zhangzengfei
2021-01-05 79e9891452ca13f5a556cabd5c4b200aa7f666cd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#ifndef THFACEIMAGE_I_H
#define THFACEIMAGE_I_H
 
#include "FiStdDefEx.h"
 
/*
* ============================================================================
*  Name     : THFaceImage_i.h
*  Part of  : Face Recognition (THFaceImage) SDK
*  Created  : 9.1.2016 by XXX
*  Description:
*     THFaceImage_i.h -  Face Recognition (THFaceImage) SDK header file
*  Version  : 4.0.0
*  Copyright: All Rights Reserved by XXXX
*  Revision:
* ============================================================================
*/
 
#define THFACEIMAGE_API extern "C" __attribute__((visibility ("default")))
 
//////Struct define//////
 
struct FaceAngle
{
    int   yaw;//angle of yaw,from -90 to +90,left is negative,right is postive
    int   pitch;//angle of pitch,from -90 to +90,up is negative,down is postive
    int   roll;//angle of roll,from -90 to +90,left is negative,right is postive
    float confidence;//confidence of face pose(from 0 to 1,0.6 is suggested threshold)
};
 
struct THFI_FacePos
{
    RECT        rcFace;//coordinate of face
       POINT        ptLeftEye;//coordinate of left eye
    POINT        ptRightEye;//coordinate of right eye
    POINT        ptMouth;//coordinate of mouth
    POINT        ptNose;//coordinate of nose                                
    FaceAngle    fAngle;//value of face angle
    int            nQuality;//quality of face(from 0 to 100)
    BYTE           pFacialData[512];//facial data
    THFI_FacePos()
    {
        memset(&rcFace,0,sizeof(RECT));
        memset(&ptLeftEye,0,sizeof(POINT));
        memset(&ptRightEye,0,sizeof(POINT));
        memset(&ptMouth,0,sizeof(POINT));
        memset(&ptNose,0,sizeof(POINT));
        memset(&fAngle,0,sizeof(FaceAngle));
        nQuality=0;
        memset(pFacialData, 0, 512);
    }
};
 
typedef long long DWORD_PTR;
struct THFI_Param
{
    int nMinFaceSize;//min face width size can be detected,default is 50 pixels
    int nRollAngle;//max face roll angle,default is 30(degree)
    bool bOnlyDetect;//ingored
    DWORD_PTR dwReserved;//reserved value,must be NULL
    THFI_Param()
    {
        nMinFaceSize=50;
        nRollAngle=30;
        bOnlyDetect=false;
        dwReserved=NULL;
    }
};
 
 
//////API define//////
THFACEIMAGE_API void THFI_SetDir(const char* modelDir, const char* tmpDir);
/*
 The THFI_SetDir function will set face detection environment directory,it must be called before THFI_Create
 Parameters:
    modelDir[input],´æ·Å libTHDetect_dpbin.soÎļþµÄĿ¼£¬Èç¹ûmodelDirΪNULL£¬ÔòʹÓÃĬÈÏ·¾¶¡°/mnt/sdcard/SysConfig/model/¡±
    tmpDir[input],ÁÙʱ¶ÁдĿ¼£¬¹©Ëã·¨³õʼ»¯Ê¹Óã¬Ëã·¨±ØÐë¾ßÓÐÁÙʱĿ¼ÏµĶÁдȨÏÞ,Èç¹ûtmpDirΪNULL£¬ÔòʹÓÃĬÈÏ·¾¶¡°"/mnt/sdcard/SysConfig/tmp/"¡±            
 Return Values:
    No return value.
 Remarks£º         
    It must be called before THFI_Create.
*/
 
THFACEIMAGE_API int        THFI_Create(short nChannelNum,THFI_Param* pParam=NULL);
/*
 The THFI_Create function will initialize the algorithm engine module
 
 Parameters:
    nChannelNum[intput],algorithm channel num,for multi-thread mode,one thread uses one channel
    pParam[input],algorithm engine parameter.
 Return Values:
    If the function succeeds, the return value is valid channel number.
    If the function fails, the return value is zero or negative;
    error code:
        -99,invalid license.
 Remarks: 
    This function only can be called one time at program initialization.
*/
 
THFACEIMAGE_API int        THFI_DetectFace(short nChannelID, BYTE* pImage, int bpp, int nWidth, int nHeight, THFI_FacePos* pfps, int nMaxFaceNums, int nSampleSize=360);
/*
 The THFI_DetectFace function execute face detection only.
 
 Parameters:
    nChannelID[input],channel ID(from 0 to nChannelNum-1)
    pImage[input],image data buffer,bgr format.
    bpp[input],bits per pixel(24-bgr image),must be 24
    nWidth[input],image width.
    nHeight[input],image height.
    pfps[output],the facial position information.
    nMaxFaceNums[input],max face nums that you want
    nSampleSize[input],down sample size(image down sample) for detect image,if it is 0,will detect by original image.
 Return Values:
    If the function succeeds, the return value is face number.
    If the function fails, the return value is negative.
    error code:
        -99,invalid license.
        -1,nChannelID is invalid or SDK is not initialized
        -2,image data is invalid,please check function parameter:pImage,bpp,nWidth,nHeight
        -3,pfps or nMaxFaceNums is invalid.
 Remarks:
    1.image data buffer(pImage)    size must be nWidth*(bpp/8)*nHeight.
    2.pfps must be allocated by caller,the memory size is nMaxFaceNums*sizeof(THFI_FacePos).
    3.if image has face(s),face number less than or equal to nMaxFaceNums
*/
 
