bef_effect_ai_hal_api.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. #ifndef _BEF_EFFECT_AI_HAL_API_H_
  2. #define _BEF_EFFECT_AI_HAL_API_H_
  3. #include "bef_effect_ai_public_define.h"
  4. //#include "bef_effect_ai_face_detect.h"
  5. /**
  6. * @brief Initialize effect handle.
  7. * @param handle Effect handle
  8. * @param model_path model path
  9. * @param license_path license path
  10. * @param type process type
  11. * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  12. */
  13. BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_init(bef_effect_handle_t *handle,
  14. const char *model_path,
  15. const char *license_path,
  16. bef_ai_process_type type,
  17. int tmp,
  18. int times=2);
  19. /**
  20. * @param handle Effect handle that will destroy
  21. */
  22. BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_destory(bef_effect_handle_t handle);
  23. /**
  24. * process image
  25. * @param handle Effect handle
  26. * @param image imput image
  27. * @param out_image output image
  28. * @param format_in imput image format
  29. * @param width image width
  30. * @param height imput height
  31. * @param run_times render times
  32. * @param orientation image orientation
  33. * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  34. */
  35. BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_process(bef_effect_handle_t handle,
  36. unsigned char* image,
  37. unsigned char* out_image,
  38. bef_ai_pixel_format format_in,
  39. bef_ai_camera_position is_front,
  40. int width,
  41. int height,
  42. bef_ai_rotate_type orientation);
  43. /**
  44. * process image
  45. * @param handle Effect handle
  46. * @param image imput image
  47. * @param out_image output image
  48. * @param format_in imput image format
  49. * @param width image width
  50. * @param height imput height
  51. * @param orientation image orientation
  52. * @param faceInfo input face detect result
  53. * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  54. */
  55. // BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_process_buffer_with_face_info(bef_effect_handle_t handle,
  56. // unsigned char* in_image,
  57. // unsigned char* out_image,
  58. // bef_ai_pixel_format format_in,
  59. // bef_ai_camera_position is_front,
  60. // int width,
  61. // int height,
  62. // bef_ai_rotate_type orientation,
  63. // bef_ai_face_info *faceInfo,
  64. // unsigned char* filePath=nullptr);
  65. /**
  66. * process image
  67. * @param handle Effect handle
  68. * @param faceInfo output face detect result
  69. * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  70. */
  71. // BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_get_face_detect_result(bef_effect_handle_t handle, bef_ai_face_info *faceInfo);
  72. /**
  73. * Set color filter with a specified string.
  74. * @param handle Effect handle
  75. * @param filter_path The absolute path of effect package.
  76. * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  77. */
  78. BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_set_color_filter_v2(bef_effect_handle_t handle, const char* filter_path);
  79. /**
  80. * @param handle Effect handle that will be created
  81. * @param fIntensity Filter smooth intensity, range in [0.0, 1.0]
  82. * if fIntensity is 0 , this filter would not work.
  83. * @return if succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  84. */
  85. BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_set_intensity(bef_effect_handle_t handle, int intensityType, float fIntensity);
  86. /**
  87. * @brief Set effect with a specified string.
  88. * @param handle Effect handle
  89. * @param stickerPath The absolute path of effect package.
  90. * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_define.h
  91. */
  92. BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_set_effect(bef_effect_handle_t handle, const char* stickerPath);
  93. /**
  94. * @brief append composer effect path array
  95. * 追加资源包路径数组,通过追加数组设置特效的组合
  96. * @param nodePaths 特效资源路径的数组
  97. * @param nodeNum 特效资源路径的数组长度
  98. */
  99. BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_composer_append_nodes(bef_effect_handle_t handle,
  100. const char *nodePaths[],
  101. int nodeNum);
  102. /**
  103. * @brief remove composer effect path array
  104. * 删除资源包路径数组,通过删除数组设置特效的组合
  105. * @param nodePaths 特效资源路径的数组
  106. * @param nodeNum 特效资源路径的数组长度
  107. */
  108. BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_composer_remove_nodes(bef_effect_handle_t handle,
  109. const char *nodePaths[],
  110. int nodeNum);
  111. /**
  112. * @brief set composer effect path array
  113. * 设置资源包路径数组,通过更新数组设置特效的组合
  114. * @param nodePaths 特效资源路径的数组
  115. * @param nodeNum 特效资源路径的数组长度
  116. *
  117. */
  118. BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_composer_set_nodes(bef_effect_handle_t handle,
  119. const char *nodePaths[],
  120. int nodeNum);
  121. /// 设置资源包路径数组,可通过额外的 ndoeTags 设置附加信息
  122. /// @param handle 创建的 handle
  123. /// @param nodePaths 特效资源路径数组
  124. /// @param nodeTags 特效资源附加信息,与nodePaths 一一对应
  125. /// @param nodeNum 特效资源数组的长度
  126. BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_composer_set_nodes_with_tags(bef_effect_handle_t handle,
  127. const char *nodePaths[],
  128. int nodeNum,
  129. const char *nodeTags[]=nullptr);
  130. /**
  131. * @brief 清理并行框架残余算法任务,在切后台、切换分辨率或切相机时使用。总之画面会不连续出现的时候都应该调用
  132. * @param handle Effect handle
  133. */
  134. BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_clean_pipeline_processor_task(bef_effect_handle_t handle);
  135. /**
  136. * @brief Set camera toward
  137. * @param handle Effect handle that initialized
  138. * @param position Camera positin
  139. * @return if succeed return IES_RESULT_SUC, other value please see bef_effect_base_define.h
  140. */
  141. BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_set_camera_device_position(bef_effect_handle_t handle,
  142. bef_ai_camera_position position);
  143. /**
  144. * @brief set composer node intensity
  145. * 设置组合特效的单个节点的强度
  146. * @param handle Effect Handle
  147. * @param key 特效资源的路径
  148. * @param value 特效的强度
  149. */
  150. BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_composer_update_node(bef_effect_handle_t handle,
  151. const char *nodePath,
  152. const char *nodeTag,
  153. float value,
  154. bool update_times=false);
  155. /// @brief 处理触摸事件
  156. /// @param handle 已创建的句柄
  157. /// @param event 触摸事件类型
  158. /// @param x 触摸位置
  159. /// @param y 触摸位置
  160. /// @param force 压力值
  161. /// @param majorRadius 触摸范围
  162. /// @param pointerId 触摸点id
  163. /// @param pointerCount 触摸点数量
  164. BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_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);
  165. /// @brief 处理手势事件
  166. /// @param handle 已创建的句柄
  167. /// @param gesture 手势类型
  168. /// @param x 触摸位置,缩放手势表示缩放比例,旋转手势表示旋转角度
  169. /// @param y 触摸位置
  170. /// @param dx 移动距离
  171. /// @param dy 移动距离
  172. /// @param factor 缩放因数
  173. BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_process_gesture(bef_effect_handle_t handle, bef_ai_gesture_event_code gesture, float x, float y, float dx, float dy, float factor);
  174. /// @brief 处理虚拟背景事件
  175. /// @param handle 已创建的句柄
  176. /// @param key key参数
  177. /// @param image 图像参数
  178. BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_set_render_cache_texture_with_buffer(bef_effect_handle_t handle, const char* key, bef_ai_image* image);
  179. /// @brief 处理虚拟背景事件
  180. /// @param handle 已创建的句柄
  181. /// @param key key参数
  182. /// @param image 背景路径
  183. BEF_SDK_API bef_effect_result_t bef_effect_ai_hal_set_render_cache_texture(bef_effect_handle_t handle, const char* key, const char* image_path);
  184. #endif