You need to enable JavaScript to run this app.
导航
表情驱动算法
最近更新时间:2025.03.17 14:05:55首次发布时间:2025.03.17 14:05:55
我的收藏
有用
有用
无用
无用
简介

AvaBoost 是一款用于面部表情驱动的算法,可以输出 ARKit 体系下的 【52 维表情系数】以及【人脸姿态矩阵】。算法要求输入分辨率360x640或以上。
该算法为V4.5.0新增算法。

技术规格
支持平台Android、iOS
支持输入格式RGBA8888、BGRA8888
内存占用<23M (测试设备OPPO R11)
检测速度<37ms(测试设备OPPO R11)
C接口说明

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

1.创建表情驱动算法句柄

BEF_SDK_API
bef_effect_result_t bef_effect_ai_avaboost_create(bef_effect_handle_t *handle);

参数说明

参数名参数类型参数说明
handlebef_effect_handle_t*创建的表情驱动算法句柄

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

2.表情驱动算法初始化

BEF_SDK_API
bef_effect_result_t bef_effect_ai_avaboost_init(bef_effect_handle_t handle, const char *modelPath);

参数说明

参数名参数类型参数说明
handlebef_effect_handle_t表情驱动算法句柄
modelPathconst char*表情驱动算法模型路径

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

3.表情驱动算法检测

BEF_SDK_API
bef_effect_result_t bef_effect_ai_avaboost_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_avaboost_ret* result
);

参数说明

参数名参数类型参数说明
handlebef_effect_handle_t表情驱动算法句柄
imageconst unsigned char*输入图像buffer
pixel_formatbef_ai_pixel_format输入图像格式
image_widthint输入图像宽度
image_heightint输入图像高度
image_strideint输入图像通道数
orientationbef_ai_rotate_type输入图像是否存在旋转,人脸为正时认为图像不需要旋转
resultbef_ai_avaboost_ret*

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

4.表情驱动算法授权

/**
 * @brief avaboost授权
 * @param [in] handle Created avaboost handle
 *                    已创建的avaboost句柄
 * @param [in] license 授权文件字符串
 * @param [in] length  授权文件字符串长度
 * @return If succeed return BEF_RESULT_SUC, other value please refer bef_effect_ai_public_define.h
 *         成功返回 BEF_RESULT_SUC, 授权码非法返回 BEF_RESULT_INVALID_LICENSE ,其它失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
 */
BEF_SDK_API
bef_effect_result_t bef_effect_ai_avaboost_check_license(bef_effect_handle_t handle, const char *licensePath);

BEF_SDK_API
bef_effect_result_t bef_effect_ai_avaboost_check_online_license(bef_effect_handle_t handle, const char *licensePath);

参数说明

参数名参数类型参数说明
handlebef_effect_handle_t表情驱动算法句柄
licensePathconst char *授权文件路径

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

5.表情驱动算法释放

BEF_SDK_API
bef_effect_result_t bef_effect_ai_avaboost_release(bef_effect_handle_t handle);

参数说明

参数名参数类型参数说明
handlebef_effect_handle_t表情驱动算法句柄

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

算法输出的表情系数依次对应的blendshape

['eyeLookDown_L', 'noseSneer_L', 'eyeLookIn_L', 'browInnerUp', 'eyeSquint_L', 'mouthClose', 'mouthLowerDown_R', 'jawOpen', 'mouthShrugLower', 'mouthLowerDown_L', 'mouthFunnel', 'eyeLookIn_R', 'eyeLookDown_R', 'noseSneer_R', 'mouthRollUpper', 'jawRight', 'mouthDimple_L', 'mouthRollLower', 'mouthSmile_L', 'mouthPress_L', 'mouthSmile_R', 'mouthPress_R', 'mouthDimple_R', 'mouthLeft', 'browDown_R', 'browDown_L', 'mouthFrown_L', 'eyeBlink_L', 'cheekSquint_L', 'browOuterUp_L', 'eyeLookUp_L', 'jawLeft', 'mouthStretch_L', 'mouthStretch_R', 'mouthPucker', 'eyeLookUp_R', 'browOuterUp_R', 'cheekSquint_R', 'eyeBlink_R', 'mouthUpperUp_L', 'mouthFrown_R', 'eyeSquint_R', 'jawForward', 'mouthUpperUp_R', 'cheekPuff', 'eyeLookOut_L', 'eyeLookOut_R', 'eyeWide_R', 'mouthRight', 'eyeWide_L', 'mouthShrugUpper', 'tongueOut']

Java 接口说明

接口说明
详细接口说明查看文件:com.effectsar.labcv.effectsdk.AvaBoost.java

1.初始化表情驱动句柄

public int init(Context context, String modelPath, String licensePath, boolean onlineLicense)

参数说明

参数名参数类型参数说明
contextContext安卓context
modelPathString表情驱动算法模型路径
licensePathString授权文件路径
onlineLicenseboolean配置在线授权或离线授权

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

2.表情驱动算法检测

public BefAvaBoostInfo detect(ByteBuffer buffer, 
                            EffectsSDKEffectConstants.PixlFormat pixelFormat, 
                            int imageWidth, 
                            int imageHeight, 
                            int imageStride, 
                             orientation)

参数说明

参数名参数类型参数说明
bufferByteBuffer输入buffer
pixelFormatEffectsSDKEffectConstants.PixlFormat输入图像格式
imageWidthint输入图像宽度
imageHeightint输入图像高度
imageStrideint输入图像步长
orientationEffectsSDKEffectConstants.Rotation输入图像是否存在旋转,人脸为正时认为图像不需要旋转

返回值
返回算法结果BefAvaBoostInfo对象,关于BefAvaBoostInfo可参考com.effectsar.labcv.effectsdk.AvaBoost.java,并且其定义与C接口bef_ai_avaboost_ret保持一致。

3.表情驱动算法释放

public void release()
FAQ

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

答:建议首先查看以下tag输出Error类型的日志:
bef_effect_ai 和SMASH_E_LOG 以及 EffectSDK

错误码

错误码请参考错误码表