提交
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#ifndef _YT_COMMON_H_
|
||||
#define _YT_COMMON_H_
|
||||
|
||||
typedef void *yt_handle;
|
||||
|
||||
typedef enum {
|
||||
YT_IMG_BGR_8UC3,
|
||||
YT_IMG_RGB_8UC3,
|
||||
YT_IMG_GRAY_8UC1,
|
||||
YT_IMG_DEPTH_16UC1,
|
||||
YT_IMG_BGRA_8UC4,
|
||||
YT_IMG_RGBA_8UC4,
|
||||
YT_IMG_NV21,
|
||||
YT_IMG_NV12,
|
||||
YT_IMG_UNKNOWN,
|
||||
} yt_img_type;
|
||||
|
||||
typedef struct yt_image_t {
|
||||
unsigned char *data;
|
||||
int width;
|
||||
int height;
|
||||
yt_img_type type;
|
||||
} yt_image;
|
||||
|
||||
typedef struct yt_rect_t {
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
} yt_rect;
|
||||
|
||||
typedef struct yt_pointf_t {
|
||||
float x;
|
||||
float y;
|
||||
} yt_pointf;
|
||||
|
||||
typedef struct yt_point3f_t {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} yt_point3f;
|
||||
|
||||
#endif // _YT_COMMON_H_
|
||||
@@ -0,0 +1,74 @@
|
||||
#ifndef _YT_DEFINES_H_
|
||||
#define _YT_DEFINES_H_
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// YouTu for cross platform defines export c api.
|
||||
// windows @see: http://geoffair.net/ms/declspec.htm
|
||||
// ----------------------------------------------------------------------------
|
||||
#if (defined(WIN32) || defined(WIN64))
|
||||
#ifdef YT_EXPORT
|
||||
#define YT_PUBLIC_ __declspec(dllexport)
|
||||
#else
|
||||
#define YT_PUBLIC_ __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#ifdef YT_EXPORT
|
||||
#define YT_PUBLIC_ __attribute__((visibility("default")))
|
||||
#else
|
||||
#define YT_PUBLIC_
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define YT_PUBLIC extern "C" YT_PUBLIC_
|
||||
#else
|
||||
#define YT_PUBLIC YT_PUBLIC_
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// YouTu error code defines
|
||||
// ----------------------------------------------------------------------------
|
||||
#define YT_SUCCESS 0
|
||||
#define YT_ERROR -1
|
||||
|
||||
// init error code: [-10, -99]
|
||||
#define YT_ERROR_OPEN_FILE -10
|
||||
#define YT_ERROR_READ_FILE -11
|
||||
#define YT_ERROR_FILE_EMPTY -12
|
||||
|
||||
#define YT_ERROR_RPN_NET_INIT -20
|
||||
#define YT_ERROR_RPN_NET_NOT_INIT -21
|
||||
#define YT_ERROR_RPN_INST_INIT -22
|
||||
#define YT_ERROR_RPN_INST_NOT_INIT -23
|
||||
#define YT_ERROR_RPN_FORWARD -24
|
||||
#define YT_ERROR_TNN_MEMORY_ALLOC_FAILED -25
|
||||
|
||||
#define YT_ERROR_INVALID_INSTANCE -99
|
||||
|
||||
// arguments error code: [-100, -999]
|
||||
#define YT_ERROR_MUST_NOT_NULL -100
|
||||
|
||||
#define YT_ERROR_IMAGE_TYPE -110
|
||||
#define YT_ERROR_IMAGE_DATA -111
|
||||
|
||||
#define YT_ERROR_FACE_POINTS -120
|
||||
#define YT_ERROR_FACE_FIVE_POINTS -121
|
||||
#define YT_ERROR_FACE_NINETY_POINTS -122
|
||||
#define YT_ERROR_FACE_RECT -123
|
||||
|
||||
#define YT_ERROR_INVALID_MODEL_VERSION -130
|
||||
#define YT_ERROR_MODEL_THRESHOLDS_SIZE -131
|
||||
|
||||
// auth error code
|
||||
#define YT_ERROR_AUTH_FAILED -1024
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// YouTu common code defines
|
||||
// ----------------------------------------------------------------------------
|
||||
#define YT_FACE_FEATURE_SIZE_512 512
|
||||
#define YT_FACE_FEATURE_SIZE_1024 1024
|
||||
|
||||
#define YT_FACE_FIVE_POINTS_SIZE 5
|
||||
#define YT_FACE_NINETY_POINTS_SIZE 90
|
||||
|
||||
#endif // _YT_DEFINES_H_
|
||||
@@ -0,0 +1,87 @@
|
||||
#ifndef _YT_FACE_DETECTOR_H_
|
||||
#define _YT_FACE_DETECTOR_H_
|
||||
|
||||
#include "yt_common.h"
|
||||
#include "yt_defines.h"
|
||||
|
||||
typedef struct yt_face_detector_param_t_liveness {
|
||||
int min_face_size; ///< 最小搜索步长,建议使用默认值
|
||||
int max_face_size; ///< 最大搜索步长,建议使用默认值
|
||||
int bigger_face_mode; ///< 检测模式:0:完整检测, 1:快速检测
|
||||
bool non_square_rect; ///< 检测框:是否为正方形框
|
||||
float threshold; ///< 检测阈值:建议使用默认值
|
||||
} Yt_face_detector_param_liveness;
|
||||
|
||||
/**
|
||||
* @brief 获取版本
|
||||
*
|
||||
* @param[in] handle 实例句柄,获得 SDK 版本
|
||||
* @return SDK 版本
|
||||
*/
|
||||
YT_PUBLIC const char *Yt_face_detector_get_version_liveness();
|
||||
|
||||
/**
|
||||
* @brief 初始化SDK,每个进程只需调用一次
|
||||
*
|
||||
* @param[in] model_dirpath 传入模型绝对路径或者相对路径,例如:`./model/face-xxx`
|
||||
* @param[in] config_filename 传入模型路径下的配置文件名称,例如:`config.ini`
|
||||
* @return YT_SUCCESS:成功,其他:失败
|
||||
*/
|
||||
YT_PUBLIC int Yt_face_detector_create_handle_liveness(yt_handle *handle, const char *model_dirpath, const char *config_filename);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <android/asset_manager.h>
|
||||
/**
|
||||
* @brief 初始化SDK,每个进程只需调用一次,该接口用于 android 加载 assets 目录下模型文件
|
||||
* 如有 jni 开发需求,可以通过此接口加载模型
|
||||
*
|
||||
* @param[in] mgr 通过 `AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);` 获得
|
||||
* @param[in] assets_model_dirpath 传入模型相对于 `assets` 目录的路径,例如:`models/face-xxx`
|
||||
* @param[in] assets_config_filename 传入模型路径下的配置文件名称,例如:`config.ini`
|
||||
* @return YT_SUCCESS:成功,其他:失败
|
||||
*/
|
||||
YT_PUBLIC int Yt_face_detector_create_handle_android_liveness(yt_handle *handle, AAssetManager *mgr, const char *model_dirpath, const char *config_filename);
|
||||
#endif
|
||||
|
||||
#ifdef UNIVERSE_IO
|
||||
#include <io/io.hpp>
|
||||
YT_PUBLIC int Yt_face_detector_create_handle_io_liveness(yt_handle* handle, const char* model_dirpath, const char* config_filename, IO* io);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief 销毁实例
|
||||
*
|
||||
* @param[in] handle 实例句柄
|
||||
*/
|
||||
YT_PUBLIC void Yt_face_detector_destroy_handle_liveness(yt_handle handle);
|
||||
|
||||
/**
|
||||
* @brief 获取参数
|
||||
*
|
||||
* @param[in] handle 实例句柄
|
||||
* @param[out] param 默认参数
|
||||
* @return YT_SUCCESS:成功,其他:失败
|
||||
*/
|
||||
YT_PUBLIC int Yt_face_detector_get_default_param_liveness(yt_handle handle, Yt_face_detector_param_liveness *param);
|
||||
|
||||
/**
|
||||
* @brief 检测接口,单帧图片检测
|
||||
*
|
||||
* @param[in] handle 实例句柄
|
||||
* @param[in] image 图片,图片类型:YT_IMG_BGR_8UC3 or YT_IMG_RGB_8UC3
|
||||
* @param[in] param 自定义的参数
|
||||
* @param[out] tracked_faces 检测到的人脸信息
|
||||
* @param[out] tracked_faces_count 检测到的人脸数量
|
||||
* @return YT_SUCCESS:成功,其他:失败
|
||||
*/
|
||||
YT_PUBLIC int Yt_face_detector_detect_liveness(yt_handle handle, const yt_image image, const Yt_face_detector_param_liveness param,
|
||||
yt_rect **rects, int *count);
|
||||
|
||||
/**
|
||||
* @brief 释放检测结果
|
||||
*
|
||||
* @param[in] rects
|
||||
*/
|
||||
YT_PUBLIC void Yt_face_detector_release_rects_liveness(yt_rect *rects);
|
||||
|
||||
#endif // _YT_FACE_DETECTOR_H_
|
||||
Reference in New Issue
Block a user