pixelFree_c.hpp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. typedef struct {
  82. bool isUse; //false
  83. float brightness;// -1.0 to 1.0
  84. float contrast; // Contrast ranges from 0.0 to 4.0 (max contrast), with 1.0 as the normal level
  85. float exposure; // Exposure ranges from -10.0 to 10.0, with 0.0 as the normal level
  86. float highlights; //0 - 1, increase to lighten shadows.
  87. float shadows; //0 - 1, decrease to darken highlights.
  88. float saturation; //Saturation ranges from 0.0 (fully desaturated) to 2.0 (max saturation), with 1.0 as the normal level
  89. float temperature;//choose color temperature, in degrees Kelvin default 5000.0
  90. float tint; //adjust tint to compensate
  91. float hue; //0-360
  92. } PFImageColorGrading;
  93. typedef struct {
  94. float key_color[3]; // 0~1
  95. float hue;
  96. float saturation;// 0-1.0
  97. float brightness; // 0-1.0
  98. float similarity; //相似度
  99. } PFHLSFilterParams;
  100. /* 美颜类型 */
  101. typedef enum PFBeautyFiterType{
  102. PFBeautyFiterTypeFace_EyeStrength = 0,
  103. //瘦脸
  104. PFBeautyFiterTypeFace_thinning,
  105. //窄脸
  106. PFBeautyFiterTypeFace_narrow,
  107. //下巴
  108. PFBeautyFiterTypeFace_chin,
  109. //v脸
  110. PFBeautyFiterTypeFace_V,
  111. //small
  112. PFBeautyFiterTypeFace_small,
  113. //瘦鼻
  114. PFBeautyFiterTypeFace_nose,
  115. //额头
  116. PFBeautyFiterTypeFace_forehead,
  117. //嘴巴
  118. PFBeautyFiterTypeFace_mouth,
  119. //人中
  120. PFBeautyFiterTypeFace_philtrum,
  121. //长鼻
  122. PFBeautyFiterTypeFace_long_nose = 10,
  123. //眼距
  124. PFBeautyFiterTypeFace_eye_space,
  125. //微笑嘴角
  126. PFBeautyFiterTypeFace_smile,
  127. //旋转眼睛
  128. PFBeautyFiterTypeFace_eye_rotate,
  129. //开眼角
  130. PFBeautyFiterTypeFace_canthus,
  131. //磨皮
  132. PFBeautyFiterTypeFaceBlurStrength,
  133. //美白
  134. PFBeautyFiterTypeFaceWhitenStrength,
  135. //红润
  136. PFBeautyFiterTypeFaceRuddyStrength,
  137. //锐化
  138. PFBeautyFiterTypeFaceSharpenStrength,
  139. //新美白算法
  140. PFBeautyFiterTypeFaceM_newWhitenStrength,
  141. //画质增强
  142. PFBeautyFiterTypeFaceH_qualityStrength,
  143. //亮眼(0~1)
  144. PFBeautyFiterTypeFaceEyeBrighten,
  145. //滤镜类型
  146. PFBeautyFiterName,
  147. //滤镜强度
  148. PFBeautyFiterStrength,
  149. //绿幕
  150. PFBeautyFiterLvmu,
  151. // 2D 贴纸
  152. PFBeautyFiterSticker2DFilter,
  153. // 一键美颜
  154. PFBeautyFiterTypeOneKey = 26,
  155. // 水印
  156. PFBeautyFiterWatermark,
  157. // 扩展字段
  158. PFBeautyFiterExtend,
  159. } PFBeautyFiterType;
  160. /* 一键美颜类型 */
  161. typedef enum PFBeautyTypeOneKey{
  162. // 关闭一键美颜
  163. PFBeautyTypeOneKeyNormal = 0,
  164. // 自然
  165. PFBeautyTypeOneKeyNatural,
  166. // 可爱
  167. PFBeautyTypeOneKeyCute,
  168. // 女神
  169. PFBeautyTypeOneKeyGoddess,
  170. // 白净
  171. PFBeautyTypeOneKeyFair,
  172. }PFBeautyTypeOneKey;
  173. PF_CAPI_EXPORT extern const char* PF_Version();
  174. typedef struct PFPixelFree PFPixelFree;
  175. PF_CAPI_EXPORT extern void PF_VLogSetLevel(PFPixelFree* pixelFree,int level,char *path);
  176. PF_CAPI_EXPORT extern PFPixelFree* PF_NewPixelFree();
  177. PF_CAPI_EXPORT extern void PF_DeletePixelFree(PFPixelFree* pixelFree);
  178. //目前仅支持双输入。GPU 纹理由于渲染,cpu buffer 用检测
  179. PF_CAPI_EXPORT extern int PF_processWithBuffer(PFPixelFree* pixelFree,PFIamgeInput inputImage);
  180. PF_CAPI_EXPORT extern void PF_pixelFreeSetBeautyFiterParam(PFPixelFree* pixelFree, int key,void *value);
  181. PF_CAPI_EXPORT extern void PF_createBeautyItemFormBundle(PFPixelFree* pixelFree, void *data,int size,PFSrcType type);
  182. PF_CAPI_EXPORT extern void PF_pixelFreeGetFaceRect(PFPixelFree* pixelFree,float *faceRect);
  183. PF_CAPI_EXPORT extern int PF_pixelFreeHaveFaceSize(PFPixelFree* pixelFree);
  184. PF_CAPI_EXPORT extern int PF_pixelFreeColorGrading(PFPixelFree* pixelFree,PFImageColorGrading* ImageColorGrading);
  185. PF_CAPI_EXPORT extern int PF_pixelFreeAddHLSFilter(PFPixelFree* pixelFree,PFHLSFilterParams* HLSFilterParams);
  186. PF_CAPI_EXPORT extern int PF_pixelFreeDeleteHLSFilter(PFPixelFree* pixelFree,int handle);
  187. PF_CAPI_EXPORT extern int PF_pixelFreeChangeHLSFilter(PFPixelFree* pixelFree,int handle,PFHLSFilterParams* HLSFilterParams);
  188. #ifdef __cplusplus
  189. }
  190. #endif
  191. #endif /* pixelFree_c_hpp */