bef_effect_ai_hairparser.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #ifndef BEF_EFFECT_AI_HAIRPARSER_H
  2. #define BEF_EFFECT_AI_HAIRPARSER_H
  3. #include "bef_effect_ai_public_define.h"
  4. #if defined(__ANDROID__) || defined(TARGET_OS_ANDROID)
  5. #if BEF_EFFECT_ANDROID_WITH_JNI
  6. #include<jni.h>
  7. #endif
  8. #endif
  9. /**
  10. * @brief 创建句柄
  11. * @param [out] handle Created hairparser handle
  12. * 创建的骨骼句柄
  13. * @return If succeed return BEF_RESULT_SUC, other value please see bef_effect_ai_public_define.h
  14. * 成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  15. */
  16. BEF_SDK_API bef_effect_result_t
  17. bef_effect_ai_hairparser_create(
  18. bef_effect_handle_t *handle
  19. );
  20. /*
  21. * @brief 从文件初始化模型参数
  22. **/
  23. BEF_SDK_API bef_effect_result_t
  24. bef_effect_ai_hairparser_init_model(
  25. bef_effect_handle_t handle,
  26. const char* param_path);
  27. /*
  28. * @brief 设置SDK参数
  29. * net_input_width 和 net_input_height
  30. * 表示神经网络的传入,一般情况下不同模型不太一样
  31. * 此处(HairParser)传入值约定为 net_input_width = 192, net_input_height = 336
  32. * use_tracking: 算法时的参数,目前传入 true 即可
  33. * use_blur: 算法时的参数, 目前传入 true 即可
  34. **/
  35. BEF_SDK_API bef_effect_result_t
  36. bef_effect_ai_hairparser_set_param(
  37. bef_effect_handle_t handle,
  38. int net_input_width,
  39. int net_input_height,
  40. bool use_tracking,
  41. bool use_blur);
  42. /*
  43. * * @brief 获取输出mask shape
  44. * output_width, output_height, channel 用于得到 bef_effect_ai_hairparser_do_detect 接口输出的
  45. * alpha 大小 如果在 bef_effect_ai_hairparser_set_param 的参数中,net_input_width,net_input_height
  46. * 已按约定传入,即 net_input_width = 192, net_input_height = 336
  47. * channel 始终返回 1
  48. */
  49. BEF_SDK_API bef_effect_result_t
  50. bef_effect_ai_hairparser_get_output_shape(bef_effect_handle_t handle,
  51. int* output_width,
  52. int* output_height,
  53. int* channel);
  54. /*
  55. * @brief 进行抠图操作
  56. * @note 注意dst_alpha_data 空间需要外部分配
  57. * src_image_data 为传入图片的大小,图片大小任意
  58. * pixel_format, width, height, image_stride 为传入图片的信息
  59. **/
  60. BEF_SDK_API bef_effect_result_t
  61. bef_effect_ai_hairparser_do_detect(
  62. bef_effect_handle_t handle,
  63. const unsigned char* src_image_data,
  64. bef_ai_pixel_format pixel_format,
  65. int width,
  66. int height,
  67. int image_stride,
  68. bef_ai_rotate_type orient,
  69. unsigned char* dst_alpha_data,
  70. bool need_flip_alpha);
  71. /*
  72. * @brief 释放句柄
  73. **/
  74. BEF_SDK_API bef_effect_result_t
  75. bef_effect_ai_hairparser_destroy(bef_effect_handle_t handle);
  76. /**
  77. * @brief 头发分割授权
  78. * @param [in] handle Created hairparser handle
  79. * 已创建的骨骼检测句柄
  80. * @param [in] license 授权文件字符串
  81. * @param [in] length 授权文件字符串长度
  82. * @return If succeed return BEF_RESULT_SUC, other value please refer bef_effect_ai_public_define.h
  83. * 成功返回 BEF_RESULT_SUC, 授权码非法返回 BEF_RESULT_INVALID_LICENSE ,其它失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
  84. */
  85. #if defined(__ANDROID__) || defined(TARGET_OS_ANDROID)
  86. #if BEF_EFFECT_ANDROID_WITH_JNI
  87. BEF_SDK_API bef_effect_result_t bef_effect_ai_hairparser_check_license(JNIEnv* env, jobject context, bef_effect_handle_t handle, const char *licensePath);
  88. #else
  89. BEF_SDK_API bef_effect_result_t bef_effect_ai_hairparser_check_license(bef_effect_handle_t handle, const char *licensePath);
  90. #endif
  91. #else
  92. #ifdef __APPLE__
  93. BEF_SDK_API bef_effect_result_t bef_effect_ai_hairparser_check_license(bef_effect_handle_t handle, const char *licensePath);
  94. #endif
  95. #endif
  96. BEF_SDK_API bef_effect_result_t
  97. bef_effect_ai_hairparser_check_online_license(bef_effect_handle_t handle, const char *licensePath);
  98. #endif // BEF_EFFECT_AI_HAIRPARSER_H