bef_effect_ai_api.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. #ifndef bef_effect_ai_api_h
  2. #define bef_effect_ai_api_h
  3. #include "bef_effect_ai_public_define.h"
  4. #include "bef_effect_ai_face_detect.h"
  5. #include "bef_effect_ai_hand.h"
  6. #include "bef_effect_ai_skeleton.h"
  7. #include "bef_effect_ai_face_attribute.h"
  8. #if (defined(__ANDROID__) || defined(TARGET_OS_ANDROID))
  9. #if BEF_EFFECT_ANDROID_WITH_JNI
  10. #include <jni.h>
  11. #include <android/asset_manager.h>
  12. #include <android/asset_manager_jni.h>
  13. #endif
  14. #endif
  15. /**
  16. * @brief Create effect handle.
  17. * @param handle Effect handle that will be created.
  18. * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h.
  19. */
  20. BEF_SDK_API bef_effect_result_t bef_effect_ai_create(bef_effect_handle_t *handle);
  21. /**
  22. * @param handle Effect handle that will destroy
  23. */
  24. BEF_SDK_API void bef_effect_ai_destroy(bef_effect_handle_t handle);
  25. /**
  26. * @brief Initialize effect handle.
  27. * @param handle Effect handle
  28. * @param width Texture width
  29. * @param height Texture height
  30. * @param strModeDir Resource folder
  31. * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  32. */
  33. BEF_SDK_API bef_effect_result_t bef_effect_ai_init(bef_effect_handle_t handle, int width, int height, const char *strModeDir, const char* deviceName);
  34. /**
  35. * @brief Initialize effect handle.
  36. * @param handle Effect handle
  37. * @param width Texture width
  38. * @param height Texture height
  39. * @param strModeDir Resource folder
  40. * @param asset_mgr Native AssetManager ptr
  41. * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  42. */
  43. BEF_SDK_API bef_effect_result_t bef_effect_ai_init_with_assetmgr(bef_effect_handle_t handle, int width, int height, const char *strModeDir, const char* deviceName, void *asset_mgr);
  44. /**
  45. * should set imageMode = true while processing images with only faceMakeup sticker has been set
  46. * @param handle
  47. * @param imageMode
  48. * @return
  49. */
  50. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_image_mode(bef_effect_handle_t handle, bool imageMode);
  51. /**
  52. * @brief Return all available features name, can only be called after bef_effect_ai_init
  53. * @return If succeed return BEF_EFFECT_RESULT_SUC, `features` will contain all available feature name item, each item has length of BEF_EFFECT_FEATURE_LEN,
  54. `len` would point to a number which stands for the amount of features.
  55. BEF_RESULT_FAIL is returned if the given space is not big enough (according to `len`) to hold data returned by this api.
  56. BEF_RESULT_INVALID_EFFECT_HANDLE is returned if this api been called before `bef_effect_ai_init`.
  57. */
  58. BEF_SDK_API bef_effect_result_t bef_effect_available_features(char (*features)[BEF_EFFECT_FEATURE_LEN], int* len);
  59. /**
  60. * @brief Set camera toward
  61. * @param handle Effect handle that initialized
  62. * @param position Camera positin
  63. * @return if succeed return IES_RESULT_SUC, other value please see bef_effect_base_define.h
  64. */
  65. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_camera_device_position(bef_effect_handle_t handle, bef_ai_camera_position position);
  66. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_device_rotation(bef_effect_handle_t handle, float* quaternion);
  67. /**
  68. * @brief Set frame size.
  69. * @param handle Effect handle
  70. * @param width Texture width
  71. * @param height Texture height
  72. * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  73. */
  74. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_width_height(bef_effect_handle_t handle, int width, int height);
  75. /**
  76. * @brief Set camera orientation, which is used for detection.
  77. * @param handle Effect handle that initialized
  78. * @param orientation Camera clock wise
  79. * @return if succeed return IES_RESULT_SUC, other value please see bef_effect_base_define.h
  80. */
  81. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_orientation(bef_effect_handle_t handle, bef_ai_rotate_type orientation);
  82. /**
  83. * @brief Setup beauty-face-filter with a specified string.
  84. * @param handle Effect handle
  85. * @param strBeautyName The name of beauty will apply
  86. * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  87. */
  88. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_beauty(bef_effect_handle_t handle, const char *strBeautyName);
  89. /**
  90. * @brief Setup beauty-face-filter with a specified string.
  91. * @param handle Effect handle
  92. * @param strMakeupName The path of makeup resource will apply
  93. * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_define.h
  94. */
  95. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_buildin_makeup(bef_effect_handle_t handle, const char* strMakeupName);
  96. /**
  97. * @brief Setup reshape-face-filter with a specified string.
  98. * @param handle Effect handle
  99. * @param strPath The absolute path of effect package.
  100. * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  101. */
  102. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_reshape_face(bef_effect_handle_t handle, const char *strPath);
  103. /**
  104. * @brief Update reshape-face-filter parameters
  105. * @param handle Effect handle
  106. * @param fIntensity Filter intensity, range in [0.0, 1.0]
  107. * @return if succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  108. */
  109. BEF_SDK_API bef_effect_result_t bef_effect_ai_update_reshape_face(bef_effect_handle_t handle, const float fIntensity);
  110. /**
  111. * @brief Update reshape-face-filter parameters
  112. * @param handle Effect handle
  113. * @param eyeIntensity eye intensity, range in [0.0, 1.0]
  114. * @param cheekIntensity cheek intensity, range in [0.0, 1.0]
  115. * @return if succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  116. */
  117. BEF_SDK_API bef_effect_result_t bef_effect_ai_update_reshape_face_intensity(bef_effect_handle_t handle, const float eyeIntensity, const float cheekIntensity);
  118. /**
  119. @param handle effect handle
  120. @param leftFilterPath current filter path
  121. @param rightFilterPath next filter path
  122. @parm direction the direction that the next filter will appear
  123. @param position the borderline of left-filter and right-filter in x-axis.
  124. @return if succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  125. */
  126. BEF_SDK_API bef_effect_result_t bef_effect_ai_switch_color_filter_v2(bef_effect_handle_t handle, const char *leftFilterPath, const char *rightFilterPath, float position);
  127. /**
  128. * Set color filter with a specified string.
  129. * @param handle Effect handle
  130. * @param strPath The absolute path of effect package.
  131. * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  132. */
  133. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_color_filter_v2(bef_effect_handle_t handle, const char *strPath);
  134. /**
  135. * @brief Set effect with a specified string.
  136. * @param handle Effect handle
  137. * @param strPath The absolute path of effect package.
  138. * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_define.h
  139. */
  140. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_effect(bef_effect_handle_t handle, const char *strPath);
  141. /**
  142. * @brief set composer resource path,
  143. * 设置composer资源包路径,使composer资源包生效
  144. * @param handle Effect Handle
  145. * @param strPath composer file path
  146. * @Deprecated
  147. */
  148. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_composer(bef_effect_handle_t handle, const char *strPath);
  149. /**
  150. * @brief set composer effect path array
  151. * 设置资源包路径数组,通过更新数组设置特效的组合
  152. * @param nodePaths 特效资源路径的数组
  153. * @param nodeNum 特效资源路径的数组长度
  154. *
  155. */
  156. BEF_SDK_API bef_effect_result_t bef_effect_ai_composer_set_nodes(bef_effect_handle_t handle, const char *nodePaths[], int nodeNum);
  157. /// 设置资源包路径数组,可通过额外的 ndoeTags 设置附加信息
  158. /// @param handle 创建的 handle
  159. /// @param nodePaths 特效资源路径数组
  160. /// @param nodeTags 特效资源附加信息,与nodePaths 一一对应
  161. /// @param nodeNum 特效资源数组的长度
  162. BEF_SDK_API bef_effect_result_t bef_effect_ai_composer_set_nodes_with_tags(bef_effect_handle_t handle, const char *nodePaths[], const char *nodeTags[], int nodeNum);
  163. /**
  164. * @brief append composer effect path array
  165. * 追加资源包路径数组,通过追加数组设置特效的组合
  166. * @param nodePaths 特效资源路径的数组
  167. * @param nodeNum 特效资源路径的数组长度
  168. *
  169. */
  170. BEF_SDK_API bef_effect_result_t bef_effect_ai_composer_append_nodes(bef_effect_handle_t handle, const char *nodePaths[], int nodeNum);
  171. /**
  172. * @brief append composer effect path array
  173. * 追加资源包路径数组,通过追加数组设置特效的组合
  174. * @param nodePaths 特效资源路径的数组
  175. * @param nodeTags 特效资源附加信息,与nodePaths 一一对应
  176. * @param nodeNum 特效资源路径的数组长度
  177. *
  178. */
  179. BEF_SDK_API bef_effect_result_t bef_effect_ai_composer_append_nodes_with_tags(bef_effect_handle_t handle, const char *nodePaths[], const char *nodeTags[], int nodeNum);
  180. /**
  181. * @brief remove composer effect path array
  182. * 删除资源包路径数组,通过删除数组设置特效的组合
  183. * @param nodePaths 特效资源路径的数组
  184. * @param nodeNum 特效资源路径的数组长度
  185. *
  186. */
  187. BEF_SDK_API bef_effect_result_t bef_effect_ai_composer_remove_nodes(bef_effect_handle_t handle, const char *nodePaths[], int nodeNum);
  188. /**
  189. * @brief set composer node intensity
  190. * 设置组合特效的单个节点的强度
  191. * @param handle Effect Handle
  192. * @param key 特效资源的路径
  193. * @param value 特效的强度
  194. */
  195. BEF_SDK_API bef_effect_result_t bef_effect_ai_composer_update_node(bef_effect_handle_t handle, const char *nodePath,const char *nodeTag, float value);
  196. /**
  197. * @brief 设置Composer模式
  198. * @param handle Effect handle
  199. * @param mode 0: A槽区+B槽区模式(Composer Feature), 1: A槽区+B槽区+C槽区模式(Composer下沉)
  200. * @param orderType 0: 按照zorder排序, 目前只支持0
  201. * @return 成功返回BEF_EFFECT_RESULT_SUC, 其它值参考bef_effect_define.h
  202. * @Deprecated
  203. */
  204. BEF_SDK_API bef_effect_result_t bef_effect_ai_composer_set_mode(bef_effect_handle_t handle, int mode, int orderType);
  205. /**
  206. * @param handle Effect handle
  207. * @param textureid_src texture source
  208. * @return if succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  209. */
  210. BEF_SDK_API bef_effect_result_t bef_effect_ai_algorithm_texture(bef_effect_handle_t handle, unsigned int textureid_src, double timeStamp);
  211. /**
  212. * @param handle Effect handle
  213. * @param texture texture source
  214. * @param buffer buffer address
  215. * @param buffer_format format of buffer, see bef_ai_pixel_format
  216. * @param buffer_width with of buffer
  217. * @param buffer_height height of buffer
  218. * @param buffer_stride stride of buffer
  219. * @param timeStamp current time, unit second
  220. * @return if succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  221. */
  222. BEF_SDK_API bef_effect_result_t bef_effect_ai_algorithm_texture_with_buffer(bef_effect_handle_t handle,
  223. unsigned int texture,
  224. const unsigned char *buffer,
  225. bef_ai_pixel_format buffer_format,
  226. int buffer_width,
  227. int buffer_height,
  228. int buffer_stride,
  229. double timeStamp);
  230. /**
  231. * @param [in] handle Created effect handle
  232. * 初始化的特效句柄,需要再OpenGL环境中使用
  233. * @param [in] img_in 数据buffer
  234. * @param [in] fmt_in 数据buffer的格式,支持RGBA,BGRA(ios支持),NV21,NV12,YUV420P
  235. * @param [in] image_width 数据buffer图像的宽度
  236. * @param [in] image_height 数据buffer图像的长度
  237. * @param [in] image_stride 数据buffer的步长(一行的占用的字节数)
  238. * @param [in] timestamp 时间戳
  239. * @return If succeed return BEF_RESULT_SUC, other value please refer bef_effect_ai_public_define.h
  240. * 成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  241. */
  242. BEF_SDK_API bef_effect_result_t
  243. bef_effect_ai_algorithm_buffer(
  244. bef_effect_handle_t handle,
  245. const unsigned char *img_in,
  246. bef_ai_pixel_format fmt_in,
  247. int image_width,
  248. int image_height,
  249. int image_stride,
  250. double timestamp
  251. );
  252. /**
  253. * @breif Draw srcTexture with effects to dstTexture.
  254. * @param handle Effect handle
  255. * @param srcTexture source texture
  256. * @param dstTexture distination texture
  257. * @return if succeed return IES_RESULT_SUC, other value please see bef_effect_base_define.h
  258. */
  259. BEF_SDK_API bef_effect_result_t bef_effect_ai_process_texture(bef_effect_handle_t handle, unsigned int srcTexture, unsigned int dstTexture, double timeStamp);
  260. /**
  261. * @breif Draw source buffer with effects to destination buffer.
  262. * 绘制特效
  263. * @param [in] handle Created effect handle
  264. * 初始化的特效句柄
  265. * @param [in] img_in 输入图片buffer
  266. * @param [in] fmt_in 输入图片buffer的格式,支持RGBA,BGRA(ios支持),NV12,NV21,YUV420P
  267. * @param [in] image_width 输入图片buffer的宽度
  268. * @param [in] image_height 输入图片buffer的高度
  269. * @param [in] image_stride 输入图片buffer的步长(一行字节数)
  270. * @param [in] img_out 输出图片数据
  271. * @param [in] fmt_out 输出图片数据格式,支持RGBA,NV12,NV21,YUV420P
  272. * @param [in] timestamp Current timestamp
  273. * 时间戳
  274. * @return If succeed return BEF_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  275. * 成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  276. */
  277. #if BEF_EFFECT_ANDROID_WITH_JNI
  278. BEF_SDK_API bef_effect_result_t
  279. bef_effect_ai_process_buffer(bef_effect_handle_t handle,
  280. const unsigned char *img_in,
  281. bef_ai_pixel_format fmt_in,
  282. int image_width,
  283. int image_height,
  284. int image_stride,
  285. unsigned char *img_out,
  286. bef_ai_pixel_format fmt_out,
  287. double timestamp
  288. );
  289. #else
  290. BEF_SDK_API bef_effect_result_t
  291. bef_effect_ai_process_buffer(bef_effect_handle_t handle,
  292. const unsigned char *img_in,
  293. bef_ai_pixel_format fmt_in,
  294. int image_width,
  295. int image_height,
  296. int image_stride,
  297. unsigned char *img_out,
  298. bef_ai_camera_position is_front,
  299. double timestamp,
  300. int process_times,
  301. bef_ai_process_type previewMode,
  302. bef_ai_rotate_type orientation,
  303. int dstTexture
  304. );
  305. BEF_SDK_API bef_effect_result_t
  306. bef_effect_ai_process_buffer_with_face_info(bef_effect_handle_t handle,
  307. const unsigned char *img_in,
  308. bef_ai_pixel_format fmt_in,
  309. int image_width,
  310. int image_height,
  311. unsigned char *img_out,
  312. bef_ai_camera_position is_front,
  313. double timestamp,
  314. int process_times,
  315. bef_ai_process_type previewMode,
  316. bef_ai_rotate_type orientation,
  317. int dstTexture,
  318. bef_ai_face_info *faceInfo
  319. );
  320. #endif
  321. /**
  322. * @param handle Effect handle that will be created
  323. * @param fIntensity Filter smooth intensity, range in [0.0, 1.0]
  324. * if fIntensity is 0 , this filter would not work.
  325. * @return if succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  326. */
  327. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_intensity(bef_effect_handle_t handle, bef_intensity_type intensityType, float fIntensity);
  328. /**
  329. * @brief 开启或关闭并行框架,开启后算法在独立线程完成检测。默认不开启
  330. * @param handle effect handle
  331. * @param usePipeline 控制参数
  332. */
  333. BEF_SDK_API bef_effect_result_t bef_effect_ai_use_pipeline_processor(bef_effect_handle_t handle, bool usePipeline);
  334. /**
  335. * @brief 清理并行框架残余算法任务,在切后台、切换分辨率或切相机时使用。总之画面会不连续出现的时候都应该调用
  336. * @param handle Effect handle
  337. */
  338. BEF_SDK_API bef_effect_result_t bef_effect_ai_clean_pipeline_processor_task(bef_effect_handle_t handle);
  339. /**
  340. * @brief 开启并行框架3buffer策略,避免 buffer 的拷贝
  341. * @param handle effect handle
  342. * @param use3Buffer 是否开启3buffer
  343. */
  344. BEF_SDK_API bef_effect_result_t bef_effect_ai_use_3buffer(bef_effect_handle_t handle, bool use3buffer);
  345. /**
  346. * @brief 获取人脸检测结果
  347. * @param handle 已创建的授权
  348. * @param result 人脸检测结果
  349. * @return If succeed return BEF_RESULT_SUC, other value please refer bef_effect_ai_public_define.h
  350. * 成功返回 BEF_RESULT_SUC, 授权码非法返回BEF_RESULT_INVALID_LICENSE,其它失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  351. */
  352. BEF_SDK_API bef_effect_result_t bef_effect_ai_get_face_detect_result(bef_effect_handle_t handle, bef_ai_face_info* result);
  353. /**
  354. * @brief 获取人脸检测mask结果
  355. * @param handle 已创建的授权
  356. * @param mask_type mask类型枚举值, bef_face_mask_type
  357. * @param result 人脸检测mask结果,根据类型输入
  358. * @return If succeed return BEF_RESULT_SUC, other value please refer bef_effect_ai_public_define.h
  359. * 成功返回 BEF_RESULT_SUC, 授权码非法返回BEF_RESULT_INVALID_LICENSE,其它失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  360. */
  361. BEF_SDK_API bef_effect_result_t bef_effect_ai_get_face_seg_result(bef_effect_handle_t handle, int mask_type, void* result);
  362. /**
  363. * @brief 获取手的检测结果
  364. * @param handle 已创建的授权
  365. * @param result 手检测结果
  366. * @return If succeed return BEF_RESULT_SUC, other value please refer bef_effect_ai_public_define.h
  367. * 成功返回 BEF_RESULT_SUC, 授权码非法返回BEF_RESULT_INVALID_LICENSE,其它失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  368. */
  369. BEF_SDK_API bef_effect_result_t bef_effect_ai_get_hand_detect_result(bef_effect_handle_t handle, bef_ai_hand_info *result);
  370. /**
  371. * @brief 获取人体检测结果
  372. * @param handle 已创建的授权
  373. * @param result 人体检测结果
  374. * @return If succeed return BEF_RESULT_SUC, other value please refer bef_effect_ai_public_define.h
  375. * 成功返回 BEF_RESULT_SUC, 授权码非法返回BEF_RESULT_INVALID_LICENSE,其它失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  376. */
  377. BEF_SDK_API bef_effect_result_t bef_effect_ai_get_skeleton_detect_result(bef_effect_handle_t handle, bef_ai_skeleton_result *result);
  378. /**
  379. * @brief 获取人脸属性检测结果
  380. * @param handle 已创建的授权
  381. * @param result 人脸属性检测结果
  382. * @return If succeed return BEF_RESULT_SUC, other value please refer bef_effect_ai_public_define.h
  383. * 成功返回 BEF_RESULT_SUC, 授权码非法返回BEF_RESULT_INVALID_LICENSE,其它失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  384. */
  385. BEF_SDK_API bef_effect_result_t bef_effect_ai_get_face_attr_detect_result(bef_effect_handle_t handle, bef_ai_face_attribute_result *result);
  386. /**
  387. * @brief 给贴纸发送消息
  388. * @param handle 已创建的授权
  389. * @param msgID 消息id
  390. * @return If succeed return BEF_RESULT_SUC, other value please refer bef_effect_ai_public_define.h
  391. * 成功返回 BEF_RESULT_SUC, 授权码非法返回BEF_RESULT_INVALID_LICENSE,其它失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  392. */
  393. BEF_SDK_API bef_effect_result_t bef_effect_ai_send_msg(bef_effect_handle_t handle, unsigned int msgID, long arg1, long arg2, const char *arg3);
  394. /**
  395. * @brief 给贴纸发送开拍重置信息,这个函数目前仅用在使用creator
  396. * 设计的贴纸,并且确认勾选了开拍重置选项
  397. * @param handle 已创建的授权
  398. * @return If succeed return BEF_RESULT_SUC, other value please refer bef_effect_ai_public_define.h
  399. * 成功返回 BEF_RESULT_SUC, 授权码非法返回BEF_RESULT_INVALID_LICENSE,其它失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  400. */
  401. BEF_SDK_API bef_effect_result_t bef_effect_ai_reset_sticker(bef_effect_handle_t handle);
  402. /// @brief 处理触摸事件
  403. /// @param handle 已创建的句柄
  404. /// @param event 触摸事件类型
  405. /// @param x 触摸位置
  406. /// @param y 触摸位置
  407. /// @param force 压力值
  408. /// @param majorRadius 触摸范围
  409. /// @param pointerId 触摸点id
  410. /// @param pointerCount 触摸点数量
  411. BEF_SDK_API bef_effect_result_t bef_effect_ai_process_touch(bef_effect_handle_t handle, bef_ai_touch_event_code event, float x, float y, float force, float majorRadius, int pointerId, int pointerCount);
  412. /// @brief 处理手势事件
  413. /// @param handle 已创建的句柄
  414. /// @param gesture 手势类型
  415. /// @param x 触摸位置,缩放手势表示缩放比例,旋转手势表示旋转角度
  416. /// @param y 触摸位置
  417. /// @param dx 移动距离
  418. /// @param dy 移动距离
  419. /// @param factor 缩放因数
  420. BEF_SDK_API bef_effect_result_t bef_effect_ai_process_gesture(bef_effect_handle_t handle, bef_ai_gesture_event_code gesture, float x, float y, float dx, float dy, float factor);
  421. /// @brief 通过 buffer 设置 render cache texture
  422. /// @details 传入一个固定名字的纹理给到 SDK,传入一个 buffer,SDK 会将其解析成纹理
  423. /// @param handle 句柄
  424. /// @param key 纹理名称
  425. /// @param image 图像数据
  426. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_render_cache_texture_with_buffer(bef_effect_handle_t handle, const char* key, bef_ai_image* image);
  427. /// @brief 通过文件设置 render cache texture
  428. /// @details 传入一个固定名字的纹理给到 SDK,传入一个文件路径,SDK 会将其解析成纹理
  429. /// @param handle 句柄
  430. /// @param key 纹理名称
  431. /// @param path 文件绝对路径
  432. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_render_cache_texture(bef_effect_handle_t handle, const char* key, const char* path);
  433. /// @brief 设置 gles 版本
  434. /// @details 需要在初始化之前调用才有效果
  435. /// @param handle 句柄
  436. /// @param api gles 版本,参见 bef_ai_render_api_type
  437. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_render_api(bef_effect_handle_t handle, bef_ai_render_api_type api);
  438. /// @brief 是否使用内置传感器
  439. /// @param handle 句柄
  440. /// @param useBuiltinSensor 是否使用内置传感器
  441. BEF_SDK_API bef_effect_result_t bef_effect_ai_use_builtin_sensor(bef_effect_handle_t handle, bool useBuiltinSensor);
  442. /// @brief 在一定时间内加载素材
  443. /// @param handle 句柄
  444. /// @param timeout 等待时间,单位 us,-1 时表示一直等待直到素材加载完成
  445. BEF_SDK_API bef_effect_result_t bef_effect_ai_load_resource_with_timeout(bef_effect_handle_t handle, int timeout);
  446. /// @brief 通过key获取一张截图
  447. /// @param handle Effect实例
  448. /// @param key 要获取截图对应的key值
  449. /// @param image 指向由effect分配的截图,如果当前无截图返回nullptr
  450. /// @return 成功则返回BEF_RESULT_SUC
  451. BEF_SDK_API bef_effect_result_t bef_effect_ai_get_captured_image_with_key(bef_effect_handle_t handle, const char* key, bef_ai_image** image);
  452. /// @brief 释放截图
  453. /// @param handle Effect实例
  454. /// @param image 指向通过bef_effect_get_captured_image_with_key获取的截图
  455. /// @return
  456. BEF_SDK_API void bef_effect_ai_release_captured_image(bef_effect_handle_t handle, bef_ai_image* image);
  457. #ifdef __ANDROID__
  458. /**
  459. * @param handle Created effect detect handle
  460. * 已创建的句柄
  461. * @param result Current face detect result struct
  462. *
  463. */
  464. #if BEF_EFFECT_ANDROID_WITH_JNI
  465. BEF_SDK_API bef_effect_result_t
  466. bef_effect_ai_check_license(
  467. JNIEnv* env,
  468. jobject context,
  469. bef_effect_handle_t handle,
  470. const char *licensePath);
  471. BEF_SDK_API bef_effect_result_t
  472. bef_effect_ai_check_license_buffer(
  473. JNIEnv* env,
  474. jobject context,
  475. bef_effect_handle_t handle,
  476. const char *buffer,
  477. unsigned long buffer_len
  478. );
  479. BEF_SDK_API AAssetManager* bef_effect_ai_assetmgr_from_context(
  480. JNIEnv *env,
  481. jobject context
  482. );
  483. #else
  484. BEF_SDK_API bef_effect_result_t
  485. bef_effect_ai_check_license(
  486. bef_effect_handle_t handle,
  487. const char *licensePath
  488. );
  489. #endif
  490. #else
  491. BEF_SDK_API bef_effect_result_t
  492. bef_effect_ai_check_license(
  493. bef_effect_handle_t handle,
  494. const char *licensePath
  495. );
  496. BEF_SDK_API bef_effect_result_t
  497. bef_effect_ai_check_license_buffer(
  498. bef_effect_handle_t handle,
  499. const char *buffer,
  500. unsigned long buffer_len
  501. );
  502. #endif
  503. BEF_SDK_API bef_effect_result_t
  504. bef_effect_ai_check_online_license(bef_effect_handle_t handle, const char *licensePath);
  505. BEF_SDK_API bef_effect_result_t
  506. bef_effect_ai_check_license_function(bef_ai_license_function_type funcType, const char* licensePath, bool onlineLicense);
  507. BEF_SDK_API bef_effect_result_t
  508. bef_effect_ai_check_license_base(const char* licensePath, bool onlineLicense);
  509. /// @brief 开启或关闭强制人脸检测
  510. /// @param handle Effect实例
  511. /// @param force 开关值
  512. /// @return 成功则返回BEF_RESULT_SUC
  513. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_algorithm_force_detect(bef_effect_handle_t handle, bool force);
  514. /// @brief 设置模型缓存路径
  515. /// @param handle Effect实例
  516. /// @param path 路径
  517. /// @return 成功则返回BEF_RESULT_SUC
  518. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_cache_directory(bef_effect_handle_t handle, const char* path);
  519. /// @brief 设置Log回调
  520. /// @param callback 自定义Log回调
  521. /// @return 成功则返回BEF_RESULT_SUC
  522. BEF_SDK_API bef_effect_result_t bef_effect_ai_set_log_callback(bef_ai_log_callback callback);
  523. /// @brief 移除log回调
  524. /// @return 成功则返回BEF_RESULT_SUC
  525. BEF_SDK_API bef_effect_result_t bef_effect_ai_remove_log_callback();
  526. /// @brief 设置日志等级
  527. /// @param 日志等级
  528. /// @return
  529. BEF_SDK_API void bef_effect_ai_set_log_level(bef_ai_log_level logLevel);
  530. BEF_SDK_API bef_effect_result_t
  531. bef_effect_ai_set_face_int_param(bef_effect_handle_t handle, const char* param, int value);
  532. /// @brief 更新arcore对应的frame
  533. /// @param handle Effect实例
  534. /// @param frame arcore对应的session
  535. /// @return 成功则返回BEF_RESULT_SUC
  536. BEF_SDK_API bef_effect_result_t bef_effect_ai_ar_update_frame(bef_effect_handle_t handle, void* frame);
  537. #endif /* bef_effect_ai_h */