函数定义
BEF_SDK_API bef_effect_result_t bef_effect_ai_action_recognition_create( const char * model_path bef_effect_handle_t * handle );
参数说明
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| model_path | const char * | 模型文件路径 |
| handle | bef_effect_handle_t * | Created action_recognition handle 创建的动作识别句柄 |
返回值: BEF_SDK_API bef_effect_result_t
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
函数定义
BEF_SDK_API void bef_effect_ai_action_recognition_destroy( bef_effect_handle_t handle );
参数说明
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| handle | bef_effect_handle_t | Destroy the created action_recognition handle 销毁创建的动作识别句柄 |
返回值: BEF_SDK_API void
函数定义
BEF_SDK_API bef_effect_result_t bef_effect_ai_action_recognition_set_template( bef_effect_handle_t handle const char * template_path );
参数说明
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| handle | bef_effect_handle_t | Created action_recognition handle 已创建的动作识别句柄 |
| template_path | const char * | 模板文件路径 |
返回值: BEF_SDK_API bef_effect_result_t
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
函数定义
BEF_SDK_API bef_effect_result_t bef_effect_ai_action_recognition_start_pose_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_action_recognition_start_pose_type type bef_ai_action_recognition_start_pose_result * result );
参数说明
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| handle | bef_effect_handle_t | Created action_recognition handle 已创建的骨骼句柄 |
| image | const unsigned char * | Image base address 输入图片的数据指针 |
| pixel_format | bef_ai_pixel_format | Pixel format of input image 输入图片的格式 |
| image_width | int | Image width 输入图像的宽度 (以像素为单位) |
| image_height | int | Image height 输入图像的高度 (以像素为单位) |
| image_stride | int | Image stride in each row 输入图像每一行的步长 (以像素为单位) |
| orientation | bef_ai_rotate_type | Image orientation 输入图像的转向,具体请参考 bef_effect_ai_public_define.h 中的 bef_rotate_type |
| type | bef_ai_action_recognition_start_pose_type | pose type 姿势类型 |
| result | bef_ai_action_recognition_start_pose_result * | result |
返回值: BEF_SDK_API bef_effect_result_t
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
函数定义
BEF_SDK_API bef_effect_result_t bef_effect_ai_action_recognition_count( 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 int confirm_time bef_ai_action_recognition_result * action_recognition_result );
参数说明
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| handle | bef_effect_handle_t | Created action_recognition handle 已创建的骨骼句柄 |
| image | const unsigned char * | Image base address 输入图片的数据指针 |
| pixel_format | bef_ai_pixel_format | Pixel format of input image 输入图片的格式 |
| image_width | int | Image width 输入图像的宽度 (以像素为单位) |
| image_height | int | Image height 输入图像的高度 (以像素为单位) |
| image_stride | int | Image stride in each row 输入图像每一行的步长 (以像素为单位) |
| orientation | bef_ai_rotate_type | Image orientation 输入图像的转向,具体请参考 bef_effect_ai_public_define.h 中的 bef_rotate_type |
| confirm_time | int | count confirmation time 计数确认时长 |
| action_recognition_result | bef_ai_action_recognition_result * | 不可为nullptr |
返回值: BEF_SDK_API bef_effect_result_t
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
函数定义
BEF_SDK_API bef_effect_result_t bef_effect_ai_action_recognition_check_license( JNIEnv * env jobject context bef_effect_handle_t handle const char * licensePath );
参数说明
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| env | JNIEnv * | JNIEnv 环境 |
| context | jobject | Android Context 对象 |
| handle | bef_effect_handle_t | Created action_recognition handle 已创建的动作识别句柄 |
| licensePath | const char * | licensePath |
返回值: BEF_SDK_API bef_effect_result_t
成功返回 BEF_RESULT_SUC, 授权码非法返回 BEF_RESULT_INVALID_LICENSE ,其它失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
函数定义
BEF_SDK_API bef_effect_result_t bef_effect_ai_action_recognition_check_license( bef_effect_handle_t handle const char * licensePath );
参数说明
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| handle | bef_effect_handle_t | Created action_recognition handle 已创建的动作识别句柄 |
| licensePath | const char * | licensePath |
返回值: BEF_SDK_API bef_effect_result_t
成功返回 BEF_RESULT_SUC, 授权码非法返回 BEF_RESULT_INVALID_LICENSE ,其它失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
接口可以调整阈值,以达到识别难度降低的效果。
函数定义
BEF_SDK_API bef_effect_result_t bef_effect_ai_action_recognition_set_template_threshold(bef_effect_handle_t handle, float threshold);
参数说明
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| handle | bef_effect_handle_t | Created action_recognition handle 已创建的动作识别句柄 |
| threshold | float | 模板阈值 |
返回值
成功返回 BEF_RESULT_SUC, 授权码非法返回 BEF_RESULT_INVALID_LICENSE ,其它失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
备注
阈值范围见此文档附录
动作计数结果信息
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| keypoints | bef_ai_tt_key_point[BEF_AI_ACTION_RECOGNITION_MAX_POINT_NUM] | 检测到的骨骼信息 |
| feed_body_part | bef_ai_action_recognition_feedback_body_part | 反馈的身体部位类别 |
| feedback_keypoints | bef_ai_tt_key_point[BEF_AI_ACTION_RECOGNITION_MAX_POINT_NUM *2] | 检测到的反馈骨骼信息 |
| feedback_kp_count | int | 检测到的反馈骨骼信息数量,feedback_keypoints的实际长度 |
| recognize_succeed | bool | 是否计数成功,为true时,表示计数成功,界面可以增加计数 |
| is_feedback_valid | bool | 反馈信息是否有效,为true时,表示信息有效,界面可以显示反馈信息 |
初始姿态检测结果信息
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| is_detected | bool | 是否通过初始姿态检测,为true时,表示通过检测,可以开始计数 |
反馈的身体部位类别
| 参数名 | 参数说明 |
|---|---|
| BEF_AI_ACTION_RECOGNITION_FeedbackNone | |
| BEF_AI_ACTION_RECOGNITION_FeedbackLeftArm | 左臂 |
| BEF_AI_ACTION_RECOGNITION_FeedbackRightArm | 右臂 |
| BEF_AI_ACTION_RECOGNITION_FeedbackLeftLeg | 左腿 |
| BEF_AI_ACTION_RECOGNITION_FeedbackRightLeg | 右腿 |
初始姿态类别
| 参数名 | 参数说明 |
|---|---|
| BEF_AI_ACTION_RECOGNITION_Stand | 站立 |
| BEF_AI_ACTION_RECOGNITION_Lying | 平躺 |
| BEF_AI_ACTION_RECOGNITION_Sitting | 坐姿 |
| 参数名 | 参数值 | 参数说明 |
|---|---|---|
| BEF_AI_ACTION_RECOGNITION_MAX_POINT_NUM | 18 | 最大骨骼点数量 |
动作计数 API 类
函数定义
int init( Context context String modelPath String licensePath );
参数说明
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| context | Context | Android Context 对象 |
| modelPath | String | 模型文件路径 |
| licensePath | String | 授权文件路径 |
返回值: int
函数定义
int setTemplate( String templatePath );
参数说明
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| templatePath | String | 模版文件路径 |
返回值: int
函数定义
BefActionRecognitionInfo.PoseDetectResult detectPose( ByteBuffer buffer BytedEffectConstants.PixlFormat pixelFormat int width int height int stride BefActionRecognitionInfo.ActionRecognitionPoseType poseType BytedEffectConstants.Rotation orientation );
参数说明
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| buffer | ByteBuffer | 图片数据 |
| pixelFormat | BytedEffectConstants.PixlFormat | 图片格式 |
| width | int | 宽 |
| height | int | 高 |
| stride | int | 步长 |
| poseType | BefActionRecognitionInfo.ActionRecognitionPoseType | 姿态类型 |
| orientation | BytedEffectConstants.Rotation | 图像旋转方向,具体见 Rotation |
返回值: BefActionRecognitionInfo.PoseDetectResult
姿态检测结果,具体见 PoseDetectResult
函数定义
BefActionRecognitionInfo detect( ByteBuffer buffer BytedEffectConstants.PixlFormat pixelFormat int width int height int stride BytedEffectConstants.Rotation orientation int confirmTime );
参数说明
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| buffer | ByteBuffer | 图片数据 |
| pixelFormat | BytedEffectConstants.PixlFormat | 图片格式 |
| width | int | 宽 |
| height | int | 高 |
| stride | int | 步长 |
| orientation | BytedEffectConstants.Rotation | 图像旋转方向,具体见 Rotation |
| confirmTime | int | 计数确认时长 |
返回值: BefActionRecognitionInfo
动作计数结果,具体见 BefActionRecognitionInfo
函数定义
int setThreshold(float threshold)
参数说明
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| threshold | float | 模板阈值 |
返回值
返回算法阈值
备注
阈值调节范围见此文档附录
函数定义
void destroy( );
返回值: void
动作计数检测结果
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| keyPoints | BefPublicDefine.BefKeyPoint[] | 检测到的骨骼信息 |
| feedbackPart | int | 反馈的身体部位类别 |
| feedbackKeyPoints | BefPublicDefine.BefKeyPoint[] | 检测到的反馈骨骼信息 |
| recognizeSucceed | boolean | 是否计数成功,为true时,表示计数成功,界面可以增加计数 |
| isFeedbackValid | boolean | 反馈信息是否有效,为true时,表示信息有效,界面可以显示反馈信息 |
初始姿态检测结果信息
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| isDetected | boolean | 是否通过初始姿态检测,为true时,表示通过检测,可以开始计数 |
动作计数检测结果
| 参数名 | 参数类型 | 参数说明 |
|---|---|---|
| keyPoints | BefPublicDefine.BefKeyPoint[] | 检测到的骨骼信息 |
| feedbackPart | int | 反馈的身体部位类别 |
| feedbackKeyPoints | BefPublicDefine.BefKeyPoint[] | 检测到的反馈骨骼信息 |
| recognizeSucceed | boolean | 是否计数成功,为true时,表示计数成功,界面可以增加计数 |
| isFeedbackValid | boolean | 反馈信息是否有效,为true时,表示信息有效,界面可以显示反馈信息 |
阈值调整范围:
安卓:
| 动作 | 最小阈值 | 最大阈值 |
|---|---|---|
| 开合跳 | 0.3 | 0.5 |
| 深蹲 | 0.3 | 0.48 |
| 平板支撑 | 0.3 | 0.55 |
| 俯卧撑 | 0.3 | 0.52 |
| 仰卧起坐 | 0.3 | 0.46 |
| 高抬腿跑 | 0.3 | 0.5 |
| 箭步蹲 | 0.3 | 0.5 |
| 臀桥 | 0.3 | 0.49 |
| 弓箭步跳 | 0.3 | 0.53 |
| 跪姿俯卧撑 | 0.3 | 0.52 |
iOS:
| 动作 | 最小阈值 | 最大阈值 |
|---|---|---|
| 开合跳 | 0.3 | 0.5 |
| 深蹲 | 0.3 | 0.48 |
| 平板支撑 | 0.3 | 0.55 |
| 俯卧撑 | 0.3 | 0.52 |
| 仰卧起坐 | 0.3 | 0.46 |
| 高抬腿跑 | 0.3 | 0.5 |
| 箭步蹲 | 0.3 | 0.5 |
| 臀桥 | 0.3 | 0.5 |
| 弓箭步跳 | 0.3 | 0.52 |
| 跪姿俯卧撑 | 0.3 | 0.53 |