CNamaSDK.h 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852
  1. #ifndef CNAMASDK_H
  2. #define CNAMASDK_H
  3. #ifdef _WIN32
  4. #ifdef NAMA_BUILD_SHARED_LIB
  5. #define FUNAMA_API __declspec(dllexport)
  6. #else
  7. #define FUNAMA_API
  8. #endif
  9. #else
  10. #define FUNAMA_API __attribute__((visibility("default")))
  11. #endif
  12. #define FU_FORMAT_BGRA_BUFFER 0
  13. #define FU_FORMAT_RGBA_TEXTURE 1
  14. #define FU_FORMAT_NV21_BUFFER 2
  15. #define FU_FORMAT_GL_CURRENT_FRAMEBUFFER 3
  16. #define FU_FORMAT_RGBA_BUFFER 4
  17. #define FU_FORMAT_CAMERA 5
  18. #define FU_FORMAT_RGBA_TEXTURE_EXTERNAL_OES 6
  19. #define FU_FORMAT_ANDROID_DUAL 7
  20. #define FU_FORMAT_NV12_BUFFER 8
  21. #define FU_FORMAT_INTERNAL_IOS_DUAL_INPUT 9
  22. #define FU_FORMAT_GL_SPECIFIED_FRAMEBUFFER 10
  23. #define FU_FORMAT_AVATAR_INFO 12
  24. #define FU_FORMAT_I420_BUFFER 13
  25. #define FU_FORMAT_VOID 14
  26. #define NAMA_FILTER_TYPE_PRE 1
  27. #define NAMA_FILTER_TYPE_ONCE 2
  28. #define NAMA_FILTER_TYPE_FXAA 4
  29. #define NAMA_FILTER_TYPE_NORMAL 8
  30. #define DETECTOR_IMAGE_FORMAT_RGBA 0
  31. #define DETECTOR_IMAGE_FORMAT_MONO 1
  32. #define DETECTOR_IMAGE_FORMAT_BGRA 2
  33. #define DETECTOR_IMAGE_FORMAT_NV21 3
  34. #define DETECTOR_IMAGE_FORMAT_NV12 4
  35. #define DETECTOR_IMAGE_FORMAT_I420 5
  36. typedef enum FUAITYPE {
  37. FUAITYPE_NONE = 0,
  38. FUAITYPE_BACKGROUNDSEGMENTATION = 1 << 1,
  39. FUAITYPE_HAIRSEGMENTATION = 1 << 2,
  40. FUAITYPE_HANDGESTURE = 1 << 3,
  41. FUAITYPE_HANDPROCESSOR = 1 << 4,
  42. FUAITYPE_TONGUETRACKING = 1 << 5,
  43. FUAITYPE_HUMANPOSE2D = 1 << 6,
  44. FUAITYPE_BACKGROUNDSEGMENTATION_GREEN = 1 << 7,
  45. FUAITYPE_FACEPROCESSOR = 1 << 8,
  46. FUAITYPE_HUMAN_PROCESSOR = 1 << 9,
  47. FUAITYPE_FACE_RECOGNIZER = 1 << 10,
  48. FUAITYPE_IMAGE_BEAUTY = 1 << 11,
  49. FUAITYPE_FACE_ATTRIBUTE_PROCESSOR = 1 << 12,
  50. FUAITYPE_FACELANDMARKS75 = 1 << 13,
  51. FUAITYPE_FACELANDMARKS209 = 1 << 14,
  52. FUAITYPE_FACELANDMARKS239 = 1 << 15
  53. } FUAITYPE;
  54. #define FUAITYPE_FACEPROCESSOR_FACECAPTURE 1048576 // 1<<20
  55. #define FUAITYPE_FACEPROCESSOR_FACECAPTURE_TONGUETRACKING 2097152 // 1<<21
  56. #define FUAITYPE_FACEPROCESSOR_HAIRSEGMENTATION 4194304 // 1<<22
  57. #define FUAITYPE_FACEPROCESSOR_HEADSEGMENTATION 8388608 // 1<<23
  58. #define FUAITYPE_FACEPROCESSOR_EXPRESSION_RECOGNIZER 16777216 // 1<<24
  59. #define FUAITYPE_FACEPROCESSOR_EMOTION_RECOGNIZER 33554432 // 1<<25
  60. #define FUAITYPE_FACEPROCESSOR_DISNEYGAN 67108864 // 1<<26
  61. #define FUAITYPE_FACEPROCESSOR_FACEID 134217728 // 1<<27
  62. #define FUAITYPE_HUMAN_PROCESSOR_DETECT 268435456 // 1<<28
  63. #define FUAITYPE_HUMAN_PROCESSOR_SEGMENTATION 536870912 // 1<<29
  64. #define FUAITYPE_HUMAN_PROCESSOR_2D_SELFIE 1073741824 // 1<<30
  65. #define FUAITYPE_HUMAN_PROCESSOR_2D_DANCE 2147483648 // 1<<31
  66. #define FUAITYPE_HUMAN_PROCESSOR_2D_SLIM 4294967296 // 1<<32
  67. #define FUAITYPE_HUMAN_PROCESSOR_3D_SELFIE 8589934592 // 1<<33
  68. #define FUAITYPE_HUMAN_PROCESSOR_3D_DANCE 17179869184 // 1<<34
  69. #define FUAITYPE_HUMAN_PROCESSOR_2D_IMGSLIM 34359738368 // 1<<35
  70. #define FUAITYPE_IMAGE_BEAUTY_UNKNOW 68719476736 // 1<<36
  71. #define FUAITYPE_FACEPROCESSOR_LIPSOCCUSEGMENT 137438953472 // 1<<37
  72. #define FUAITYPE_FACEPROCESSOR_FACEOCCUSEGMENT 274877906944 // 1<<38
  73. typedef enum FUAIGESTURETYPE {
  74. FUAIGESTURE_NO_HAND = -1,
  75. FUAIGESTURE_UNKNOWN = 0,
  76. FUAIGESTURE_THUMB = 1,
  77. FUAIGESTURE_KORHEART = 2,
  78. FUAIGESTURE_SIX = 3,
  79. FUAIGESTURE_FIST = 4,
  80. FUAIGESTURE_PALM = 5,
  81. FUAIGESTURE_ONE = 6,
  82. FUAIGESTURE_TWO = 7,
  83. FUAIGESTURE_OK = 8,
  84. FUAIGESTURE_ROCK = 9,
  85. FUAIGESTURE_CROSS = 10,
  86. FUAIGESTURE_HOLD = 11,
  87. FUAIGESTURE_GREET = 12,
  88. FUAIGESTURE_PHOTO = 13,
  89. FUAIGESTURE_HEART = 14,
  90. FUAIGESTURE_MERGE = 15,
  91. FUAIGESTURE_EIGHT = 16,
  92. FUAIGESTURE_HALFFIST = 17,
  93. FUAIGESTURE_GUN = 18,
  94. } FUAIGESTURETYPE;
  95. typedef enum FULOGLEVEL {
  96. FU_LOG_LEVEL_TRACE = 0,
  97. FU_LOG_LEVEL_DEBUG = 1,
  98. FU_LOG_LEVEL_INFO = 2,
  99. FU_LOG_LEVEL_WARN = 3,
  100. FU_LOG_LEVEL_ERROR = 4,
  101. FU_LOG_LEVEL_CRITICAL = 5,
  102. FU_LOG_LEVEL_OFF = 6
  103. } FULOGLEVEL;
  104. typedef enum FUAIEXPRESSIONTYPE {
  105. FUAIEXPRESSION_UNKNOWN = 0,
  106. FUAIEXPRESSION_BROW_UP = 1 << 1,
  107. FUAIEXPRESSION_BROW_FROWN = 1 << 2,
  108. FUAIEXPRESSION_LEFT_EYE_CLOSE = 1 << 3,
  109. FUAIEXPRESSION_RIGHT_EYE_CLOSE = 1 << 4,
  110. FUAIEXPRESSION_EYE_WIDE = 1 << 5,
  111. FUAIEXPRESSION_MOUTH_SMILE_LEFT = 1 << 6,
  112. FUAIEXPRESSION_MOUTH_SMILE_RIGHT = 1 << 7,
  113. FUAIEXPRESSION_MOUTH_FUNNEL = 1 << 8,
  114. FUAIEXPRESSION_MOUTH_OPEN = 1 << 9,
  115. FUAIEXPRESSION_MOUTH_PUCKER = 1 << 10,
  116. FUAIEXPRESSION_MOUTH_ROLL = 1 << 11,
  117. FUAIEXPRESSION_MOUTH_PUFF = 1 << 12,
  118. FUAIEXPRESSION_MOUTH_SMILE = 1 << 13,
  119. FUAIEXPRESSION_MOUTH_FROWN = 1 << 14,
  120. FUAIEXPRESSION_HEAD_LEFT = 1 << 15,
  121. FUAIEXPRESSION_HEAD_RIGHT = 1 << 16,
  122. FUAIEXPRESSION_HEAD_NOD = 1 << 17,
  123. } FUAIEXPRESSIONTYPE;
  124. typedef enum FUAITONGUETYPE {
  125. FUAITONGUE_UNKNOWN = 0,
  126. FUAITONGUE_UP = 1 << 1,
  127. FUAITONGUE_DOWN = 1 << 2,
  128. FUAITONGUE_LEFT = 1 << 3,
  129. FUAITONGUE_RIGHT = 1 << 4,
  130. FUAITONGUE_LEFT_UP = 1 << 5,
  131. FUAITONGUE_LEFT_DOWN = 1 << 6,
  132. FUAITONGUE_RIGHT_UP = 1 << 7,
  133. FUAITONGUE_RIGHT_DOWN = 1 << 8,
  134. } FUAITONGUETYPE;
  135. typedef enum FUITEMTRIGGERTYPE {
  136. FUITEMTRIGGER_UNKNOWN = 0,
  137. FUITEMTRIGGER_CAI_DAN = 1,
  138. } FUITEMTRIGGERTYPE;
  139. typedef enum FUAIEMOTIONTYPE {
  140. FUAIEMOTION_UNKNOWN = 0,
  141. FUAIEMOTION_HAPPY = 1 << 1,
  142. FUAIEMOTION_SAD = 1 << 2,
  143. FUAIEMOTION_ANGRY = 1 << 3,
  144. FUAIEMOTION_SURPRISE = 1 << 4,
  145. FUAIEMOTION_FEAR = 1 << 5,
  146. FUAIEMOTION_DISGUST = 1 << 6,
  147. FUAIEMOTION_NEUTRAL = 1 << 7,
  148. FUAIEMOTION_CONFUSE = 1 << 8,
  149. } FUAIEMOTIONTYPE;
  150. typedef enum FUAIHUMANSTATE {
  151. FUAIHUMAN_NO_BODY = 0,
  152. FUAIHUMAN_HALF_LESS_BODY = 1,
  153. FUAIHUMAN_HALF_BODY = 2,
  154. FUAIHUMAN_HALF_MORE_BODY = 3,
  155. FUAIHUMAN_FULL_BODY = 4,
  156. } FUAIHUMANSTATE;
  157. typedef enum FUAISCENESTATE {
  158. FUAISCENE_UNKNOWN = -1,
  159. FUAISCENE_SELFIE = 0,
  160. FUAISCENE_DANCE = 1,
  161. FUAISCENE_SLIM = 2,
  162. } FUAISCENESTATE;
  163. typedef enum FUAIHUMANFOLLOWMODE {
  164. FUAIHUMAN_FOLLOW_MODE_UNKNOWN = -1,
  165. FUAIHUMAN_FOLLOW_MODE_FIX = 0,
  166. FUAIHUMAN_FOLLOW_MODE_ALIGN = 1,
  167. FUAIHUMAN_FOLLOW_MODE_STAGE = 2
  168. } FUAIHUMANFOLLOWMODE;
  169. typedef enum FUAIHUMANMIRRORTYPE {
  170. FUAIHUMAN_MIRROR_LR = 0,
  171. FUAIHUMAN_MIRROR_TB = 1,
  172. FUAIHUMAN_MIRROR_BOTH = 2,
  173. FUAIHUMAN_MIRROR_NONE = 3
  174. } FUAIHUMANMIRRORTYPE;
  175. typedef enum FUAIHUMANROTTYPE {
  176. FUAIHUMAN_ROT_0 = 0,
  177. FUAIHUMAN_ROT_90 = 1,
  178. FUAIHUMAN_ROT_180 = 2,
  179. FUAIHUMAN_ROT_270 = 3
  180. } FUAIHUMANROTTYPE;
  181. typedef enum FUAIHUMANSEGSCENETYPE {
  182. FUAIHUMAN_SEG_MEETING = 0,
  183. FUAIHUMAN_SEG_COMMON = 1
  184. } FUAIHUMANSEGSCENETYPE;
  185. typedef enum TRANSFORM_MATRIX {
  186. /*
  187. * 8 base orientation cases, first do counter-clockwise rotation in degree,
  188. * then do flip
  189. */
  190. DEFAULT = 0, // no rotation, no flip
  191. CCROT0 = DEFAULT, // no rotation, no flip
  192. CCROT90, // counter-clockwise rotate 90 degree
  193. CCROT180, // counter-clockwise rotate 180 degree
  194. CCROT270, // counter-clockwise rotate 270 degree
  195. CCROT0_FLIPVERTICAL, // vertical flip
  196. CCROT0_FLIPHORIZONTAL, // horizontal flip
  197. CCROT90_FLIPVERTICAL, // first counter-clockwise rotate 90 degree,then
  198. // vertical flip
  199. CCROT90_FLIPHORIZONTAL, // first counter-clockwise rotate 90 degree,then
  200. // horizontal flip
  201. /*
  202. * enums below is alias to above enums, there are only 8 orientation cases
  203. */
  204. CCROT0_FLIPVERTICAL_FLIPHORIZONTAL = CCROT180,
  205. CCROT90_FLIPVERTICAL_FLIPHORIZONTAL = CCROT270,
  206. CCROT180_FLIPVERTICAL = CCROT0_FLIPHORIZONTAL,
  207. CCROT180_FLIPHORIZONTAL = CCROT0_FLIPVERTICAL,
  208. CCROT180_FLIPVERTICAL_FLIPHORIZONTAL = DEFAULT,
  209. CCROT270_FLIPVERTICAL = CCROT90_FLIPHORIZONTAL,
  210. CCROT270_FLIPHORIZONTAL = CCROT90_FLIPVERTICAL,
  211. CCROT270_FLIPVERTICAL_FLIPHORIZONTAL = CCROT90,
  212. } TRANSFORM_MATRIX;
  213. #define FU_ROTATION_MODE_0 0
  214. #define FU_ROTATION_MODE_90 1
  215. #define FU_ROTATION_MODE_180 2
  216. #define FU_ROTATION_MODE_270 3
  217. /*\brief An I/O format where `ptr` points to a BGRA buffer. It matches the
  218. * camera format on iOS. */
  219. #define FU_FORMAT_BGRA_BUFFER 0
  220. /*\brief An I/O format where `ptr` points to a single GLuint that is a RGBA
  221. * texture. It matches the hardware encoding format on Android. */
  222. #define FU_FORMAT_RGBA_TEXTURE 1
  223. /*\brief An I/O format where `ptr` points to an NV21 buffer. It matches the
  224. * camera preview format on Android. */
  225. #define FU_FORMAT_NV21_BUFFER 2
  226. #define FU_FORMAT_I420_BUFFER 13
  227. /*\brief An output-only format where `out_ptr` is NULL or points to a
  228. TGLRenderingDesc structure. The result is rendered onto the current GL
  229. framebuffer no matter what `out_ptr` is. If a TGLRenderingDesc is specified,
  230. we can optionally return an image to the caller in the specified format.
  231. */
  232. #define FU_FORMAT_GL_CURRENT_FRAMEBUFFER 3
  233. /*\brief An I/O format where `ptr` points to a RGBA buffer. */
  234. #define FU_FORMAT_RGBA_BUFFER 4
  235. /*\brief An input-only format where `ptr` points to a TCameraDesc struct. The
  236. * input is directly taken from the specified camera. w and h are taken as the
  237. * preferred image size*/
  238. #define FU_FORMAT_CAMERA 5
  239. /*\brief An input-only format where `in_ptr` points to a single GLuint that is
  240. * an EXTERNAL_OES texture. It matches the hardware encoding format on Android.
  241. */
  242. #define FU_FORMAT_RGBA_TEXTURE_EXTERNAL_OES 6
  243. /*\brief An I/O format where `in_ptr` points to a TAndroidDualMode struct, which
  244. provides both a texture and an NV21 buffer as input.
  245. As the name suggests, this is the most efficient interface on Android. */
  246. #define FU_FORMAT_ANDROID_DUAL_MODE 7
  247. typedef struct {
  248. int camera_id; //<which camera should we use, 0 for front, 1 for back
  249. } TCameraDesc;
  250. /*\brief Indicate that the `tex` member is an EXTERNAL_OES texture */
  251. #define FU_ADM_FLAG_EXTERNAL_OES_TEXTURE 1
  252. /*\brief Indicate that the result should also be read back to p_NV21 */
  253. #define FU_ADM_FLAG_ENABLE_READBACK 2
  254. /*\brief Indicate that the input texture is a packed NV21 texture */
  255. #define FU_ADM_FLAG_NV21_TEXTURE 4
  256. /*\brief Indicate that the input texture is a packed IYUV420 texture */
  257. #define FU_ADM_FLAG_I420_TEXTURE 8
  258. /*\brief Indicate that the input buffer is a packed IYUV420 buffer */
  259. #define FU_ADM_FLAG_I420_BUFFER 16
  260. /*\brief Indicate that the input texture is a packed NV12 texture */
  261. #define FU_ADM_FLAG_NV12_TEXTURE 0x400000
  262. /*\brief Indicate that the input buffer is a packed NV12 buffer */
  263. #define FU_ADM_FLAG_NV12_BUFFER 0x800000
  264. #define FU_ADM_FLAG_RGBA_BUFFER 128
  265. typedef struct {
  266. void* p_NV21; //<the NV21 buffer
  267. int tex; //<the texture
  268. int flags;
  269. } TAndroidDualMode;
  270. /*\brief An I/O format where `ptr` points to a TNV12Buffer struct, which
  271. * describes a YpCbCr8BiPlanar buffer. It matches the YUV camera formats on iOS.
  272. */
  273. #define FU_FORMAT_NV12_BUFFER 8
  274. typedef struct {
  275. void* p_Y; //<the Y plane base address
  276. void* p_CbCr; //<the CbCr plane base address
  277. int stride_Y; //<the Y plane bytes-per-row
  278. int stride_CbCr; //<the CbCr plane bytes-per-row
  279. } TNV12Buffer;
  280. /*\brief An internal input format for efficient iOS CVPixelBuffer handling where
  281. * `ptr` points to a TIOSDualInput structure*/
  282. #define FU_FORMAT_INTERNAL_IOS_DUAL_INPUT 9
  283. #define FU_IDM_FORMAT_BGRA 0
  284. #define FU_IDM_FORMAT_NV12 1
  285. typedef struct {
  286. // members to be specified in the BGRA mode
  287. void* p_BGRA; //<the BGRA plane base address
  288. // members to be specified in the NV12 mode
  289. void* p_Y; //<the Y plane base address
  290. void* p_CbCr; //<the CbCr plane base address
  291. // members to be specified in the BGRA mode
  292. int stride_BGRA; //<the BGRA plane bytes-per-row
  293. // members to be specified in the NV12 mode
  294. int stride_Y; //<the Y plane bytes-per-row
  295. int stride_CbCr; //<the CbCr plane bytes-per-row
  296. // commom member
  297. int tex_handle; //<the GPU-side input, which has to be an RGBA texture
  298. /////////////////
  299. int format; //<FU_IDM_FORMAT_BGRA or FU_IDM_FORMAT_NV12
  300. } TIOSDualInput;
  301. /*\brief An internal output format for efficient iOS CVPixelBuffer handling
  302. * where `ptr` points to a TIOSFBO structure*/
  303. typedef struct {
  304. // we will reuse the FBO internally as an intermediate render target, so we
  305. // need to know the texture we expect a depth buffer to be bound to the FBO
  306. int fbo; //<the FBO to render onto
  307. int tex; //<the texture bound to that FBO
  308. } TSPECFBO;
  309. #define FU_FORMAT_GL_SPECIFIED_FRAMEBUFFER 10
  310. ////////////
  311. /**\brief take a user-defined param and a a width / height pair and return a
  312. * pointer to receive the image output*/
  313. typedef void* (*PFRECEIVE_RESULT)(void* param, int w, int h);
  314. typedef struct {
  315. unsigned char orientation; //<the target orientation and flags
  316. unsigned char version; //<version==0 for orientation only, set version to 1
  317. // if you want to read back anything
  318. unsigned short __padding;
  319. // version==1 members
  320. int image_output_mode; //<FU_FORMAT_BGRA_BUFFER, FU_FORMAT_RGBA_TEXTURE,
  321. // FU_FORMAT_NV21_BUFFER, or
  322. // FU_FORMAT_GL_CURRENT_FRAMEBUFFER for nothing at all
  323. PFRECEIVE_RESULT fcallback; //<the callback for receiving the image
  324. void* param; //<the user-defined param for the callback
  325. } TGLRenderingDesc;
  326. #define FU_FORMAT_AVATAR_INFO 12
  327. typedef struct {
  328. float* p_translation;
  329. float* p_rotation;
  330. float* p_expression;
  331. float* rotation_mode;
  332. float* pupil_pos;
  333. int is_valid;
  334. } TAvatarInfo;
  335. typedef struct {
  336. void* in_ptr;
  337. int in_type;
  338. int out_w;
  339. int out_h;
  340. float view_0_ratio;
  341. int margin_in_pixel;
  342. int is_vertical;
  343. int is_image_first;
  344. int rotation_mode_before_crop;
  345. float crop_ratio_top;
  346. int use_black_edge;
  347. } TSplitViewInfo;
  348. #define NAMA_RENDER_FEATURE_TRACK_FACE 0x10
  349. #define NAMA_RENDER_FEATURE_BEAUTIFY_IMAGE 0x20
  350. #define NAMA_RENDER_FEATURE_RENDER 0x40
  351. #define NAMA_RENDER_FEATURE_ADDITIONAL_DETECTOR 0x80
  352. #define NAMA_RENDER_FEATURE_RENDER_ITEM 0x100
  353. #define NAMA_RENDER_FEATURE_FULL \
  354. (NAMA_RENDER_FEATURE_RENDER_ITEM | NAMA_RENDER_FEATURE_TRACK_FACE | \
  355. NAMA_RENDER_FEATURE_BEAUTIFY_IMAGE | NAMA_RENDER_FEATURE_RENDER | \
  356. NAMA_RENDER_FEATURE_ADDITIONAL_DETECTOR)
  357. #define NAMA_RENDER_FEATURE_MASK 0xff0
  358. #define NAMA_RENDER_OPTION_FLIP_X 0x1000
  359. #define NAMA_RENDER_OPTION_FLIP_Y 0x2000
  360. #define NAMA_NOCLEAR_CURRENT_FRAMEBUFFER 0x4000
  361. #define NAMA_RENDER_OPTION_MASK 0xff000
  362. #ifdef __cplusplus
  363. extern "C" {
  364. #endif
  365. /**
  366. \brief open file log
  367. \param file_fullname - nullptr for default terminal, non-null for log into
  368. file. \param max_file_size, max file size in byte. \param max_files, max file
  369. num for rotating log. \return zero for failed, one for success.
  370. */
  371. FUNAMA_API int fuOpenFileLog(const char* file_pullname, int max_file_size,
  372. int max_files);
  373. /**
  374. \brief Set log level
  375. \param level - define in FULOGLEVEL enumeration.
  376. \return zero for failed, one for success.
  377. */
  378. FUNAMA_API int fuSetLogLevel(FULOGLEVEL level);
  379. /**
  380. \brief set log prefix
  381. \param prefix, log prefix
  382. */
  383. FUNAMA_API void fuSetLogPrefix(const char* prefix);
  384. /**
  385. \brief Get current log level
  386. \return ref to FULOGLEVEL
  387. */
  388. FUNAMA_API FULOGLEVEL fuGetLogLevel();
  389. /**
  390. \brief init gl context, which managed by SDK
  391. \param sharedContext ptr of shared context, can be null.
  392. \return non null for success.
  393. \warning experimental API
  394. */
  395. FUNAMA_API void* fuInitGLContext(void* sharedContext);
  396. /**
  397. \brief destroy the managed gl context, created by fuInitGLContext.
  398. \return true for success, vice versa.
  399. \warning experimental API
  400. */
  401. FUNAMA_API bool fuDestroyGLContext();
  402. /**
  403. \brief make the managed gl context current, context that created by
  404. fuInitGLContext.
  405. \return true for success, vice versa.
  406. \warning experimental API
  407. */
  408. FUNAMA_API bool fuMakeGLContextCurrent();
  409. FUNAMA_API void* fuGetCurrentGLContext();
  410. /**
  411. \brief Initialize and authenticate your SDK instance to the FaceUnity server,
  412. must be called exactly once before all other functions. The buffers should
  413. NEVER be freed while the other functions are still being called. You can call
  414. this function multiple times to "switch pointers".
  415. \param v3data should point to contents of the "v3.bin" we provide
  416. \param sz_v3data should point to num-of-bytes of the "v3.bin" we provide
  417. \param ardata should be NULL
  418. \param authdata is the pointer to the authentication data pack we provide. You
  419. must avoid storing the data in a file. Normally you can just `#include
  420. "authpack.h"` and put `g_auth_package` here.
  421. \param sz_authdata is the authentication data size, we use plain int to avoid
  422. cross-language compilation issues. Normally you can just `#include
  423. "authpack.h"` and put `sizeof(g_auth_package)` here.
  424. \return non-zero for success, zero for failure
  425. */
  426. FUNAMA_API int fuSetup(float* sdk_data, int sz_sdk_data, float* ardata,
  427. void* authdata, int sz_authdata);
  428. FUNAMA_API int fuSetupWithoutRetry(float* sdk_data, int sz_sdk_data,
  429. float* ardata, void* authdata,
  430. int sz_authdata);
  431. /**
  432. \brief offline authentication
  433. Initialize and authenticate your SDK instance to the FaceUnity server,
  434. must be called exactly once before all other functions. The buffers should
  435. NEVER be freed while the other functions are still being called. You can call
  436. this function multiple times to "switch pointers".
  437. \param v3data should point to contents of the "v3.bin" we provide
  438. \param sz_v3data should point to num-of-bytes of the "v3.bin" we provide
  439. \param ardata should be NULL
  440. \param authdata is the pointer to the authentication data pack we provide. You
  441. must avoid storing the data in a file. Normally you can just `#include
  442. "authpack.h"` and put `g_auth_package` here.
  443. \param sz_authdata is the authentication data size, we use plain int to avoid
  444. cross-language compilation issues. Normally you can just `#include
  445. "authpack.h"` and put `sizeof(g_auth_package)` here.
  446. \param offline_bundle_ptr is the pointer to offline bundle from FaceUnity
  447. server
  448. \param offline_bundle_sz is size of offline bundle
  449. \return non-zero for success, zero for failure
  450. */
  451. FUNAMA_API int fuSetupLocal(float* v3data, int sz_v3data, float* ardata,
  452. void* authdata, int sz_authdata,
  453. void** offline_bundle_ptr, int* offline_bundle_sz);
  454. FUNAMA_API int fuSetupLocal2(float* v3data, int sz_v3data, float* ardata,
  455. void* authdata, int sz_authdata,
  456. void* offline_input_bundle_ptr,
  457. int offline_input_bundle_sz,
  458. void** offline_output_bundle_ptr,
  459. int* offline_output_bundle_sz);
  460. /**
  461. \brief Initialize and authenticate your SDK instance with internal check,
  462. must be called exactly once before all other functions. The buffers should
  463. NEVER be freed while the other functions are still being called. You can call
  464. this function multiple times to "switch pointers".
  465. \param v3data should point to contents of the "v3.bin" we provide
  466. \param sz_v3data should point to num-of-bytes of the "v3.bin" we provide
  467. \param ardata should be NULL
  468. \param authdata is the pointer to the authentication data pack we provide. You
  469. must avoid storing the data in a file. Normally you can just `#include
  470. "authpack.h"` and put `g_auth_package` here.
  471. \param sz_authdata is the authentication data size, we use plain int to avoid
  472. cross-language compilation issues. Normally you can just `#include
  473. "authpack.h"` and put `sizeof(g_auth_package)` here.
  474. \return non-zero for success, zero for failure
  475. */
  476. FUNAMA_API int fuSetupInternalCheck(float* sdk_data, int sz_sdk_data,
  477. float* ardata, void* authdata,
  478. int sz_authdata);
  479. /**
  480. \brief Initialize and authenticate your SDK instance with internal check,
  481. must be called exactly once before all other functions. The buffers should
  482. NEVER be freed while the other functions are still being called. You can call
  483. this function multiple times to "switch pointers".
  484. \param v3data should point to contents of the "v3.bin" we provide
  485. \param sz_v3data should point to num-of-bytes of the "v3.bin" we provide
  486. \param ardata should be NULL
  487. \param authdata is the pointer to the authentication data pack we provide. You
  488. must avoid storing the data in a file. Normally you can just `#include
  489. "authpack.h"` and put `g_auth_package` here.
  490. \param sz_authdata is the authentication data size, we use plain int to avoid
  491. cross-language compilation issues. Normally you can just `#include
  492. "authpack.h"` and put `sizeof(g_auth_package)` here.
  493. \param auth_info_data is the pointer to the encrypted authentication
  494. information data. You must avoid storing the data in a file, compute at runtime
  495. instead.
  496. \param sz_auth_info_data is the encrypted authentication information
  497. data size,
  498. \return non-zero for success, zero for failure
  499. */
  500. FUNAMA_API int fuSetupInternalCheckEx(float* sdk_data, int sz_sdk_data,
  501. float* ardata, void* authdata,
  502. int sz_authdata, void* auto_info_data,
  503. int sz_auto_info_data);
  504. /**
  505. \brief Initialize and authenticate your SDK instance with internal check,
  506. must be called exactly once before all other functions. The buffers should
  507. NEVER be freed while the other functions are still being called. You can call
  508. this function multiple times to "switch pointers".
  509. \param v3data should point to contents of the "v3.bin" we provide
  510. \param sz_v3data should point to num-of-bytes of the "v3.bin" we provide
  511. \param ardata should be NULL
  512. \param authdata is the pointer to the authentication data pack we provide. You
  513. must avoid storing the data in a file. Normally you can just `#include
  514. "authpack.h"` and put `g_auth_package` here.
  515. \param sz_authdata is the authentication data size, we use plain int to avoid
  516. cross-language compilation issues. Normally you can just `#include
  517. "authpack.h"` and put `sizeof(g_auth_package)` here.
  518. \return non-zero for success, zero for failure
  519. */
  520. FUNAMA_API int fuSetupInternalCheckPackageBind(float* sdk_data, int sz_sdk_data,
  521. float* ardata, void* authdata,
  522. int sz_authdata);
  523. /**
  524. \brief if opengl is supported return 1, else return 0
  525. call after fuSetup
  526. */
  527. FUNAMA_API int fuGetOpenGLSupported();
  528. /**
  529. \brief Generalized interface for rendering a list of items with extension.
  530. This function needs a GLES 2.0+ context.
  531. \param out_format is the output format
  532. \param out_ptr receives the rendering result, which is either a GLuint texture
  533. handle or a memory buffer Note that in the texture cases, we will overwrite
  534. *out_ptr with a texture we generate.
  535. \param in_format is the input format
  536. \param in_ptr points to the input image, which is either a GLuint texture
  537. handle or a memory buffer
  538. \param w specifies the image width
  539. \param h specifies the image height
  540. \param frameid specifies the current frame id. To get animated effects, please
  541. increase frame_id by 1 whenever you call this.
  542. \param p_items points to the list of items
  543. \param n_items is the number of items
  544. \param func_flag flags indicate all changable functionalities of render
  545. interface
  546. \param p_masks indicates a list of masks for each item, bitwisely work
  547. on certain face
  548. \return a GLuint texture handle containing the rendering result if out_format
  549. isn't FU_FORMAT_GL_CURRENT_FRAMEBUFFER
  550. */
  551. FUNAMA_API int fuRenderItemsEx2(int out_format, void* out_ptr, int in_format,
  552. void* in_ptr, int w, int h, int frame_id,
  553. int* p_items, int n_items, int func_flag,
  554. void* p_item_masks);
  555. FUNAMA_API int fuRender(int out_format, void* out_ptr, int in_format,
  556. void* in_ptr, int w, int h, int frame_id, int* p_items,
  557. int n_items, int func_flag, void* p_item_masks);
  558. FUNAMA_API int fuRenderBundles(int out_format, void* out_ptr, int in_format,
  559. void* in_ptr, int w, int h, int frame_id,
  560. int* p_items, int n_items);
  561. FUNAMA_API int fuRenderBundlesEx(int out_format, void* out_ptr, int in_format,
  562. void* in_ptr, int w, int h, int frame_id,
  563. int* p_items, int n_items, int func_flag,
  564. void* p_item_masks);
  565. FUNAMA_API int fuRenderBundlesSplitView(int out_format, void* out_ptr,
  566. int in_format, void* in_ptr, int w,
  567. int h, int frame_id, int* p_items,
  568. int n_items, int func_flag,
  569. void* p_item_masks,
  570. TSplitViewInfo* split_info);
  571. FUNAMA_API int fuRotateImage(void* in_ptr, int in_format, int in_w, int in_h,
  572. int rotate_mode, int flip_x, int flip_y,
  573. void* out_ptr1, void* out_ptr2);
  574. /**
  575. this api will be deprecated. use
  576. fuSetInputCameraTextureMatrix/fuSetInputCameraBufferMatrix
  577. \brief input description for fuRenderBundles api, use to rotate or flip input
  578. texture to portrait mode.
  579. \param flip_x, flip input texture horizontally
  580. \param flip_y, flip input texture vertically
  581. \param rotate_mode w.r.t to rotation the the input texture counterclockwise,
  582. 0=0^deg, 1=90^deg,2=180^deg, 3=270^deg
  583. */
  584. FUNAMA_API void fuSetInputCameraMatrix(int flip_x, int flip_y, int rotate_mode);
  585. /**
  586. \brief input description for fuRender api, use to transform the input gpu
  587. texture to portrait mode(head-up). then the final output will portrait mode.
  588. the outter user present render pass should use identity matrix to present the
  589. result.
  590. \param tex_trans_mat, the transform matrix use to transform the input
  591. texture to portrait mode.
  592. \note when your input is cpu buffer only don't use
  593. this api, fuSetInputCameraBufferMatrix will handle all case.
  594. */
  595. FUNAMA_API void fuSetInputCameraTextureMatrix(TRANSFORM_MATRIX tex_trans_mat);
  596. /**
  597. \brief input description for fuRender api, use to transform the input cpu
  598. buffer to portrait mode(head-up). then the final output will portrait mode. the
  599. outter user present render pass should use identity matrix to present the
  600. result.
  601. \param buf_trans_mat, the transform matrix use to transform the input
  602. cpu buffer to portrait mode.
  603. \note when your input is gpu texture only don't
  604. use this api, fuSetInputCameraTextureMatrix will handle all case.
  605. */
  606. FUNAMA_API void fuSetInputCameraBufferMatrix(TRANSFORM_MATRIX buf_trans_mat);
  607. /**
  608. \brief set input camera texture transform matrix state, turn on or turn off
  609. */
  610. FUNAMA_API void fuSetInputCameraTextureMatrixState(bool isEnable);
  611. /**
  612. \brief set input camera buffer transform matrix state, turn on or turn off
  613. */
  614. FUNAMA_API void fuSetInputCameraBufferMatrixState(bool isEnable);
  615. /**
  616. \brief add optional transform for final result, when use
  617. fuSetInputCameraTextureMatrix/fuSetInputCameraBufferMatrix, we means the output
  618. is in portrait mode(head-up), and the outter user present render pass should
  619. use identity matrix to present the result. but in some rare case, user would
  620. like to use a diffent orientation output. in this case,use
  621. fuSetInputCameraTextureMatrix/fuSetInputCameraBufferMatrix(portrait mode), then
  622. use the additional fuSetOutputMatrix to transform the final result to perfer
  623. orientation.
  624. \note Don't use this api unless you have to!
  625. */
  626. FUNAMA_API void fuSetOutputMatrix(TRANSFORM_MATRIX out_trans_mat);
  627. /**
  628. \brief set additional transform matrix state, turn on or turn off
  629. */
  630. FUNAMA_API void fuSetOutputMatrixState(bool isEnable);
  631. /**
  632. \brief set internal render target cache state, it is turn off by default.
  633. */
  634. FUNAMA_API void fuSetRttCacheState(bool isEnable);
  635. /**
  636. \brief control output resolution for fuRenderBundles.
  637. \param w, width of output texture
  638. \param h, height of output texture
  639. */
  640. FUNAMA_API void fuSetOutputResolution(int w, int h);
  641. /**
  642. \brief Generalized interface for rendering a list of items. This function needs
  643. a GLES 2.0+ context.
  644. \param out_format is the output format
  645. \param out_ptr receives the rendering result, which is either a GLuint texture
  646. handle or a memory buffer Note that in the texture cases, we will overwrite
  647. *out_ptr with a texture we generate.
  648. \param in_format is the input format
  649. \param in_ptr points to the input image, which is either a GLuint texture
  650. handle or a memory buffer
  651. \param w specifies the image width
  652. \param h specifies the image height
  653. \param frameid specifies the current frame id. To get animated effects, please
  654. increase frame_id by 1 whenever you call this.
  655. \param p_items points to the list of items
  656. \param n_items is the number of items
  657. \return a GLuint texture handle containing the rendering result if out_format
  658. isn't FU_FORMAT_GL_CURRENT_FRAMEBUFFER
  659. */
  660. FUNAMA_API int fuRenderItemsEx(int out_format, void* out_ptr, int in_format,
  661. void* in_ptr, int w0, int h0, int frame_id,
  662. int* p_items, int n_items);
  663. /**
  664. \brief Generalized interface for rendering a list of items. This function needs
  665. a GLES 2.0+ context.
  666. \param out_format is the output format
  667. \param out_ptr receives the rendering result, which is either a GLuint texture
  668. handle or a memory buffer Note that in the texture cases, we will overwrite
  669. *out_ptr with a texture we generate.
  670. \param in_format is the input format
  671. \param in_ptr points to the input image, which is either a GLuint texture
  672. handle or a memory buffer
  673. \param w specifies the image width
  674. \param h specifies the image height
  675. \param frameid specifies the current frame id. To get animated effects, please
  676. increase frame_id by 1 whenever you call this.
  677. \param p_items points to the list of items
  678. \param n_items is the number of items
  679. \param p_masks indicates a list of masks for each item, bitwisely work on
  680. certain face
  681. \return a GLuint texture handle containing the rendering result if out_format
  682. isn't FU_FORMAT_GL_CURRENT_FRAMEBUFFER
  683. */
  684. FUNAMA_API int fuRenderItemsMasked(int out_format, void* out_ptr, int in_format,
  685. void* in_ptr, int w0, int h0, int frame_id,
  686. int* p_items, int n_items,
  687. void* p_item_masks);
  688. /**
  689. \brief Generalized interface for beautifying image.
  690. Disable face tracker and item rendering.
  691. This function needs a GLES 2.0+ context.
  692. \param out_format is the output format
  693. \param out_ptr receives the rendering result, which is either a GLuint texture
  694. handle or a memory buffer Note that in the texture cases, we will overwrite
  695. *out_ptr with a texture we generate.
  696. \param in_format is the input format
  697. \param in_ptr points to the input image, which is either a GLuint texture handle
  698. or a memory buffer
  699. \param w specifies the image width
  700. \param h specifies the image height
  701. \param frameid specifies the current frame id. To get animated effects, please
  702. increase frame_id by 1 whenever you call this.
  703. \param p_items points to the list of items
  704. \param n_items is the number of items
  705. \return a GLuint texture handle containing the rendering result if out_format
  706. isn't FU_FORMAT_GL_CURRENT_FRAMEBUFFER
  707. */
  708. FUNAMA_API int fuBeautifyImage(int out_format, void* out_ptr, int in_format,
  709. void* in_ptr, int w, int h, int frame_id,
  710. int* p_items, int n_items);
  711. /**
  712. \brief Create an accessory item from a binary package, you can discard the data
  713. after the call. This function MUST be called in the same GLES context / thread
  714. as fuRenderItems.
  715. \param data is the pointer to the data
  716. \param sz is the data size, we use plain int to avoid cross-language
  717. compilation issues
  718. \return an integer handle representing the item
  719. */
  720. FUNAMA_API int fuCreateItemFromPackage(void* data, int sz);
  721. FUNAMA_API int fuCreateLiteItemFromPackage(int handle, void* data, int sz);
  722. /**
  723. \brief Destroy an accessory item. This function no need to be called in the
  724. same GLES context / thread as the original fuCreateItemFromPackage.
  725. \param item is the handle to be destroyed.
  726. */
  727. FUNAMA_API void fuDestroyItem(int item);
  728. /**
  729. \brief Destroy all accessory items ever created.This function MUST be called in
  730. the same GLES context / thread as the original fuCreateItemFromPackage.
  731. */
  732. FUNAMA_API void fuDestroyAllItems();
  733. /**
  734. \brief Destroy all internal data, resources, threads, etc.
  735. */
  736. FUNAMA_API void fuDestroyLibData();
  737. /**
  738. \brief Call this function when the GLES context has been lost, this function
  739. won't do gl resource release, it only reset cpu flags.
  740. */
  741. FUNAMA_API void fuOnDeviceLostSafe();
  742. /**
  743. \brief Call this function when the GLES context has been lost and recreated.
  744. That isn't a normal thing, so this function could leak resources on each
  745. call.
  746. */
  747. FUNAMA_API void fuOnDeviceLost();
  748. /**
  749. \brief Call this function when the GLES context has been lost and recreated.
  750. That isn't a normal thing, so this function could leak resources on
  751. each. This function only releses all gl resource compared to fuOnDeviceLost
  752. call.
  753. */
  754. FUNAMA_API void fuReleaseGLResources();
  755. /**
  756. \brief Call this function when the GLES context has been lost and recreated.
  757. This function won't do gl resource release, it only reset cpu flags.
  758. This function only releses all gl resource compared to
  759. fuOnDeviceLostSafe call.
  760. */
  761. FUNAMA_API void fuReleaseGLResourcesSafe();
  762. /**
  763. \brief Call this function to reset the face tracker on camera switches
  764. */
  765. FUNAMA_API void fuOnCameraChange();
  766. /**
  767. \brief Check whether an item is debug version
  768. \param data - the pointer to the item data
  769. \param sz - the data size, we use plain int to avoid cross-language compilation
  770. issues
  771. \return 0 - normal item 1 - debug item -1 - corrupted item data
  772. */
  773. FUNAMA_API int fuCheckDebugItem(char* data, int sz);
  774. /**
  775. \brief Bind items to target item, target item act as a controller,target item
  776. should has 'OnBind' function, already bound items won't be unbound
  777. \param obj_handle is the target item handle
  778. \param p_items points to a list of item handles to be bound to the target item
  779. \param n_items is the number of item handles in p_items
  780. \return the number of items newly bound to the avatar
  781. */
  782. FUNAMA_API int fuBindItems(int obj_handle, int* p_items, int n_items);
  783. /**
  784. \brief Unbind items from the target item
  785. \param obj_hand is the target item handle
  786. \param p_items points to a list of item handles to be unbound from the target
  787. item
  788. \param n_items is the number of item handles in p_items
  789. \return the number of items unbound from the target item
  790. */
  791. FUNAMA_API int fuUnbindItems(int obj_handle, int* p_items, int n_items);
  792. /**
  793. \brief Unbind all items from the target item
  794. \param obj_handle is the target item handle
  795. \return the number of items unbound from the target item
  796. */
  797. FUNAMA_API int fuUnbindAllItems(int obj_handle);
  798. /**
  799. \warning: deprecated API,use fuBindItems instead
  800. \brief Bind items to an avatar, already bound items won't be unbound
  801. \param avatar_item is the avatar item handle
  802. \param p_items points to a list of item handles to be bound to the avatar
  803. \param n_items is the number of item handles in p_items
  804. \param p_contracts points to a list of contract handles for authorizing items
  805. \param n_contracts is the number of contract handles in p_contracts
  806. \return the number of items newly bound to the avatar
  807. */
  808. FUNAMA_API int fuAvatarBindItems(int obj_handle, int* p_items, int n_items,
  809. int* p_contracts, int n_contracts);
  810. /**
  811. \warning: deprecated API,use fuUnindItems instead
  812. \brief Unbind items from an avatar
  813. \param obj_handle is the avatar item handle
  814. \param p_items points to a list of item handles to be unbound from the avatar
  815. \param n_items is the number of item handles in p_items
  816. \return the number of items unbound from the avatar
  817. */
  818. FUNAMA_API int fuAvatarUnbindItems(int obj_handle, int* p_items, int n_items);
  819. /**
  820. \brief Get an item parameter as a double value
  821. \param obj_handle specifies the item
  822. \param name is the parameter name
  823. \return double value of the parameter
  824. */
  825. FUNAMA_API double fuItemGetParamd(int obj_handle, const char* name);
  826. /**
  827. \brief Set an item parameter to a double value
  828. \param obj_handle specifies the item
  829. \param name is the parameter name
  830. \param value is the parameter value to be set
  831. \return zero for failure, non-zero for success
  832. */
  833. FUNAMA_API int fuItemSetParamd(int obj_handle, const char* name, double value);
  834. /**
  835. \brief Set an item parameter to a double array
  836. \param item specifies the item
  837. \param name is the parameter name
  838. \param value points to an array of doubles
  839. \param n specifies the number of elements in value
  840. \return zero for failure, non-zero for success
  841. */
  842. FUNAMA_API int fuItemSetParamdv(int obj_handle, const char* name, double* value,
  843. int n);
  844. /**
  845. \brief Get an item parameter as a string
  846. \param item specifies the item
  847. \param name is the parameter name
  848. \param buf receives the string value
  849. \param sz is the number of bytes available at buf
  850. \return the length of the string value, or -1 if the parameter is not a string.
  851. */
  852. FUNAMA_API int fuItemGetParams(int obj_handle, const char* name, char* buf,
  853. int buf_sz);
  854. /**
  855. \brief Set an item parameter to a string value
  856. \param item specifies the item
  857. \param name is the parameter name
  858. \param value is the parameter value to be set
  859. \return zero for failure, non-zero for success
  860. */
  861. FUNAMA_API int fuItemSetParams(int obj_handle, const char* name,
  862. const char* value);
  863. /**
  864. \brief Get an item parameter to a byte buffer
  865. \param obj_handle specifies the item
  866. \param name is the parameter name
  867. \param buf is the parameter value to be set
  868. \param n is the parameter value to be set
  869. \return zero for failure, non-zero for success
  870. */
  871. FUNAMA_API int fuItemGetParamu8v(int obj_handle, const char* name, char* buf,
  872. int n);
  873. /**
  874. \brief Set an item parameter to a byte buffer
  875. \param obj_handle specifies the item
  876. \param name is the parameter name
  877. \param buf is the parameter value to be set
  878. \param n is the parameter value to be set
  879. \return zero for failure, non-zero for success
  880. */
  881. FUNAMA_API int fuItemSetParamu8v(int obj_handle, const char* name,
  882. const void* value, int n);
  883. /**
  884. \brief Set an item parameter to a u64 value
  885. \param item specifies the item
  886. \param name is the parameter name
  887. \param value is the parameter value to be set
  888. \return zero for failure, non-zero for success
  889. */
  890. FUNAMA_API int fuItemSetParamu64(int item, char* name,
  891. unsigned long long value);
  892. /**
  893. \brief Get an item parameter as a double array
  894. \param item specifies the item
  895. \param name is the parameter name
  896. \param buf receives the double array value
  897. \param n specifies the number of elements in value
  898. \return the length of the double array value, or -1 if the parameter is not a
  899. double array.
  900. */
  901. FUNAMA_API int fuItemGetParamdv(int item, char* name, double* buf, int n);
  902. /**
  903. \brief Get an item parameter as a float array
  904. \param item specifies the item
  905. \param name is the parameter name
  906. \param buf receives the double array value
  907. \param n specifies the number of elements in value
  908. \return the length of the double array value, or -1 if the parameter is not a
  909. double array.
  910. */
  911. FUNAMA_API int fuItemGetParamfv(int item, char* name, float* buf, int sz);
  912. /**
  913. \brief create a texture for a rgba buffer and set tex as an item parameter
  914. \param item specifies the item
  915. \param name is the parameter name
  916. \param value rgba buffer
  917. \param width image width
  918. \param height image height
  919. \return zero for failure, non-zero for success
  920. */
  921. FUNAMA_API int fuCreateTexForItem(int item, const char* name, void* value,
  922. int width, int height);
  923. /**
  924. \brief delete the texture in item,only can be used to delete texutre create by
  925. fuCreateTexForItem
  926. \param item specifies the item
  927. \param name is the parameter name
  928. \return zero for failure, non-zero for success
  929. */
  930. FUNAMA_API int fuDeleteTexForItem(int item, const char* name);
  931. /**
  932. \brief Get the face tracking status
  933. \return The number of valid faces currently being tracked
  934. */
  935. FUNAMA_API int fuIsTracking();
  936. /**
  937. \brief Get library init status
  938. \return 1 inited, 0 not init.
  939. */
  940. FUNAMA_API int fuIsLibraryInit();
  941. /**
  942. \brief Get the camera image size
  943. \param pret points to two integers, which receive the size
  944. */
  945. FUNAMA_API void fuGetCameraImageSize(int* ret);
  946. /**
  947. \brief Set the default orientation for face detection. The correct orientation
  948. would make the initial detection much faster.
  949. \param rmode is the default orientation to be set to, one of 0..3 should work.
  950. */
  951. FUNAMA_API void fuSetDefalutOrientation();
  952. /**
  953. \brief Set the default rotationMode.
  954. \param rotationMode is the default rotationMode to be set to, one of 0..3 should
  955. work.
  956. */
  957. FUNAMA_API void fuSetDefaultRotationMode(int rotationMode);
  958. /**
  959. \brief Set the device's Orientation.
  960. \param deviceOrientation is the device's runtime orientation, one of 0..3 should
  961. work.
  962. */
  963. FUNAMA_API int fuSetDeviceOrientation(int deviceOrientation);
  964. /**
  965. \brief Set the maximum number of faces we track. The default value is 1.
  966. \param n is the new maximum number of faces to track
  967. \return The previous maximum number of faces tracked
  968. */
  969. FUNAMA_API int fuSetMaxFaces(int n_max_faces);
  970. /**
  971. \brief Set detect face every how number of frame when no face
  972. \param n is the number of frame
  973. */
  974. FUNAMA_API void fuSetFaceProcessorDetectEveryNFramesWhenNoFace(int n_frames);
  975. /**
  976. \brief Set detect face every how number of frame when having face
  977. \param n is the number of frame
  978. */
  979. FUNAMA_API void fuSetFaceProcessorDetectEveryNFramesWhenFace(int n_frames);
  980. /**
  981. \brief Get the unique identifier for each face during current tracking
  982. Lost face tracking will change the identifier, even for a quick retrack
  983. \param face_id is the id of face, index is smaller than which is set in
  984. fuSetMaxFaces If this face_id is x, it means x-th face currently tracking
  985. \return the unique identifier for each face
  986. */
  987. FUNAMA_API int fuGetFaceIdentifier(int face_id);
  988. /**
  989. \brief Get face info. Certificate aware interface.
  990. \param face_id is the id of face, index is smaller than which is set in
  991. fuSetMaxFaces If this face_id is x, it means x-th face currently tracking To get
  992. a unique id for each face, use fuGetFaceIdentifier interface
  993. \param name the name of certain face info
  994. \param pret allocated memory space as container
  995. \param num is number of float allocated in pret
  996. eg:
  997. "landmarks" - 2D landmarks coordinates in image space - 75*2 float
  998. "landmarks_ar" - 3D landmarks coordinates in camera space - 75*3 float
  999. "eye_rotation" - eye rotation quaternion - 4 float - (Conversion between
  1000. quaternions and Eular angles:
  1001. https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles)
  1002. "translation" - 3D translation of face in camera space - 3 float
  1003. "rotation" - rotation quaternion - 4 float - (Conversion between
  1004. quaternions and Eular angles:
  1005. https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles)
  1006. "projection_matrix" - the transform matrix from camera space to image space -
  1007. 16 float
  1008. "face_rect" - the rectangle of tracked face in image
  1009. space,(xmin,ymin,xmax,ymax) - 4 float
  1010. "rotation_mode" - the relative orientaion of face agains phone, 0-3 - 1 float
  1011. "failure_rate" - the failure rate of face tracking, the less the more
  1012. confident about tracking result - 1 float
  1013. \return 1 means successful fetch, container filled with info 0 means failure,
  1014. general failure is due to invalid face info other specific failure will print on
  1015. the console
  1016. */
  1017. FUNAMA_API int fuGetFaceInfo(int face_id, const char* name, void* pret,
  1018. int num);
  1019. /*
  1020. result is rotated and fliped according to fuSetInputCameraBufferMatrix
  1021. */
  1022. FUNAMA_API int fuGetFaceInfoRotated(int face_id, const char* name, void* pret,
  1023. int num);
  1024. FUNAMA_API int fuGetAIInfo(int index, const char* name, void* pret, int num);
  1025. FUNAMA_API int fuGetAIInfoRotated(int index, const char* name, void* pret,
  1026. int num);
  1027. FUNAMA_API void* fuGetFaceProcessorResult();
  1028. /**
  1029. \warning deprecated api
  1030. \brief Set the quality-performance tradeoff.
  1031. \param quality is the new quality value.
  1032. It's a floating point number between 0 and 1.
  1033. Use 0 for maximum performance and 1 for maximum quality.
  1034. The default quality is 1 (maximum quality).
  1035. */
  1036. FUNAMA_API void fuSetQualityTradeoff(float quality);
  1037. /**
  1038. \brief Set AI type for fuTrackFace and fuTrackFaceWithTongue interface
  1039. \param ai_type, is a bit combination of FUAITYPE and subtypes;
  1040. */
  1041. FUNAMA_API void fuSetTrackFaceAIType(unsigned long long ai_type);
  1042. /**
  1043. \brief Generalized interface for tracking face.
  1044. \param out_format is the output format
  1045. \param out_ptr receives the rendering result, which is either a
  1046. GLuint texture handle or a memory buffer Note that in the texture cases, we will
  1047. overwrite *out_ptr with a texture we generate.
  1048. \param in_format is the input format
  1049. \param in_ptr points to the input image, which is either a GLuint texture
  1050. handle or a memory buffer
  1051. \param w specifies the image width
  1052. \param h specifies the image height
  1053. \param frameid specifies the current frame id. To get animated
  1054. effects, please increase frame_id by 1 whenever you call this.
  1055. \param p_items points to the list of items
  1056. \param n_items is the number of items
  1057. \return a GLuint texture handle containing the rendering result if out_format
  1058. isn't FU_FORMAT_GL_CURRENT_FRAMEBUFFER
  1059. */
  1060. FUNAMA_API int fuTrackFace(int in_format, void* in_ptr, int w0, int h0);
  1061. /**
  1062. \brief Generalized interface for tracking face with tongue tracking.
  1063. */
  1064. FUNAMA_API int fuTrackFaceWithTongue(int in_format, void* in_ptr, int w0,
  1065. int h0);
  1066. /**
  1067. \brief Get system error, which causes system shutting down
  1068. \return System error code represents one or more errors
  1069. Error code can be checked against following bitmasks, non-zero result
  1070. means certain error This interface is not a callback, needs to be called on
  1071. every frame and check result, no cost Inside authentication error
  1072. (NAMA_ERROR_BITMASK_AUTHENTICATION), meanings for each error code are listed
  1073. below:
  1074. 1 failed to seed the RNG
  1075. 2 failed to parse the CA cert
  1076. 3 failed to connect to the server
  1077. 4 failed to configure TLS
  1078. 5 failed to parse the client cert
  1079. 6 failed to parse the client key
  1080. 7 failed to setup TLS
  1081. 8 failed to setup the server hostname
  1082. 9 TLS handshake failed
  1083. 10 TLS verification failed
  1084. 11 failed to send the request
  1085. 12 failed to read the response
  1086. 13 bad authentication response
  1087. 14 incomplete authentication palette info
  1088. 15 not inited yet
  1089. 16 failed to create a thread
  1090. 17 authentication package rejected
  1091. 18 void authentication data
  1092. 19 bad authentication package
  1093. 20 certificate expired 21 invalid certificate
  1094. */
  1095. #define NAMA_ERROR_BITMASK_AUTHENTICATION 0xff
  1096. #define NAMA_ERROR_BITMASK_DEBUG_ITEM 0x100
  1097. #define NAMA_ERROR_SEED_RNG_FAILURE 1
  1098. #define NAMA_ERROR_PARSE_CA_CERT_FAILURE 2
  1099. #define NAMA_ERROR_CONNECT_SERVER_FAILURE 3
  1100. #define NAMA_ERROR_CONFIG_TLS_FAILURE 4
  1101. #define NAMA_ERROR_PARSE_CLIENT_CERT_FAILURE 5
  1102. #define NAMA_ERROR_PARSE_CLIENT_KEY_FAILURE 6
  1103. #define NAMA_ERROR_SETUP_TLS_FAILURE 7
  1104. #define NAMA_ERROR_SETUP_SERVER_FAILURE 8
  1105. #define NAMA_ERROR_TLS_HANDSHAKE_FAILURE 9
  1106. #define NAMA_ERROR_TLS_VERIFICATION_FAILURE 10
  1107. #define NAMA_ERROR_SEND_REQUEST_FAILURE 11
  1108. #define NAMA_ERROR_READ_RESPONSE_FAILURE 12
  1109. #define NAMA_ERROR_BAD_RESPONSE 13
  1110. #define NAMA_ERROR_INCOMPLETE_PALETTE_INFO 14
  1111. #define NAMA_ERROR_AUTH_NOT_INITED 15
  1112. #define NAMA_ERROR_CREATE_THREAD_FAILURE 16
  1113. #define NAMA_ERROR_AUTH_PACKAGE_REJECTED 17
  1114. #define NAMA_ERROR_VOID_AUTH_DATA 18
  1115. #define NAMA_ERROR_BAD_AUTH_PACKAGE 19
  1116. #define NAMA_ERROR_CERTIFICATE_EXPIRED 20
  1117. #define NAMA_ERROR_INVALID_CERTIFICATE 21
  1118. #define NAMA_ERROR_PARSE_SYSTEM_DATA_FAILURE 22
  1119. FUNAMA_API int fuGetSystemError();
  1120. /**
  1121. \brief Interpret system error code
  1122. \param code - System error code returned by fuGetSystemError()
  1123. \return One error message from the code
  1124. */
  1125. FUNAMA_API const char* fuGetSystemErrorString(int code);
  1126. /**
  1127. \brief Turn on or turn off Tongue Tracking, used in trackface.
  1128. \param enable > 0 means turning on, enable <= 0 means turning off
  1129. */
  1130. FUNAMA_API int fuSetTongueTracking(int i);
  1131. /**
  1132. \brief Turn on or turn off multisample anti-alising, msaa has an impact on
  1133. performance.
  1134. \param samples > 0 means turning on, samples <= 0 means turning off, 0 by
  1135. default. samples<=GL_MAX_SAMPLES(usually 4).
  1136. */
  1137. FUNAMA_API int fuSetMultiSamples(int samples);
  1138. /**
  1139. \brief Load Tongue Detector data, to support tongue animation.
  1140. \param data - the pointer to tongue model data 'tongue.bundle',
  1141. which is along beside lib files in SDK package
  1142. \param sz - the data size, we use plain int to avoid cross-language compilation
  1143. issues
  1144. \return zero for failure, one for success
  1145. */
  1146. FUNAMA_API int fuLoadTongueModel(void* data, int sz);
  1147. /**
  1148. \warning deprecated api.
  1149. */
  1150. FUNAMA_API void fuSetStrictTracking(int i);
  1151. /**
  1152. \brief Get the current rotationMode.
  1153. \return the current rotationMode, one of 0..3 should work.
  1154. */
  1155. FUNAMA_API int fuGetCurrentRotationMode();
  1156. /**
  1157. \brief Get certificate permission code for modules
  1158. \param i - get i-th code, currently available for 0 and 1
  1159. \return The permission code
  1160. */
  1161. FUNAMA_API int fuGetModuleCode(int i);
  1162. /**
  1163. \brief the same as fuIsTracking
  1164. */
  1165. FUNAMA_API int fuHasFace();
  1166. /**
  1167. \warning deprecated api.
  1168. */
  1169. FUNAMA_API int fuSetASYNCTrackFace(int i);
  1170. /**
  1171. \brief Clear Physics World
  1172. \return 0 means physics disabled and no need to clear,1 means cleared
  1173. successfully
  1174. */
  1175. FUNAMA_API int fuClearPhysics();
  1176. /**
  1177. \warning depreated api
  1178. */
  1179. FUNAMA_API int fuSetFaceDetParam(void* name, void* pinput);
  1180. /**
  1181. \warning depreated api
  1182. */
  1183. FUNAMA_API int fuSetFaceTrackParam(void* name, void* pinput);
  1184. /**
  1185. \brief Get SDK version string, Major.Minor.Fix_ID
  1186. \return SDK version string in const char*
  1187. */
  1188. FUNAMA_API const char* fuGetVersion();
  1189. /**
  1190. \brief Get SDK commit time string
  1191. \return SDK commit time string in const char*
  1192. */
  1193. FUNAMA_API const char* fuGetCommitTime();
  1194. /**
  1195. \brief Load AI model data, to support tongue animation.
  1196. \param data - the pointer to AI model data 'ai_xxx.bundle',which is along
  1197. beside lib files in SDK package
  1198. \param sz - the data size, we use plain int to avoid cross-language compilation
  1199. issues
  1200. \param type - define in FUAITYPE enumeration.
  1201. \return zero for failure, one for success.
  1202. */
  1203. FUNAMA_API int fuLoadAIModelFromPackage(void* data, int sz, FUAITYPE type);
  1204. /**
  1205. \brief Preprocess AI model.
  1206. \param data - the pointer to AI model data 'ai_xxx.bundle',which is along
  1207. beside lib files in SDK package
  1208. \param sz - the data size, we use plain int to avoid cross-language compilation
  1209. issues
  1210. \param type - define in FUAITYPE enumeration.
  1211. \return zero for failure, one for success.
  1212. */
  1213. FUNAMA_API int fuPreprocessAIModelFromPackage(void* data, int sz,
  1214. FUAITYPE type);
  1215. /**
  1216. \brief Release AI Model, when no more need some type of AI albility.
  1217. \param type - define in FUAITYPE enumeration.
  1218. \return zero for failure, one for success.
  1219. */
  1220. FUNAMA_API int fuReleaseAIModel(FUAITYPE type);
  1221. /**
  1222. \brief Get AI Model load status
  1223. \param type - define in FUAITYPE enumeration.
  1224. \return zero for unloaded, one for loaded.
  1225. */
  1226. FUNAMA_API int fuIsAIModelLoaded(FUAITYPE type);
  1227. /**
  1228. \brief Render a list of items on top of a GLES texture or a memory buffer.
  1229. This function needs a GLES 2.0+ context.
  1230. \param texid specifies a GLES texture. Set it to 0u if you want to render to a
  1231. memory buffer.
  1232. \param img specifies a memory buffer. Set it to NULL if you want
  1233. to render to a texture. If img is non-NULL, it will be overwritten by the
  1234. rendered image when fuRenderItems returns
  1235. \param w specifies the image width
  1236. \param h specifies the image height
  1237. \param frameid specifies the current frame id.
  1238. To get animated effects, please increase frame_id by 1 whenever you call
  1239. this.
  1240. \param p_items points to the list of items
  1241. \param n_items is the number of items
  1242. \return a new GLES texture containing the rendered image in the texture
  1243. mode
  1244. */
  1245. FUNAMA_API int fuRenderItems(int texid, int* img, int w, int h, int frame_id,
  1246. int* p_items, int n_items);
  1247. /**
  1248. \brief set crop state.
  1249. \param state is the Cropped switch
  1250. \return zero for closed, one for open
  1251. */
  1252. FUNAMA_API int fuSetCropState(int state);
  1253. /**
  1254. \brief Set the coordinates of the crop.
  1255. \param (x0,y0) is the coordinates of the starting point after cropping. (x0,y0)
  1256. is (0,0) befor cropping \param (x1,y1) is the coordinate of the end point after
  1257. cropping. (x1,y1) is (imageWideth, imageHeight) before cropping \return zero for
  1258. failure, one for success
  1259. */
  1260. FUNAMA_API int fuSetCropFreePixel(int x0, int y0, int x1, int y1);
  1261. /**
  1262. \brief Count API calls.
  1263. \param name is the API name
  1264. */
  1265. FUNAMA_API int fuAuthCountWithAPIName(char* name);
  1266. FUNAMA_API void fuHexagonInitWithPath(const char* lib_directory_path);
  1267. FUNAMA_API void fuHexagonTearDown();
  1268. /**
  1269. \brief set if use pixel buffer to speed up reading pixel from buffer.
  1270. \param use,set use or not use.
  1271. */
  1272. FUNAMA_API int fuSetUsePbo(bool use);
  1273. /**
  1274. \brief set Set texture loading quality
  1275. \param quality, 0:high 1:medium 2.low
  1276. */
  1277. FUNAMA_API int fuSetLoadQuality(int quality);
  1278. /**
  1279. \brief set if use the output texture for async reading, when use spcified
  1280. framebuffer for output. \param use,set 1 for use or 0 for not use, not use by
  1281. default for performance.
  1282. */
  1283. FUNAMA_API int fuSetUseTexAsync(bool use);
  1284. /**
  1285. \brief set if force use gl 2.
  1286. \param use,set 1 for use or 0 for not use.
  1287. */
  1288. FUNAMA_API int fuSetForceUseGL2(int use);
  1289. /**
  1290. * \brief HandGestureCallBack,callback with first handgesture type.
  1291. * \param type, ref to FUAIGESTURETYPE
  1292. */
  1293. typedef void (*HandGestureCallBack)(int type);
  1294. /**
  1295. * \brief set callback for handgesture detection.
  1296. * \param onHandGestureListener,
  1297. * callback. will override the older one, null for reset callback.
  1298. * \note this callback will be called with the first hand's type, you should
  1299. * use fuHandDetectorGetResultNumHands and fuHandDetectorGetResultGestureType
  1300. * for all info.
  1301. * \note this callback will be called when calling Render* interface. when use
  1302. * fuTrackFace*, you should use fuHandDetectorGetResultNumHands and
  1303. * fuHandDetectorGetResultGestureType for all info.
  1304. */
  1305. FUNAMA_API void fuSetHandGestureCallBack(HandGestureCallBack cb);
  1306. /**
  1307. * \brief ItemCallBack,callback.
  1308. * \param handle, ref to handle for triggered item.
  1309. * \param type, ref to FUITEMTRIGGERTYPE.
  1310. */
  1311. typedef void (*ItemCallBack)(int handle, int type);
  1312. /**
  1313. * \brief set callback for item.
  1314. * \param item,
  1315. * handle for time
  1316. * \param cb,
  1317. * callback. will override the older one, null for reset callback.
  1318. * \note this callback will be called when calling Render* interface.
  1319. */
  1320. FUNAMA_API int fuSetItemCallBack(int handle, ItemCallBack cb);
  1321. /**
  1322. * \brief prepare GL resource for a list of items in advance
  1323. * This function needs a GLES 2.0+ context.
  1324. * \param p_items, points to the list of items
  1325. * \param n_items, is the number of items
  1326. */
  1327. FUNAMA_API void fuPrepareGLResource(int* p_items, int n_items);
  1328. /**
  1329. \brief check prepare gl resource is ready.
  1330. This function needs a GLES 2.0+ context.
  1331. \param output, 1 for ready prepared, 0 false, -1 load program binary failed
  1332. */
  1333. FUNAMA_API int fuIsGLPrepared(int* p_items, int n_items);
  1334. FUNAMA_API int fuGetFaceTransferTexID();
  1335. /**
  1336. * \brief set use async ai inference.
  1337. * \param use_async,
  1338. * ture or false.
  1339. */
  1340. FUNAMA_API int fuSetUseAsyncAIInference(int use_async);
  1341. /**
  1342. * \brief set use multi buffer.
  1343. * \param use_multi_gpu_textuer,
  1344. * ture or false.
  1345. * \param use_multi_cpu_buffer,
  1346. * ture or false.
  1347. */
  1348. FUNAMA_API int fuSetUseMultiBuffer(int use_multi_gpu_textuer,
  1349. int use_multi_cpu_buffer);
  1350. /**
  1351. \brief check gl error
  1352. \return OpenGL error information, 0 for no error
  1353. */
  1354. FUNAMA_API int fuCheckGLError();
  1355. /**
  1356. FaceProcessor related api
  1357. */
  1358. /**
  1359. \brief Set tracking fov for ai model FaceProcessor.
  1360. */
  1361. FUNAMA_API int fuSetFaceProcessorFov(float fov);
  1362. /**
  1363. \brief Get tracking fov of ai model FaceProcessor.
  1364. */
  1365. FUNAMA_API float fuGetFaceProcessorFov();
  1366. /**
  1367. \brief set faceprocessor's face detect mode. when use 1 for video mode, face
  1368. detect strategy is opimized for no face scenario. In image process scenario,
  1369. you should set detect mode into 0 image mode.
  1370. \param mode, 0 for image, 1 for video, 1 by default
  1371. */
  1372. FUNAMA_API int fuSetFaceProcessorDetectMode(int mode);
  1373. /**
  1374. \brief set ai model FaceProcessor's minium track face size.
  1375. \param ratio, ratio with min(w,h).
  1376. */
  1377. FUNAMA_API void fuFaceProcessorSetMinFaceRatio(float ratio);
  1378. /**
  1379. \brief set ai model FaceProcessor's landmark quality.
  1380. \param quality, landmark quality, 0 for low quality, 1 for mediem, 2 for high
  1381. quality. 1 by default.
  1382. */
  1383. FUNAMA_API void fuFaceProcessorSetFaceLandmarkQuality(int quality);
  1384. /**
  1385. \brief set ai model FaceProcessor's detector mode.
  1386. \param use, 0 for disable detect small face, 1 for enable detect small face
  1387. */
  1388. FUNAMA_API void fuFaceProcessorSetDetectSmallFace(int use);
  1389. /**
  1390. \brief set ai model FaceProcessor use capture eye look camera.
  1391. \param use, 0 for disable, 1 for enable
  1392. \return zero for failed, one for success
  1393. */
  1394. FUNAMA_API int fuFaceProcessorSetUseCaptureEyeLookCam(int use);
  1395. /**
  1396. \brief get ai model FaceProcessor's tracking hair mask with index.
  1397. \param index, index of fuFaceProcessorGetNumResults.
  1398. \param mask_width, width of return.
  1399. \param mask_height, height of return.
  1400. \return mask data.
  1401. */
  1402. FUNAMA_API const float* fuFaceProcessorGetResultHairMask(int index,
  1403. int* mask_width,
  1404. int* mask_height);
  1405. /**
  1406. \brief get ai model FaceProcessor's tracking head mask with index.
  1407. \param index, index of fuFaceProcessorGetNumResults.
  1408. \param mask_width, width of return.
  1409. \param mask_height, height of return.
  1410. \return mask data.
  1411. */
  1412. FUNAMA_API const float* fuFaceProcessorGetResultHeadMask(int index,
  1413. int* mask_width,
  1414. int* mask_height);
  1415. /**
  1416. \brief get ai model FaceProcessor's tracking face occlusion.
  1417. \param index, index of fuFaceProcessorGetNumResults.
  1418. \return zero for no occlusion, one for occlusion, minus one for no tracked face
  1419. */
  1420. FUNAMA_API int fuFaceProcessorGetResultFaceOcclusion(int index);
  1421. /**
  1422. \brief get ai model FaceProcessor's face detection confidence score.
  1423. \param index, index of fuFaceProcessorGetNumResults.
  1424. \return face detection confidence score.
  1425. */
  1426. FUNAMA_API float fuFaceProcessorGetConfidenceScore(int index);
  1427. /**
  1428. \brief get ai model FaceProcessor's tracking face count.
  1429. \return num of faces.
  1430. */
  1431. FUNAMA_API int fuFaceProcessorGetNumResults();
  1432. /**
  1433. HumanProcessor related api
  1434. */
  1435. /**
  1436. \brief set humanprocessor's human detect mode. when use 1 for video mode, human
  1437. detect strategy is opimized for no human scenario. In image process scenario,
  1438. you should set detect mode into 0 image mode.
  1439. \param mode, 0 for image, 1 for video, 1 by default
  1440. */
  1441. FUNAMA_API int fuSetHumanProcessorDetectMode(int mode);
  1442. /**
  1443. \brief Reset ai model HumanProcessor's tracking state.
  1444. */
  1445. FUNAMA_API void fuHumanProcessorReset();
  1446. /**
  1447. \brief set ai model HumanProcessor's maxinum tracking people.
  1448. */
  1449. FUNAMA_API void fuHumanProcessorSetMaxHumans(int max_humans);
  1450. /**
  1451. \param n_buffer_frames(default 5 and > 0): filter buffer frames.
  1452. \param pos_w(default 0.05 and >= 0): root position filter weight, less pos_w
  1453. -> smoother.
  1454. \param angle_w(default 1.2 and >= 0): joint angle filter weight, less angle_w ->
  1455. smoother.
  1456. */
  1457. FUNAMA_API void fuHumanProcessorSetAvatarAnimFilterParams(int n_buffer_frames,
  1458. float pos_w,
  1459. float angle_w);
  1460. /**
  1461. \brief set ai model HumanProcessor's tracking fov, use to 3d joint projection.
  1462. \param fov.
  1463. */
  1464. FUNAMA_API void fuHumanProcessorSetFov(float fov);
  1465. /**
  1466. \brief get ai model HumanProcessor's tracking fov, use to 3d joint projection.
  1467. \return fov
  1468. */
  1469. FUNAMA_API float fuHumanProcessorGetFov();
  1470. /**
  1471. \brief get ai model HumanProcessor's tracking result.
  1472. \return tracked people number
  1473. */
  1474. FUNAMA_API int fuHumanProcessorGetNumResults();
  1475. /**
  1476. \brief get ai model HumanProcessor's tracking id.
  1477. \param index, index of fuHumanProcessorGetNumResults
  1478. \return tracking id
  1479. */
  1480. FUNAMA_API int fuHumanProcessorGetResultTrackId(int index);
  1481. /**
  1482. \brief get ai model HumanProcessor's tracking human state with id.
  1483. \param index is index of fuHumanProcessorGetNumResults
  1484. \return state, enum of FUAIHUMANSTATE
  1485. */
  1486. FUNAMA_API int fuHumanProcessorGetHumanState(int index);
  1487. /**
  1488. \brief get ai model HumanProcessor's tracking gesture types with id.
  1489. \param index is index of fuHumanProcessorGetNumResults
  1490. \param size, size of return data.
  1491. \return gesture types array, [left hand gesture, right hand gesture], enum of
  1492. FUAIGESTURETYPE
  1493. */
  1494. FUNAMA_API const int* fuHumanProcessorGetGestureTypes(int index, int* size);
  1495. /**
  1496. \brief get ai model HumanProcessor's action type with index.
  1497. \param index, index of fuHumanProcessorGetNumResults
  1498. \return action type
  1499. */
  1500. FUNAMA_API int fuHumanProcessorGetResultActionType(int index);
  1501. /**
  1502. \brief get ai model HumanProcessor's action score with index.
  1503. \param index, index of fuHumanProcessorGetNumResults
  1504. \return score
  1505. */
  1506. FUNAMA_API float fuHumanProcessorGetResultActionScore(int index);
  1507. /**
  1508. \brief get ai model HumanProcessor's tracking rect with index.
  1509. \param index, index of fuHumanProcessorGetNumResults
  1510. \return rect array
  1511. */
  1512. FUNAMA_API const float* fuHumanProcessorGetResultRect(int index);
  1513. /**
  1514. \brief get ai model HumanProcessor's tracking 2d joint with index.
  1515. \param index, index of fuHumanProcessorGetNumResults
  1516. \param size, size of return data.
  1517. */
  1518. FUNAMA_API const float* fuHumanProcessorGetResultJoint2ds(int index, int* size);
  1519. /**
  1520. \brief get ai model HumanProcessor's tracking 3d joint with index.
  1521. \param index, index of fuHumanProcessorGetNumResults
  1522. \param size, size of return data.
  1523. */
  1524. FUNAMA_API const float* fuHumanProcessorGetResultJoint3ds(int index, int* size);
  1525. /**
  1526. \brief get ai model HumanProcessor's pof2d joint with index.(The joint2ds
  1527. generated by human driver). \param index, index of
  1528. fuHumanProcessorGetNumResults \param size, size of return data.
  1529. */
  1530. FUNAMA_API const float* fuHumanProcessorGetResultPofJoint2ds(int index,
  1531. int* size);
  1532. /**
  1533. \brief get ai model HumanProcessor's pof2d joint scores with index. (The
  1534. joint2ds generated by human driver). \param index, index of
  1535. fuHumanProcessorGetNumResults \param size, size of return data.
  1536. */
  1537. FUNAMA_API const float* fuHumanProcessorGetResultPofJointScores(int index,
  1538. int* size);
  1539. /**
  1540. \brief enable model HumanProcessor's BVH motion frame output.
  1541. \param enable: (default is true).
  1542. */
  1543. FUNAMA_API void fuHumanProcessorSetEnableBVHOutput(bool enable);
  1544. /**
  1545. \brief set the inplane rotation of model HumanProcessor's BVH output.
  1546. \param inplane_rot: inplane counter-clock-wise rotation type.
  1547. */
  1548. FUNAMA_API void fuHumanProcessorSetBVHInPlaneRotation(
  1549. FUAIHUMANROTTYPE inplane_rot);
  1550. /**
  1551. \brief set the inplane mirror type of model HumanProcessor's BVH output.
  1552. \param inplane_mirror_type: inplane mirror type.
  1553. */
  1554. FUNAMA_API void fuHumanProcessorSetBVHInPlaneMirrorType(
  1555. FUAIHUMANMIRRORTYPE inplane_mirror_type);
  1556. /**
  1557. \brief get model HumanProcessor's BVH motiont frame output.
  1558. \param index: index of fuHumanProcessorGetNumResults
  1559. \param size: size of return data.
  1560. */
  1561. FUNAMA_API const float* fuHumanProcessorGetResultBVHMotionFrameOutput(
  1562. int index, int* size);
  1563. /**
  1564. \brief get ai model HumanProcessor's tracking full body mask with index.
  1565. \param index, index of fuHumanProcessorGetNumResults.
  1566. \param mask_width, width of return.
  1567. \param mask_height, height of return.
  1568. \return mask data.
  1569. */
  1570. FUNAMA_API const float* fuHumanProcessorGetResultHumanMask(int index,
  1571. int* mask_width,
  1572. int* mask_height);
  1573. /**
  1574. \brief calculate action distance.
  1575. \return score of distance, range [0,1], 1 for fully match.
  1576. */
  1577. FUNAMA_API float fuHumanActionMatchDistance(const float* src_pose, int sz_src,
  1578. const float* ref_pose, int sz_ref);
  1579. /**
  1580. \brief calculate action distance with left and right.
  1581. \return score of distance, range [0,1], 1 for fully match.
  1582. */
  1583. FUNAMA_API float fuHumanActionMatchLeftRightHandDistance(const float* src_pose,
  1584. int sz_src,
  1585. const float* ref_pose,
  1586. int sz_ref,
  1587. bool mirror);
  1588. /**
  1589. \brief get hand detector's tracking results.
  1590. \return num of hand tracked.
  1591. */
  1592. FUNAMA_API int fuHandDetectorGetResultNumHands();
  1593. /**
  1594. \brief get hand detector's tracking rect with index.
  1595. \param index ,index of fuHandDetectorGetResultNumHands.
  1596. \return rect data, float array with size 4.
  1597. */
  1598. FUNAMA_API const float* fuHandDetectorGetResultHandRect(int index);
  1599. /**
  1600. \brief get hand detector's tracking hand gesture type with index.
  1601. \param index ,index of fuHandDetectorGetResultNumHands.
  1602. \return gesture type, ref to FUAIGESTURETYPE.
  1603. */
  1604. FUNAMA_API FUAIGESTURETYPE fuHandDetectorGetResultGestureType(int index);
  1605. /**
  1606. \brief get hand detector's tracking hand gesture score with index.
  1607. \param index ,index of fuHandDetectorGetResultNumHands.
  1608. \return gesture score, range [0,1]
  1609. */
  1610. FUNAMA_API float fuHandDetectorGetResultHandScore(int index);
  1611. FUNAMA_API void fuSetOutputImageSize(int w, int h);
  1612. FUNAMA_API void fuSetCacheDirectory(const char* dir);
  1613. /**
  1614. \brief cache data manually.
  1615. */
  1616. FUNAMA_API void fuRunCache();
  1617. /**
  1618. \brief record current memory usage. this interface works on android for now.
  1619. The device must root and run corrspond monitor process.
  1620. \return zero for failure, one for success
  1621. */
  1622. FUNAMA_API int fuRecordMemoryUsage(const char* tag);
  1623. /**
  1624. \brief when application pause calling fuRender, call
  1625. fuSetRenderPauseState(true) to pause the internal physis update.
  1626. \param pause ,pause state, if true SDK will pause physis update, and will be
  1627. turn on in next fuRender call automatically.
  1628. */
  1629. FUNAMA_API void fuSetRenderPauseState(bool pause);
  1630. /**
  1631. \brief internal api for profile
  1632. */
  1633. FUNAMA_API int fuProfileGetNumTimers();
  1634. FUNAMA_API const char* fuProfileGetTimerName(int index);
  1635. FUNAMA_API long long fuProfileGetTimerAverage(int index);
  1636. FUNAMA_API long long fuProfileGetTimerCount(int index);
  1637. FUNAMA_API long long fuProfileGetTimerMin(int index);
  1638. FUNAMA_API long long fuProfileGetTimerMax(int index);
  1639. FUNAMA_API int fuProfileResetAllTimers();
  1640. FUNAMA_API void fuSetForcePortraitMode(int mode);
  1641. // in_format 0->RGB 1->RGBA
  1642. FUNAMA_API void fuImageBeautyResetPic(void* in_ptr, int w, int h, int format,
  1643. void* out_ptr, int out_w, int out_h);
  1644. FUNAMA_API void fuImageBeautyNewPic();
  1645. FUNAMA_API void fuSetFaceDelayLeaveFrameNum(int frame_num);
  1646. FUNAMA_API void fuSetFaceDelayLeaveEnable(bool use);
  1647. FUNAMA_API void fuSetHumanSegScene(FUAIHUMANSEGSCENETYPE seg_scene);
  1648. FUNAMA_API void fuSetHandDetectEveryNFramesWhenNoHand(int frame_num);
  1649. #ifdef __cplusplus
  1650. }
  1651. #endif
  1652. #endif // !CNAMASDK_H