You need to enable JavaScript to run this app.
导航

宠物脸识别

最近更新时间2023.06.28 14:45:08

首次发布时间2022.02.25 17:16:51

简介

宠物脸识别SDK提供宠物分类、宠物脸脸关键点跟踪和宠物面部动作分析的能力,具备检测速度快、跟踪稳定、性能开销低等特点。

猫脸82关键点索引图

猫82landmarks.jpeg

狗脸90关键点索引图

dog_landmarks.png

狗脸76关键点索引图

在90个关键点图的基础上去掉的耳朵部分【26-39】14个关键点,其它关键点40号之后顺延。

技术规格
支持平台Android、iOS、Windows、Mac
支持角度yaw ≤ ±90° pitch ≤ ±90°
支持输入格式RGBA8888、BGRA8888、BGR888、RGB888、NV21、NV12、YUV420P
支持最大宠物脸数10
支持最小输入尺寸短边128
支持距离脸占图片短边的1/10以上
检测速度<8ms(测试设备OppoR11,高通660)
C接口说明

详细接口说明查看头文件:bef_effect_ai_pet_face.h

接口说明

1. 创建宠物脸检测句柄

创建宠物脸检测的句柄

BEF_SDK_API
bef_effect_result_t
bef_effect_ai_pet_face_create(
    const char * strModelPath,
    long long config,
    unsigned int maxNum,
    bef_effect_handle_t *handle
);

参数说明

参数名参数类型参数说明
strModelPathconst char *模型文件所在路径
configlong long config,宠物脸检测算法的配置
可以配置只检测猫,只检测狗,或者同时检测猫狗
max_face_numunsigned int指定最多能够检测到的宠物脸数目
handlebef_effect_handle_t创建的宠物脸检测句柄

备注

配置参数可以参考bef_ai_pet_face_config_type, 例如:

只检测狗

detect_config = bef_ai_pet_face_config_type::BEF_DetDog

同时检测猫狗:

detect_config = bef_ai_pet_face_config_type::BEF_DetDog|bef_ai_pet_face_config_type::BEF_DetCat

返回值

成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h

2. 宠物脸检测授权

android接口

BEF_SDK_API bef_effect_result_t bef_effect_ai_pet_face_check_license(
	JNIEnv* env,
    jobject context, 
    bef_effect_handle_t handle, 
    const char *license_path
);

参数说明

参数名参数类型参数说明
envJNIEnv *jni环境
contextjobjectjni对象
handlebef_effect_handle_t已创建的宠物脸检测句柄
license_pathconst char *授权文件路径

返回值

成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h

ios接口

BEF_SDK_API bef_effect_result_t bef_effect_ai_pet_face_check_license(
	bef_effect_handle_t handle,
    const char *license_path
);

参数说明

参数名参数类型参数说明
handlebef_effect_handle_t已创建的宠物脸检测句柄
license_pathconst char *授权文件路径

返回值

成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h

3. 检测宠物脸关键点

BEF_SDK_API
bef_effect_result_t bef_effect_ai_pet_face_detect(
    bef_effect_handle_t handle,
    const unsigned char *image,
    bef_ai_pixel_format pixel_format,
    int image_width,
    int image_height,
    int image_stride,
    bef_ai_rotate_type orientation,
    bef_ai_pet_face_result *p_pet_face_result
);

参数说明

参数名参数类型参数说明
handlebef_effect_handle_t已创建的宠物脸检测句柄
imageconst unsigned char *输入图片的数据指针
pixel_formatbef_ai_pixel_format输入图片的格式
image_widthint输入图像的宽度 (以像素为单位)
image_heightint输入图像的高度 (以像素为单位)
image_strideint输入图像每一行的步长 (以像素为单位)
orientationbef_ai_rotate_type输入图像的转向,具体请参考 bef_effect_ai_public_define.h 中的 bef_rotate_type
p_pet_face_resultbef_ai_pet_face_result *存放结果信息,需外部分配好内存,需保证空间大于等于设置的最大检测宠物脸数

返回值

成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h

4. 销毁宠物脸检测句柄

BEF_SDK_API
bef_effect_result_t bef_effect_ai_pet_face_release(bef_effect_handle_t handle);

参数说明

参数名参数类型参数说明
handlebef_effect_handle_t已创建的宠物脸检测句柄

返回值

成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h

Java 接口说明

接口说明

宠物脸关键点检测相关的函数定义在com.bytedance.labcv.effectsdk.PetFaceDetect.java中。

1. 初始化宠物脸检测句柄

public int init(
	Context context, 
    String modelPath, 
    int config, 
    String license
) 

参数说明

参数名参数类型参数说明
contextContext上下文
modelPathString模型文件路径
configint宠物脸检测算法的配置,config = 可检测的特征(必须设置, 参考{@link BytedEffectConstants.PetFaceAction})
licenseString授权文件

返回值

成功返回BEF_RESULT_SUC,否则返回对应的错误码

2. 检测宠物脸关键点

public BefPetFaceInfo detectFace(
    ByteBuffer buffer, 
    BytedEffectConstants.PixlFormat pixel_format, 
    int image_width, 
    int image_height, 
    int image_stride, 
    BytedEffectConstants.Rotation orientation
) 

参数说明

参数名参数类型参数说明
bufferByteBuffer图片数据
pixel_formatBytedEffectConstants.PixlFormat图片数据格式
image_widthint图片宽度
image_heightint图片高度
image_strideint图片每一行的步长
orientationBytedEffectConstants.Rotation图片旋转角度

返回值

成功返回BEF_RESULT_SUC,否则返回对应的错误码

3. 销毁宠物脸关键点检测句柄

public void release()

返回值

成功返回BEF_RESULT_SUC,否则返回对应的错误码

FAQ

1.如果出现任何异常,请查看是否有以下类型日志

答:建议首先查看以下tag输出Error类型的日志:

bef_effect_ai 和SMASH_E_LOG 以及 EffectSDK

错误码

错误码请参考错误码表