Video Analysis底层库拆分,sdk的go封装
zhangmeng
2019-04-29 af1e5a6e8264d5d95dd7b769e7c401b81afc550d
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
#ifndef THFACETRACKING_I_H
#define THFACETRACKING_I_H
 
#include "FiStdDefEx.h"
 
/*
* ============================================================================
*  Name     : THFaceTracking_i.h
*  Part of  : Face Tracking (THFaceTracking) SDK
*  Created  : 11.22.2017 by XXX
*  Description:
*     THFaceTracking_i.h -   Face Tracking (THFaceTracking) SDK header file
*  Version  : 1.0.0
*  Copyright: All Rights Reserved by XXXX
*  Revision:
* ============================================================================
*/
 
struct FacePose
{
    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 THFT_FaceInfo
{
    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                                
    FacePose    fAngle;//value of face angle
    int            nQuality;//quality of face(from 0 to 100)
    BYTE           pFacialData[8*1024];//facial data
 
    long        nFaceID;//face tracking id
 
    THFT_FaceInfo()
    {
        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(FacePose));
        nQuality = 0;
        memset(pFacialData, 0, 8 * 1024);
 
        nFaceID = -1;
    }
};
 
struct THFT_Param
{
    int nDeviceID;//device id for GPU device.eg:0,1,2,3.....
 
    int nImageWidth;//image width of video
    int nImageHeight;//image height of video
    int nMaxFaceNum;//max face number for tracking
    int nSampleSize;//down sample size for face detection
    int nDetectionIntervalFrame;//interval frame number of face detection for face tracking 
 
    THFT_Param()
    {
        nMaxFaceNum = 100;
        nSampleSize = 640;
        nDeviceID = 0;
        nDetectionIntervalFrame = 5;
    }
};
 
#define THFACETRACKING_API extern "C"
 
 
THFACETRACKING_API int    THFT_Create(short nChannelNum,THFT_Param* pParam);
/*
The THFT_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.
*/
 
THFACETRACKING_API void    THFT_Release();
/*
The THFT_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.
*/
 
THFACETRACKING_API int    THFT_FaceTracking(short nChannelID, unsigned char* pBGR,THFT_FaceInfo* pFaceInfos);
/*
 The THFT_FaceTracking function execute face detection and face tracking
 
 Parameters:
    nChannelID[input],channel ID(from 0 to nChannelNum-1)
    pBGR[input],image data buffer,BGR format.
    pFaceInfos[output],the facial position information.
 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:pBGR
        -3,pFaceInfos is invalid.
 Remarks:
    1.image data buffer(pBGR) size must be (THFT_Param::nImageWidth * THFT_Param::nImageHeight * 3)
    2.pFaceInfos must be allocated by caller,the memory size is THFT_Param::nMaxFaceNum*sizeof(THFT_FaceInfo).
    3.if image has face(s),face number less than or equal to THFT_Param::nMaxFaceNums
*/
 
THFACETRACKING_API int    THFT_FaceDetect(short nChannelID, BYTE* pBGR, int nWidth, int nHeight, THFT_FaceInfo* pFaceInfos, int nMaxFaceNums, int nSampleSize);
/*
 The THFT_FaceDetect function execute facial detection for an image
 
 Parameters:
    nChannelID[input],channel ID(from 0 to nChannelNum-1)
    pBGR[input],image data buffer,BGR format.
    nWidth[input],image width.
    nHeight[input],image height.
    pFaceInfos[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:pBGR,nWidth,nHeight
        -3,pFaceInfos or nMaxFaceNums is invalid.
 Remarks:
    1.image data buffer(pBGR) size must be nWidth*nHeight*3.
    2.pFaceInfos must be allocated by caller,the memory size is nMaxFaceNums*sizeof(THFT_FaceInfo).
    3.if image has face(s),face number less than or equal to nMaxFaceNums
*/
 
THFACETRACKING_API int    THFT_FaceOnly(short nChannelID, BYTE* pBGR, int nWidth, int nHeight, RECT* pFaces, int nMaxFaceNums, int nSampleSize);
/*
 The THFT_FaceOnly function execute face rectangle detection only
 
 Parameters:
    nChannelID[input],channel ID(from 0 to nChannelNum-1)
    pBGR[input],image data buffer,BGR format.
    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:pBGR,nWidth,nHeight
        -3,pFaces or nMaxFaceNums is invalid.
 Remarks:
    1.image data buffer(pBGR) size must be nWidth*nHeight*3.
    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
*/
 
 
#endif