增加换肤功能
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,125 @@
|
||||
#ifndef _YT_FACE_TRACKER_H_
|
||||
#define _YT_FACE_TRACKER_H_
|
||||
|
||||
#include "yt_common.h"
|
||||
#include "yt_defines.h"
|
||||
|
||||
#define YT_MINI_NAMESPACE liveness
|
||||
|
||||
#define SUFFIX_HELPER_(x, y) x##_##y
|
||||
#define SUFFIX_HELPER(x, y) SUFFIX_HELPER_(x, y)
|
||||
#define SUFFIX(x) SUFFIX_HELPER(x, YT_MINI_NAMESPACE)
|
||||
|
||||
typedef struct yt_face_tracker_param_t_liveness {
|
||||
int min_face_size; ///< 最小物体大小,建议使用默认值
|
||||
int max_face_size; ///< 最大物体大小,建议使用默认值
|
||||
int bigger_face_mode; ///< 检测模式:0:完整检测, 1:快速检测
|
||||
bool non_square_rect; ///< 检测框:是否为正方形框
|
||||
float threshold; ///< 检测阈值:建议使用默认值
|
||||
int detect_interval; ///< 检测间隔,默认6; detect_interval为-1时,只在第一帧或没有人时做检测
|
||||
int noface_detect_interval; /// < 检测间隔, 默认0,未检测到人脸后下一次检测间隔
|
||||
} SUFFIX(Yt_face_tracker_param);
|
||||
|
||||
typedef struct yt_tracked_face_t_liveness {
|
||||
int shape_size; ///< 人脸配准点有效位数 130 or 256
|
||||
yt_pointf face_shape[256]; ///< 人脸配准点
|
||||
float face_vis[256]; ///< 人脸配准点置信度
|
||||
yt_rect face_rect; ///< 人脸框
|
||||
|
||||
int frame_id; ///< 帧ID
|
||||
int trace_id; ///< 轨迹ID
|
||||
|
||||
float pitch; ///< 人脸俯仰角
|
||||
float yaw; ///< 人脸偏航角
|
||||
float roll; ///< 人脸翻滚角
|
||||
} SUFFIX(Yt_tracked_face);
|
||||
|
||||
/**
|
||||
* @brief 获取sdk版本
|
||||
*
|
||||
* @return yt_sdk_version
|
||||
*/
|
||||
YT_PUBLIC const char *SUFFIX(Yt_face_tracker_get_version)();
|
||||
|
||||
/**
|
||||
* @brief 创建实例,每个线程需要单独的实例
|
||||
*
|
||||
* @param[out] handle 创建的handle,每个线程需要独立的handle
|
||||
* @param[in] model_dirpath 传入模型绝对路径或者相对路径,例如:./model/
|
||||
* @param[in] config_filename 传入模型绝对路径或者相对路径下的配置文件名称,例如:config.ini
|
||||
* @param[in] param 模型初始化参数,其中的image_width、image_height和image_pading属性要根据视频长宽调整
|
||||
* @return YT_SUCCESS:成功,其他:失败
|
||||
*/
|
||||
YT_PUBLIC int SUFFIX(Yt_face_tracker_create_handle)(yt_handle *handle, const char *model_dirpath, const char *config_filename);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <android/asset_manager.h>
|
||||
/**
|
||||
* @brief 创建实例,每个线程需要单独的实例,该接口用于 android 加载 assets 目录下模型文件
|
||||
* 如有 jni 开发需求,可以通过此接口加载模型
|
||||
*
|
||||
* @param[in] mgr 通过 `AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);` 获得
|
||||
* @param[in] model_dirpath 传入模型相对于 `assets` 目录的路径,例如:`models/face-xxx`
|
||||
* @param[in] config_filename 传入模型路径下的配置文件名称,例如:`config.ini`
|
||||
* @return YT_SUCCESS:成功,其他:失败
|
||||
*/
|
||||
YT_PUBLIC int SUFFIX(Yt_face_tracker_create_handle_android)(yt_handle *handle, AAssetManager *mgr, const char *model_dirpath, const char *config_filename);
|
||||
#endif
|
||||
|
||||
#ifdef UNIVERSE_IO
|
||||
# include "io.hpp"
|
||||
YT_PUBLIC int SUFFIX(Yt_face_tracker_create_handle_io)(yt_handle* handle, const char* model_dirpath, const char* config_filename, IO* io);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief 销毁实例
|
||||
*
|
||||
* @param[in] handle 实例句柄
|
||||
*/
|
||||
YT_PUBLIC void SUFFIX(Yt_face_tracker_destroy_handle)(yt_handle handle);
|
||||
|
||||
/**
|
||||
* @brief 获取参数
|
||||
*
|
||||
* @param[in] handle 实例句柄
|
||||
* @param[out] param 当前实例的参数
|
||||
* @return YT_SUCCESS:成功,其他:失败
|
||||
*/
|
||||
YT_PUBLIC int SUFFIX(Yt_face_tracker_get_param)(yt_handle handle, SUFFIX(Yt_face_tracker_param) *param);
|
||||
|
||||
/**
|
||||
* @brief 设置参数,推荐先获取参数,再设置
|
||||
*
|
||||
* @param[in] handle 实例句柄
|
||||
* @param[in] param 自定义的参数
|
||||
* @return YT_SUCCESS:成功,其他:失败
|
||||
*/
|
||||
YT_PUBLIC int SUFFIX(Yt_face_tracker_set_param)(yt_handle handle, const SUFFIX(Yt_face_tracker_param) param);
|
||||
|
||||
/**
|
||||
* @brief 追踪接口,适合于视频流检测,内部封装了检测、5点配准、稳定模块,具有内部状态
|
||||
*
|
||||
* @param[in] handle 实例句柄
|
||||
* @param[in] image 图片,图片类型:YT_IMG_BGR_8UC3 or YT_IMG_RGB_8UC3
|
||||
* @param[out] tracked_faces 人脸追踪结果
|
||||
* @param[out] tracked_faces_count 检测到的人脸数量
|
||||
* @return YT_SUCCESS:成功,其他:失败
|
||||
*/
|
||||
YT_PUBLIC int SUFFIX(Yt_face_tracker_track)(yt_handle handle, const yt_image image, SUFFIX(Yt_tracked_face) **tracked_faces, int *tracked_faces_count);
|
||||
|
||||
/**
|
||||
* @brief 重置追踪接口,当对新的视频进行追踪时调用,用于清空追踪内部状态
|
||||
*
|
||||
* @param[in] handle 实例句柄
|
||||
* @return YT_SUCCESS:成功,其他:失败
|
||||
*/
|
||||
YT_PUBLIC int SUFFIX(Yt_face_tracker_reset)(yt_handle handle);
|
||||
|
||||
/**
|
||||
* @brief 释放人脸追踪结果
|
||||
*
|
||||
* @param[in] tracked_faces 人脸追踪结果
|
||||
*/
|
||||
YT_PUBLIC void SUFFIX(Yt_face_tracker_release_tracked_faces)(SUFFIX(Yt_tracked_face) *tracked_faces);
|
||||
|
||||
#endif // _YT_FACE_TRACKER_H_
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleName</key>
|
||||
<string>YTFaceTracker</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.tencent.youtu.tracker</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>YTFaceTrackerLiveness</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>v3.0.5-mini.16</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>v3.0.5-mini.16</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
</dict>
|
||||
</plist>
|
||||
Binary file not shown.
Reference in New Issue
Block a user