THFACEIMAGE_API int THFI_DetectFaceByEye(short nChannelID, BYTE* pImage, int nWidth, int nHeight, POINT ptLeft, POINT ptRight, THFI_FacePos* pfps);
/*
The THFI_DetectFaceByEye function detect facial data by eye position
 
Parameters:
    pImage[input],image data buffer,bgr format,pImage data size must be nWidth*nHeight*3 bytes
    nWidth[input],image width.
    nHeight[input],image height.
    ptLeft[input],left eye position
    ptRight[input],right eye position
    pfps[output],the facial position information.
Return Values:
    If the function succeeds, the return value is 1.
    If the function fails, the return value is negative.
    error code:
        -99,invalid license.
        -1,nChannelID is invalid or SDK is not initialize
        -2,image data is invalid,please check function parameter:pImage,bpp,nWidth,nHeight
        -3,pfps is invalid.
*/
 
THFACEIMAGE_API void    THFI_Release();
/*
 The THFI_Release function will release the algorithm engine module
 
 Parameters:
    No parameter.
 Return Values:
    No return value.
 Remarks:
    This function only can be called one time at program exit.
*/
 
THFACEIMAGE_API int        THFI_Create_Ex(short nChannelNum, int omp_thread_num=1);
/*
The THFI_Create_Ex function will initialize the algorithm engine module with openmp thread num
 
Parameters:
    nChannelNum[intput],algorithm channel num,for multi-thread mode,one thread uses one channel
    omp_thread_num[input],thread num for openmp
Return Values:
    If the function succeeds, the return value is valid channel number.
    If the function fails, the return value is zero or negative;
error code:
    -99,invalid license.
Remarks:
    This function only can be called one time at program initialization.
*/
 
THFACEIMAGE_API int    THFI_DetectFaceOnly(short nChannelID, BYTE* pImage, int bpp, int nWidth, int nHeight, RECT* pFaces, int nMaxFaceNums, int nSampleSize = 360);
/*
 The THFI_DetectFaceOnly function execute face detection only.
 
 Parameters:
    nChannelID[input],channel ID(from 0 to nChannelNum-1)
    pImage[input],image data buffer,bgr format.
    bpp[input],bits per pixel(24-bgr image),must be 24
    nWidth[input],image width.
    nHeight[input],image height.
    pFaces[output],the face rectangle
    nMaxFaceNums[input],max face nums that you want
    nSampleSize[input],down sample size(image down sample) for detect image,if it is 0,will detect by original image.
 Return Values:
    If the function succeeds, the return value is face number.
    If the function fails, the return value is negative.
    error code:
        -99,invalid license.
        -1,nChannelID is invalid or SDK is not initialized
        -2,image data is invalid,please check function parameter:pImage,bpp,nWidth,nHeight
        -3,pFaces or nMaxFaceNums is invalid.
 Remarks:
    1.image data buffer(pImage)    size must be nWidth*(bpp/8)*nHeight.
    2.pFaces must be allocated by caller,the memory size is nMaxFaceNums*sizeof(RECT).
    3.if image has face(s),face number less than or equal to nMaxFaceNums
*/
 
THFACEIMAGE_API int    THFI_DetectLandmark(short nChannelID, BYTE* pImage, int bpp, int nWidth, int nHeight, RECT rcFace, THFI_FacePos* pfp);
/*
 The THFI_DetectLandmark function execute face landmark.
 
 Parameters:
    nChannelID[input],channel ID(from 0 to nChannelNum-1)
    pImage[input],image data buffer,bgr format.
    bpp[input],bits per pixel(24-bgr image),must be 24
    nWidth[input],image width.
    nHeight[input],image height.
    rcFace[input],the face rectangle
    pfp[output],the facial position information of landmrk
 Return Values:
    If the function succeeds, the return value is 1.
    If the function fails, the return value is negative.
    error code:
        -99,invalid license.
        -1,nChannelID is invalid or SDK is not initialized
        -2,image data is invalid,please check function parameter:pImage,bpp,nWidth,nHeight
        -3,pfp is NULL.
 Remarks:
    1.image data buffer(pImage)    size must be nWidth*(bpp/8)*nHeight.
*/
 
THFACEIMAGE_API int        THFI_Create_Allin(short nChannelNum,int cpu_mode=0,int omp_thread_num=1,int using_gpu=0);
/*
ÃèÊö£º³õʼ»¯ÈËÁ³¼ì²âÄ£¿é£¬½¨ÒéÔÚÓ¦ÓóÌÐò³õʼ»¯Ê±µ÷ÓÃÒ»´Î
²ÎÊý£º
    nChannelNum[intput],Ë㷨ͨµÀÊý£¬Ò»¸öÏß³ÌʹÓÃÒ»¸öͨµÀ
    cpu_mode[input],CPUʹÓÃģʽ£º0-´óСºË£¬1-½öСºË£¬2-½ö´óºË
    omp_thread_num[input],²¢ÐмÆËãʱµÄÏß³ÌÊý£¬½¨ÒéСÓÚʵ¼ÊÆôÓõÄCPUºËÐÄÊý
    using_gpu[input],ÆôÓÃGPU¼ÆË㣺0-²»ÆôÓÃGPU¼ÆË㣬1-ÆôÓÃGPU¼ÆËã¡£CPU°æ±¾¿âÖиòÎÊýºöÂÔ£¬Ö»ÓÐÔÚGPU°æ±¾¿â²ÅÓÐЧ
·µ»ØÖµ£º
    ´óÓÚ0Ϊ³É¹¦³õʼ»¯µÄͨµÀÊý£¬Ð¡ÓÚµÈÓÚ0Ϊ¼ÓÔØÄ£ÐÍʧ°Ü
*/
 
#endif