bef_effect_ai_action_recognition.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. #ifndef BEF_EFFECT_AI_ACTION_RECOGNITION_H
  2. #define BEF_EFFECT_AI_ACTION_RECOGNITION_H
  3. #include "bef_effect_ai_public_define.h"
  4. #if defined(__ANDROID__) || defined(TARGET_OS_ANDROID)
  5. #include<jni.h>
  6. #endif
  7. #define BEF_AI_ACTION_RECOGNITION_MAX_POINT_NUM 18
  8. // 反馈的身体部位类别
  9. typedef enum {
  10. BEF_AI_ACTION_RECOGNITION_FeedbackNone = 0,
  11. BEF_AI_ACTION_RECOGNITION_FeedbackLeftArm = 1,// 左臂
  12. BEF_AI_ACTION_RECOGNITION_FeedbackRightArm = 2, // 右臂
  13. BEF_AI_ACTION_RECOGNITION_FeedbackLeftLeg = 3, // 左腿
  14. BEF_AI_ACTION_RECOGNITION_FeedbackRightLeg = 4, // 右腿
  15. } bef_ai_action_recognition_feedback_body_part;
  16. // 初始姿态类别
  17. typedef enum {
  18. BEF_AI_ACTION_RECOGNITION_Stand = 1, //站立
  19. BEF_AI_ACTION_RECOGNITION_Lying = 2, //平躺
  20. BEF_AI_ACTION_RECOGNITION_Sitting = 3, //坐姿
  21. BEF_AI_ACTION_RECOGNITION_SideLeft = 4,
  22. BEF_AI_ACTION_RECOGNITION_SideRight = 5
  23. } bef_ai_action_recognition_start_pose_type;
  24. //动作计数结果信息
  25. typedef struct bef_ai_action_recognition_result_st {
  26. bef_ai_tt_key_point keypoints[BEF_AI_ACTION_RECOGNITION_MAX_POINT_NUM]; // 检测到的骨骼信息
  27. bef_ai_action_recognition_feedback_body_part feed_body_part; // 反馈的身体部位类别
  28. bef_ai_tt_key_point feedback_keypoints[BEF_AI_ACTION_RECOGNITION_MAX_POINT_NUM*2]; // 检测到的反馈骨骼信息
  29. int feedback_kp_count; // 检测到的反馈骨骼信息数量,feedback_keypoints的实际长度
  30. bool recognize_succeed; // 是否计数成功,为true时,表示计数成功,界面可以增加计数
  31. bool is_feedback_valid; // 反馈信息是否有效,为true时,表示信息有效,界面可以显示反馈信息
  32. } bef_ai_action_recognition_result;
  33. //初始姿态检测结果信息
  34. typedef struct bef_ai_action_recognition_start_pose_result_st {
  35. bool is_detected; // 是否通过初始姿态检测,为true时,表示通过检测,可以开始计数
  36. } bef_ai_action_recognition_start_pose_result;
  37. /**
  38. * @brief 创建动作识别的句柄
  39. * @param [in] model_path 模型文件路径
  40. * @param [out] handle Created action_recognition handle
  41. * 创建的动作识别句柄
  42. * @return If succeed return BEF_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  43. * 成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  44. */
  45. BEF_SDK_API bef_effect_result_t
  46. bef_effect_ai_action_recognition_create(
  47. const char *model_path,
  48. bef_effect_handle_t *handle
  49. );
  50. /**
  51. * @param [in] handle Destroy the created action_recognition handle
  52. * 销毁创建的动作识别句柄
  53. */
  54. BEF_SDK_API void
  55. bef_effect_ai_action_recognition_destroy(
  56. bef_effect_handle_t handle
  57. );
  58. /**
  59. * @brief 设置动作识别模板
  60. * @param [in] handle Created action_recognition handle
  61. * 已创建的动作识别句柄
  62. * @param [in] template_path 模板文件路径
  63. * @return If succeed return BEF_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  64. * 成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  65. */
  66. BEF_SDK_API bef_effect_result_t
  67. bef_effect_ai_action_recognition_set_template(bef_effect_handle_t handle, const char *template_path);
  68. /**
  69. * @brief 设置动作识别阈值
  70. * @param [in] handle Created action_recognition handle
  71. * 已创建的动作识别句柄
  72. * @param [in] threshold 模板阈值
  73. * @return If succeed return BEF_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  74. * 成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  75. */
  76. BEF_SDK_API bef_effect_result_t
  77. bef_effect_ai_action_recognition_set_template_threshold(bef_effect_handle_t handle, float threshold);
  78. /**
  79. * @brief 动作识别开始姿态检测
  80. * @param [in] handle Created action_recognition handle
  81. * 已创建的骨骼句柄
  82. * @param [in] image Image base address
  83. * 输入图片的数据指针
  84. * @param [in] pixel_format Pixel format of input image
  85. * 输入图片的格式
  86. * @param [in] image_width Image width
  87. * 输入图像的宽度 (以像素为单位)
  88. * @param [in] image_height Image height
  89. * 输入图像的高度 (以像素为单位)
  90. * @param [in] image_stride Image stride in each row
  91. * 输入图像每一行的步长 (以像素为单位)
  92. * @param [in] orientation Image orientation
  93. * 输入图像的转向,具体请参考 bef_effect_ai_public_define.h 中的 bef_rotate_type
  94. * @param [in] type pose type 姿势类型
  95. * @param [in, out] is_detected detection result 检测结果
  96. * @return If succeed return BEF_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  97. * 成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  98. */
  99. BEF_SDK_API bef_effect_result_t
  100. bef_effect_ai_action_recognition_start_pose_detect(
  101. bef_effect_handle_t handle,
  102. const unsigned char *image,
  103. bef_ai_pixel_format pixel_format,
  104. int image_width,
  105. int image_height,
  106. int image_stride,
  107. bef_ai_rotate_type orientation,
  108. bef_ai_action_recognition_start_pose_type type,
  109. bef_ai_action_recognition_start_pose_result* result);
  110. /**
  111. * @brief 动作识别计数
  112. * @param [in] handle Created action_recognition handle
  113. * 已创建的骨骼句柄
  114. * @param [in] image Image base address
  115. * 输入图片的数据指针
  116. * @param [in] pixel_format Pixel format of input image
  117. * 输入图片的格式
  118. * @param [in] image_width Image width
  119. * 输入图像的宽度 (以像素为单位)
  120. * @param [in] image_height Image height
  121. * 输入图像的高度 (以像素为单位)
  122. * @param [in] image_stride Image stride in each row
  123. * 输入图像每一行的步长 (以像素为单位)
  124. * @param [in] confirm_time count confirmation time
  125. * 计数确认时长
  126. * @param [in] orientation Image orientation
  127. * 输入图像的转向,具体请参考 bef_effect_ai_public_define.h 中的 bef_rotate_type
  128. * @param [in, out] action_recognition_result 不可为nullptr
  129. * @return If succeed return BEF_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  130. * 成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  131. */
  132. BEF_SDK_API bef_effect_result_t
  133. bef_effect_ai_action_recognition_count(
  134. bef_effect_handle_t handle,
  135. const unsigned char *image,
  136. bef_ai_pixel_format pixel_format,
  137. int image_width,
  138. int image_height,
  139. int image_stride,
  140. bef_ai_rotate_type orientation,
  141. int confirm_time,
  142. bef_ai_action_recognition_result *action_recognition_result
  143. );
  144. /**
  145. * @brief 人体关键点授权
  146. * @param [in] handle Created action_recognition handle
  147. * 已创建的动作识别句柄
  148. * @param [in] license 授权文件字符串
  149. * @param [in] length 授权文件字符串长度
  150. * @return If succeed return BEF_RESULT_SUC, other value please refer bef_effect_ai_public_define.h
  151. * 成功返回 BEF_RESULT_SUC, 授权码非法返回 BEF_RESULT_INVALID_LICENSE ,其它失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  152. */
  153. #if defined(__ANDROID__) || defined(TARGET_OS_ANDROID)
  154. 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);
  155. #else
  156. #ifdef __APPLE__
  157. BEF_SDK_API bef_effect_result_t bef_effect_ai_action_recognition_check_license(bef_effect_handle_t handle, const char *licensePath);
  158. #endif
  159. #endif
  160. BEF_SDK_API bef_effect_result_t
  161. bef_effect_ai_action_recognition_check_online_license(bef_effect_handle_t handle, const char *licensePath);
  162. #endif // BEF_EFFECT_AI_ACTION_RECOGNITION_H