pixelFree_c.hpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. //
  2. // pixelFree_c.hpp
  3. // PixelFree
  4. //
  5. // Created by mumu on 2021/9/22.
  6. //
  7. #ifndef pixelFree_c_hpp
  8. #define pixelFree_c_hpp
  9. #include <stdio.h>
  10. #if defined(_WIN32)
  11. #ifdef PF_BUILD_SHARED_LIB
  12. #define PF_CAPI_EXPORT __declspec(dllexport)
  13. #else
  14. #define PF_CAPI_EXPORT
  15. #endif
  16. #else
  17. #define PF_CAPI_EXPORT __attribute__((visibility("default")))
  18. #endif // _WIN32
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. typedef enum PFDetectFormat{
  23. PFFORMAT_UNKNOWN = 0,
  24. PFFORMAT_IMAGE_RGB = 1,
  25. PFFORMAT_IMAGE_BGR = 2,
  26. PFFORMAT_IMAGE_RGBA = 3,
  27. PFFORMAT_IMAGE_BGRA = 4,
  28. PFFORMAT_IMAGE_ARGB = 5,
  29. PFFORMAT_IMAGE_ABGR = 6,
  30. PFFORMAT_IMAGE_GRAY = 7,
  31. PFFORMAT_IMAGE_YUV_NV12 = 8,
  32. PFFORMAT_IMAGE_YUV_NV21 = 9,
  33. PFFORMAT_IMAGE_YUV_I420 = 10,
  34. PFFORMAT_IMAGE_TEXTURE = 11,
  35. } PFDetectFormat;
  36. typedef enum PFRotationMode{
  37. PFRotationMode0 = 0,
  38. PFRotationMode90 = 1,
  39. PFRotationMode180 = 2,
  40. PFRotationMode270 = 3,
  41. } PFRotationMode;
  42. typedef enum PFSrcType{
  43. PFSrcTypeFilter = 0,
  44. PFSrcTypeAuthFile = 2,
  45. PFSrcTypeStickerFile = 3,
  46. } PFSrcType;
  47. typedef struct {
  48. const char* modelPath;
  49. const char* runCachePath;
  50. } PFDetectPath;
  51. typedef struct {
  52. int textureID;
  53. int wigth;
  54. int height;
  55. void* p_data0;// Y or rgba
  56. void* p_data1;
  57. void* p_data2;
  58. int stride_0;
  59. int stride_1;
  60. int stride_2;
  61. PFDetectFormat format;
  62. PFRotationMode rotationMode;
  63. } PFIamgeInput;
  64. typedef struct {
  65. char *imagePath;
  66. } PFFiter;
  67. typedef struct {
  68. bool isOpenLvmu;//false
  69. bool isVideo;//false
  70. const char *bgSrcPath;
  71. } PFFiterLvmuSetting;
  72. typedef struct {
  73. bool isUse; //false
  74. char *path; //
  75. float positionX;// 0-1.0
  76. float positionY;// 0-1.0
  77. float w; // 0-1.0
  78. float h;// 0-1.0
  79. bool isMirror; // false
  80. } PFFiterWatermark;
  81. /* 美颜类型 */
  82. typedef enum PFBeautyFiterType{
  83. PFBeautyFiterTypeFace_EyeStrength = 0,
  84. //瘦脸
  85. PFBeautyFiterTypeFace_thinning,
  86. //窄脸
  87. PFBeautyFiterTypeFace_narrow,
  88. //下巴
  89. PFBeautyFiterTypeFace_chin,
  90. //v脸
  91. PFBeautyFiterTypeFace_V,
  92. //small
  93. PFBeautyFiterTypeFace_small,
  94. //鼻子
  95. PFBeautyFiterTypeFace_nose,
  96. //额头
  97. PFBeautyFiterTypeFace_forehead,
  98. //嘴巴
  99. PFBeautyFiterTypeFace_mouth,
  100. //人中
  101. PFBeautyFiterTypeFace_philtrum,
  102. //长鼻
  103. PFBeautyFiterTypeFace_long_nose = 10,
  104. //眼距
  105. PFBeautyFiterTypeFace_eye_space,
  106. //微笑嘴角
  107. PFBeautyFiterTypeFace_smile,
  108. //旋转眼睛
  109. PFBeautyFiterTypeFace_eye_rotate,
  110. //开眼角
  111. PFBeautyFiterTypeFace_canthus,
  112. //磨皮
  113. PFBeautyFiterTypeFaceBlurStrength,
  114. //美白
  115. PFBeautyFiterTypeFaceWhitenStrength,
  116. //红润
  117. PFBeautyFiterTypeFaceRuddyStrength,
  118. //锐化
  119. PFBeautyFiterTypeFaceSharpenStrength,
  120. //新美白算法
  121. PFBeautyFiterTypeFaceM_newWhitenStrength,
  122. //画质增强
  123. PFBeautyFiterTypeFaceH_qualityStrength,
  124. //滤镜类型
  125. PFBeautyFiterName,
  126. //滤镜强度
  127. PFBeautyFiterStrength,
  128. //绿幕
  129. PFBeautyFiterLvmu,
  130. // 2D 贴纸
  131. PFBeautyFiterSticker2DFilter,
  132. // 一键美颜
  133. PFBeautyFiterTypeOneKey = 25,
  134. // 水印
  135. PFBeautyFiterWatermark,
  136. // 扩展字段
  137. PFBeautyFiterExtend,
  138. } PFBeautyFiterType;
  139. /* 一键美颜类型 */
  140. typedef enum PFBeautyTypeOneKey{
  141. // 关闭一键美颜
  142. PFBeautyTypeOneKeyNormal = 0,
  143. // 自然
  144. PFBeautyTypeOneKeyNatural,
  145. // 可爱
  146. PFBeautyTypeOneKeyCute,
  147. // 女神
  148. PFBeautyTypeOneKeyGoddess,
  149. // 白净
  150. PFBeautyTypeOneKeyFair,
  151. }PFBeautyTypeOneKey;
  152. PF_CAPI_EXPORT extern const char* PF_Version();
  153. typedef struct PFPixelFree PFPixelFree;
  154. PF_CAPI_EXPORT extern void PF_VLogSetLevel(PFPixelFree* pixelFree,int level,char *path);
  155. PF_CAPI_EXPORT extern PFPixelFree* PF_NewPixelFree();
  156. PF_CAPI_EXPORT extern void PF_DeletePixelFree(PFPixelFree* pixelFree);
  157. //目前仅支持双输入。GPU 纹理由于渲染,cpu buffer 用检测
  158. PF_CAPI_EXPORT extern int PF_processWithBuffer(PFPixelFree* pixelFree,PFIamgeInput inputImage);
  159. PF_CAPI_EXPORT extern void PF_pixelFreeSetBeautyFiterParam(PFPixelFree* pixelFree, int key,void *value);
  160. PF_CAPI_EXPORT extern void PF_createBeautyItemFormBundle(PFPixelFree* pixelFree, void *data,int size,PFSrcType type);
  161. PF_CAPI_EXPORT extern void PF_pixelFreeGetFaceRect(PFPixelFree* pixelFree,float *faceRect);
  162. PF_CAPI_EXPORT extern int PF_pixelFreeHaveFaceSize(PFPixelFree* pixelFree);
  163. #ifdef __cplusplus
  164. }
  165. #endif
  166. #endif /* pixelFree_c_hpp */