bef_effect_ai_gaze_estimation.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef BEF_EFFECT_AI_GAZE_ESTIMATION_H
  2. #define BEF_EFFECT_AI_GAZE_ESTIMATION_H
  3. #if defined(__ANDROID__) || defined(TARGET_OS_ANDROID)
  4. #include <jni.h>
  5. #endif
  6. #include "bef_effect_ai_public_define.h"
  7. #include "bef_effect_ai_face_detect.h"
  8. typedef unsigned long long bef_ai_gaze_handle;
  9. typedef struct bef_ai_gaze_info_base
  10. {
  11. unsigned long face_id;
  12. bool valid;
  13. float head_r[3], head_t[3];
  14. float leye_pos[3], reye_pos[3];
  15. float leye_gaze[3], reye_gaze[3], mid_gaze[3];
  16. float leye_pos2d[2], reye_pos2d[2];
  17. float leye_gaze2d[2], reye_gaze2d[2]; // 2d point on screen of gaze end point
  18. } bef_ai_gaze_info_base;
  19. /**
  20. * @brief 模型参数类型
  21. * BEF_GAZE_ESTIMATION_CAMERA_FOV : 相机Field of View,默认60度
  22. * BEF_GAZE_ESTIMATION_DIVERGENCE : 双眼视线发散度,设置范围 [-inf, inf],默认0
  23. * 0表示双眼3D视线汇聚一点,由于空间近大远小的关系,此时投影至2D空间中时视线是平行的
  24. * 1表示双眼3D视线平行,此时投影至2D空间中时视线是发散的。
  25. */
  26. typedef enum
  27. {
  28. BEF_GAZE_ESTIMATION_EDGE_MODE = 1,
  29. BEF_GAZE_ESTIMATION_CAMERA_FOV,
  30. BEF_GAZE_ESTIMATION_DIVERGENCE,
  31. } bef_ai_gaze_estimation_param_type;
  32. /**
  33. * @brief 模型枚举,有些模块可能有多个模型
  34. *
  35. */
  36. typedef enum
  37. {
  38. BEF_GAZE_ESTIMATION_MODEL1 = 1,
  39. } bef_gaze_estimation_model_type;
  40. /**
  41. * @brief 预测接口的返回值
  42. */
  43. typedef struct
  44. {
  45. bef_ai_gaze_info_base* eye_infos; // eye information, includes eye positions, gaze
  46. int face_count;
  47. } bef_ai_gaze_estimation_info;
  48. BEF_SDK_API bef_effect_result_t
  49. bef_effect_ai_gaze_estimation_create_handle(bef_ai_gaze_handle* handle);
  50. BEF_SDK_API bef_effect_result_t
  51. bef_effect_ai_gaze_estimation_init_model(bef_ai_gaze_handle handle,
  52. bef_gaze_estimation_model_type modelType,
  53. const char* modelPath);
  54. BEF_SDK_API bef_effect_result_t
  55. bef_effect_ai_gaze_estimation_set_paramf(bef_ai_gaze_handle handle,
  56. bef_ai_gaze_estimation_param_type type,
  57. float value);
  58. /**
  59. * @brief 封装预测接口的输入数据
  60. * bef_ai_face_info *faceInfo : 人脸检测结果
  61. * float LineLen : 视线长度,0为无限长
  62. */
  63. BEF_SDK_API bef_effect_result_t
  64. bef_effect_ai_gaze_estimation_detect(bef_ai_gaze_handle 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. const bef_ai_face_info* faceInfo,
  72. float lineLen,
  73. bef_ai_gaze_estimation_info* gaze_info);
  74. BEF_SDK_API bef_effect_result_t
  75. bef_effect_ai_gaze_estimation_destroy(bef_ai_gaze_handle handle);
  76. BEF_SDK_API bef_effect_result_t bef_effect_ai_gaze_estimation_check_license(bef_ai_gaze_handle handle, const char* licensePath);
  77. BEF_SDK_API bef_effect_result_t
  78. bef_effect_ai_gaze_estimation_check_online_license(bef_ai_gaze_handle handle, const char* licensePath);
  79. #endif //BEF_EFFECT_AI_GAZE_ESTIMATION_H