bef_effect_ai_skeleton.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. #ifndef BEF_EFFECT_AI_SKELETON_H
  2. #define BEF_EFFECT_AI_SKELETON_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_MAX_SKELETON_POINT_NUM 18
  8. #define BEF_AI_MAX_SKELETON_NUM 2
  9. typedef struct bef_ai_skeleton_point_info_st {
  10. float x; // 对应 cols, 范围在 [0, width] 之间
  11. float y; // 对应 rows, 范围在 [0, height] 之间
  12. bool is_detect; // 如果该值为 0, 则 x,y 无意义
  13. float score;
  14. } bef_ai_skeleton_point_info;
  15. typedef struct bef_ai_skeleton_info_st {
  16. bef_ai_skeleton_point_info keyPointInfos[BEF_AI_MAX_SKELETON_POINT_NUM]; // 检测到的骨骼信息
  17. bef_ai_rect skeletonRect; // 骨骼rect
  18. } bef_ai_skeleton_info;
  19. typedef struct bef_ai_skeleton_result_st {
  20. bef_ai_rotate_type orient;
  21. int body_count;
  22. bef_ai_skeleton_info body[BEF_AI_MAX_SKELETON_NUM];
  23. } bef_ai_skeleton_result;
  24. /**
  25. * @brief 创建骨骼的句柄
  26. * @param [in] model_path 模型文件路径
  27. * @param [out] handle Created skeleton handle
  28. * 创建的骨骼句柄
  29. * @return If succeed return BEF_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  30. * 成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  31. */
  32. BEF_SDK_API bef_effect_result_t
  33. bef_effect_ai_skeleton_create(
  34. const char *model_path,
  35. bef_effect_handle_t *handle
  36. );
  37. /**
  38. * @brief 人体关键点检测
  39. * @param [in] handle Created skeleton handle
  40. * 已创建的骨骼句柄
  41. * @param [in] image Image base address
  42. * 输入图片的数据指针
  43. * @param [in] pixel_format Pixel format of input image
  44. * 输入图片的格式
  45. * @param [in] image_width Image width
  46. * 输入图像的宽度 (以像素为单位)
  47. * @param [in] image_height Image height
  48. * 输入图像的高度 (以像素为单位)
  49. * @param [in] image_stride Image stride in each row
  50. * 输入图像每一行的步长 (以像素为单位)
  51. * @param [in] orientation Image orientation
  52. * 输入图像的转向,具体请参考 bef_effect_ai_public_define.h 中的 bef_rotate_type
  53. * @param [in, out] skeleton_info_num 不可为 NULL, 如果传入*skeleton_info为NULL,传入数据无意义,会返回检测的骨骼数量
  54. * 如果*skeleton_info不为NULL,表示skeleton_info的长度,
  55. * 如果 skeleton_info_num 大于 *skeleton_info长度,则 返回*skeleton_info长度
  56. * @param [in, out] skeleton_info skeleton_info不可为nullptr,如果传入*skeleton_info为NULL,则内部会分配内存,需要调用者使用delete[] (*skeleton_info)释放
  57. * 如果*skeleton_info不为NULL,则长度为*skeleton_info_num,
  58. * 会根据检测结果最多填充*skeleton_info_num个骨骼数据
  59. * @return If succeed return BEF_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  60. * 成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  61. */
  62. BEF_SDK_API bef_effect_result_t
  63. bef_effect_ai_skeleton_detect(
  64. bef_effect_handle_t handle,
  65. const unsigned char *image,
  66. bef_ai_pixel_format pixel_format,
  67. int image_width,
  68. int image_height,
  69. int image_stride,
  70. bef_ai_rotate_type orientation,
  71. int *skeleton_info_num,
  72. bef_ai_skeleton_info **skeleton_info
  73. );
  74. /**
  75. * @brief 人体关键点检测图片模式
  76. * @param [in] handle Created skeleton handle
  77. * 已创建的骨骼句柄
  78. * @param [in] image Image base address
  79. * 输入图片的数据指针
  80. * @param [in] pixel_format Pixel format of input image
  81. * 输入图片的格式
  82. * @param [in] image_width Image width
  83. * 输入图像的宽度 (以像素为单位)
  84. * @param [in] image_height Image height
  85. * 输入图像的高度 (以像素为单位)
  86. * @param [in] image_stride Image stride in each row
  87. * 输入图像每一行的步长 (以像素为单位)
  88. * @param [in] orientation Image orientation
  89. * 输入图像的转向,具体请参考 bef_effect_ai_public_define.h 中的 bef_rotate_type
  90. * @param [in, out] skeleton_info_num 不可为 NULL, 如果传入*skeleton_info为NULL,传入数据无意义,会返回检测的骨骼数量
  91. * 如果*skeleton_info不为NULL,表示skeleton_info的长度,
  92. * 如果 skeleton_info_num 大于 *skeleton_info长度,则 返回*skeleton_info长度
  93. * @param [in, out] skeleton_info skeleton_info不可为nullptr,如果传入*skeleton_info为NULL,则内部会分配内存,需要调用者使用delete[] (*skeleton_info)释放
  94. * 如果*skeleton_info不为NULL,则长度为*skeleton_info_num,
  95. * 会根据检测结果最多填充*skeleton_info_num个骨骼数据
  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. */
  100. BEF_SDK_API bef_effect_result_t bef_effect_ai_skeleton_detect_image_mode(
  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. int *skeleton_info_num,
  109. bef_ai_skeleton_info **skeleton_info
  110. );
  111. /**
  112. * @brief set detection inputSize 设置检测算法的输入尺寸
  113. * 如果不设置,默认width = 128 height = 224
  114. * @param [in] handle Created skeleton handle
  115. * 已创建的骨骼句柄
  116. * @param [in] width Skeleton detect width
  117. * 宽度
  118. * @param [in] height Skeleton detect network height
  119. * 高度
  120. * @return If succeed return BEF_RESULT_SUC, other value please refer bef_effect_ai_public_define.h
  121. * 成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  122. */
  123. BEF_SDK_API bef_effect_result_t
  124. bef_effect_ai_skeleton_set_detection_inputsize(
  125. bef_effect_handle_t handle,
  126. int width,
  127. int height
  128. );
  129. /**
  130. * @brief set tracking inputsize 设置跟踪算法的输入尺寸
  131. * 如果不设置,默认width = 144 height = 192
  132. * @param [in] handle Created skeleton handle
  133. * 已创建的骨骼句柄
  134. * @param [in] width Skeleton detect width
  135. * 宽度
  136. * @param [in] height Skeleton detect network height
  137. * 高度
  138. * @return If succeed return BEF_RESULT_SUC, other value please refer bef_effect_ai_public_define.h
  139. * 成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  140. */
  141. BEF_SDK_API bef_effect_result_t
  142. bef_effect_ai_skeleton_set_tracking_inputsize(
  143. bef_effect_handle_t handle,
  144. int width,
  145. int height
  146. );
  147. /**
  148. * @brief 检测骨骼个数, 最大数设置为 BEF_MAX_SKELETON_NUM 为 2
  149. * @param [in] handle Created skeleton handle
  150. * 已创建的骨骼句柄
  151. * @param [in] max_skeleton_num 设置检测最大g骨骼数 range in [1, 2]
  152. * @return If succeed return BEF_RESULT_SUC, other value please refer bef_effect_ai_public_define.h
  153. * 成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  154. */
  155. BEF_SDK_API bef_effect_result_t
  156. bef_effect_ai_skeleton_set_targetnum(
  157. bef_effect_handle_t handle,
  158. int max_skeleton_num
  159. );
  160. /**
  161. * @param [in] handle Destroy the created skeleton handle
  162. * 销毁创建的骨骼句柄
  163. */
  164. BEF_SDK_API void
  165. bef_effect_ai_skeleton_destroy(
  166. bef_effect_handle_t handle
  167. );
  168. /**
  169. * @brief 人体关键点授权
  170. * @param [in] handle Created skeleton detect handle
  171. * 已创建的骨骼检测句柄
  172. * @param [in] license 授权文件字符串
  173. * @param [in] length 授权文件字符串长度
  174. * @return If succeed return BEF_RESULT_SUC, other value please refer bef_effect_ai_public_define.h
  175. * 成功返回 BEF_RESULT_SUC, 授权码非法返回 BEF_RESULT_INVALID_LICENSE ,其它失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  176. */
  177. #if defined(__ANDROID__) || defined(TARGET_OS_ANDROID)
  178. BEF_SDK_API bef_effect_result_t bef_effect_ai_skeleton_check_license(JNIEnv* env, jobject context, bef_effect_handle_t handle, const char *licensePath);
  179. #else
  180. #ifdef __APPLE__
  181. BEF_SDK_API bef_effect_result_t bef_effect_ai_skeleton_check_license(bef_effect_handle_t handle, const char *licensePath);
  182. #endif
  183. #endif
  184. BEF_SDK_API bef_effect_result_t
  185. bef_effect_ai_skeleton_check_online_license(bef_effect_handle_t handle, const char *licensePath);
  186. #endif // BEF_EFFECT_AI_SKELETON_H