DFace SDK  2.0.0
LTM
symbol.h
1 //
2 // Created by asy on 10/20/18.
3 //
4 
5 #ifndef DFACE_SYMBOL_H
6 #define DFACE_SYMBOL_H
7 
8 #include "dface_detect.h"
9 #include "dface_pose.h"
10 #include "dface_compare.h"
11 #include "dface_recognize.h"
12 #include "dface_infrared.h"
13 #include "dface_rgb_anti.h"
14 #include "dface_track.h"
15 #include "exception/dface_general_exception.h"
16 #ifdef _WIN32
17 #include <Windows.h>
18 #else
19 #include <dlfcn.h>
20 #endif
21 
22 #ifdef _WIN32
23 //加载动态库
24 static HMODULE handle = LoadLibraryEx("libdface.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
25 #else
26 //加载动态库
27 static void *handle = dlopen("libdfacepro.so", RTLD_LAZY);
28 #endif
29 
30 
34 inline dface::DfaceDetect* load_dface_detect(){
35 #ifdef _WIN32
36  if (handle == NULL)
37  {
38  throw "libdfacepro.dll library failed to load";
39  }
40  //获得人脸检测工厂函数
41  dface::CreateDetect* createDetect = (dface::CreateDetect*)GetProcAddress(handle, "create_detect");
42  if (createDetect == NULL) {
43  throw "DfaceDetect failed to create";
44  }
45 #else
46  if (!handle)
47  {
48  throw "libdfacepro.so library failed to load";
49  }
50  //获得人脸检测工厂函数
51  dface::CreateDetect* createDetect = (dface::CreateDetect*)dlsym(handle, "create_detect");
52  const char* dlsym_error = dlerror();
53  if (dlsym_error) {
54  throw "DfaceDetect failed to create";
55  }
56 #endif
57  return createDetect();
58 }
59 
64 inline void destory_dface_detect(dface::DfaceDetect* p){
65 #ifdef _WIN32
66  //获得人脸检测通道工厂销毁函数
67  dface::DestroyDetect* destroyDetect = (dface::DestroyDetect*)GetProcAddress(handle, "destroy_detect");
68  if (destroyDetect == NULL) {
69  throw "DfaceDetect failed to destory";
70  }
71 #else
72  //获得人脸检测通道工厂销毁函数
73  dface::DestroyDetect* destroyDetect = (dface::DestroyDetect*)dlsym(handle, "destroy_detect");
74  const char* dlsym_error = dlerror();
75  if (dlsym_error) {
76  throw "DfaceDetect failed to destory";
77  }
78 #endif
79  //销毁检测通道
80  destroyDetect(p);
81 }
82 
83 
87 inline dface::DfaceRecognize* load_dface_recognize() {
88 #ifdef _WIN32
89  DWORD dwError = 0;
90  if (handle == NULL)
91  {
92  throw "libdfacepro.dll library failed to load";
93  }
94 
95  //获得人脸识别通道工厂函数
96  dface::CreateRecognize* createRecognize = (dface::CreateRecognize*)GetProcAddress(handle, "create_recognize");
97  if (createRecognize == NULL) {
98  throw "DfaceRecognize failed to create";
99  }
100 #else
101  if (!handle)
102  {
103  throw "libdfacepro.so library failed to load";
104  }
105 
106  //获得人脸识别通道工厂函数
107  dface::CreateRecognize* createRecognize = (dface::CreateRecognize*)dlsym(handle, "create_recognize");
108  const char* dlsym_error = dlerror();
109  if (dlsym_error) {
110  throw "DfaceRecognize failed to create";
111  }
112 
113 #endif
114  return createRecognize();
115 }
116 
117 
121 inline void destory_dface_recognize(dface::DfaceRecognize* p){
122 #ifdef _WIN32
123  //获得人脸识别通道工厂销毁函数
124  dface::DestroyRecognize* destroyRecognize = (dface::DestroyRecognize*)GetProcAddress(handle, "destroy_recognize");
125  if (destroyRecognize == NULL) {
126  throw "DfaceRecognize failed to destory";
127  }
128 #else
129  //获得人脸检测通道工厂销毁函数
130  dface::DestroyRecognize* destroyRecognize = (dface::DestroyRecognize*)dlsym(handle, "destroy_recognize");
131  char* dlsym_error = dlerror();
132  if (dlsym_error) {
133  throw "DfaceRecognize failed to destory";
134  }
135 #endif
136  destroyRecognize(p);
137 }
138 
139 
143 inline dface::DfaceCompare* load_dface_compare()
144 {
145 #ifdef _WIN32
146  DWORD dwError = 0;
147  //加载动态库
148  if (handle == NULL)
149  {
150  throw "libdfacepro.dll library failed to load";
151  }
152  //获得人脸比对通道工厂函数
153  dface::CreateCompare* createCompare = (dface::CreateCompare*)GetProcAddress(handle, "create_compare");
154  if (createCompare == NULL) {
155  throw "DfaceCompare failed to create";
156  }
157 #else
158  if (!handle)
159  {
160  throw "libdfacepro.so library failed to load";
161  }
162  //获得人脸比对通道工厂函数
163  dface::CreateCompare* createCompare = (dface::CreateCompare *)dlsym(handle, "create_compare");
164  const char* dlsym_error = dlerror();
165  if (dlsym_error) {
166  throw "DfaceCompare failed to create";
167  }
168 #endif
169  return createCompare();
170 }
171 
172 
176 inline void destory_dface_compare(dface::DfaceCompare* p){
177 #ifdef _WIN32
178  //获得人脸比对通道工厂销毁函数
179  dface::DestroyCompare *destroyCompare = (dface::DestroyCompare *)GetProcAddress(handle, "destroy_compare");
180  if (destroyCompare == NULL) {
181  throw "DfaceCompare failed to destory";
182  }
183 #else
184  //获得人脸比对通道工厂销毁函数
185  dface::DestroyCompare *destroyCompare = (dface::DestroyCompare*)dlsym(handle, "destroy_compare");
186  const char* dlsym_error = dlerror();
187  if (dlsym_error) {
188  throw "DfaceCompare failed to destory";
189  }
190 #endif
191  //销毁人脸比对通道
192  destroyCompare(p);
193 }
194 
195 
199 inline dface::DfacePose* load_dface_pose()
200 {
201 #ifdef _WIN32
202  DWORD dwError = 0;
203  //加载动态库
204  if (handle == NULL)
205  {
206  throw "libdfacepro.dll library failed to load";
207  }
208  //获得人脸姿态通道工厂函数
209  dface::CreatePose* createPose = (dface::CreatePose*)GetProcAddress(handle, "create_pose");
210  if (createPose == NULL) {
211  throw "DfacePose failed to create";
212  }
213 #else
214  if (!handle)
215  {
216  throw "libdfacepro.so library failed to load";
217  }
218  //获得人脸姿态通道工厂函数
219  dface::CreatePose * createPose = (dface::CreatePose*)dlsym(handle, "create_pose");
220  const char* dlsym_error = dlerror();
221  if (dlsym_error) {
222  throw "DfacePose failed to create";
223  }
224 #endif
225  return createPose();
226 }
227 
228 
232 inline void destory_dface_pose(dface::DfacePose* p){
233 #ifdef _WIN32
234  //获得人脸比对通道工厂销毁函数
235  dface::DestroyPose *destroyPose = (dface::DestroyPose*)GetProcAddress(handle, "destroy_pose");
236  if (destroyPose == NULL) {
237  throw "DfacePose failed to destory";
238  }
239 #else
240  //获得人脸比对通道工厂销毁函数
241  dface::DestroyPose *destroyPose = (dface::DestroyPose*)dlsym(handle, "destroy_pose");
242  const char* dlsym_error = dlerror();
243  if (dlsym_error) {
244  throw "DfacePose failed to destory";
245  }
246 #endif
247  //销毁人脸比对通道
248  destroyPose(p);
249 }
250 
251 
255 inline dface::DfaceInfrared* load_dface_infrared()
256 {
257 #ifdef _WIN32
258  DWORD dwError = 0;
259  //加载动态库
260  if (handle == NULL)
261  {
262  throw "libdfacepro.dll library failed to load";
263  }
264  //获得红外活体检测通道工厂函数
265  dface::CreateInfrared* createInfrared = (dface::CreateInfrared*)GetProcAddress(handle, "create_infrared");
266  if (createInfrared == NULL) {
267  throw "DfaceInfrared failed to create";
268  }
269 #else
270  if (!handle)
271  {
272  throw "libdfacepro.so library failed to load";
273  }
274  //获得红外活体检测通道工厂函数
275  dface::CreateInfrared * createInfrared = (dface::CreateInfrared*)dlsym(handle, "create_infrared");
276  const char* dlsym_error = dlerror();
277  if (dlsym_error) {
278  throw "DfaceInfrared failed to create";
279  }
280 #endif
281  return createInfrared();
282 }
283 
284 
288 inline void destory_dface_infrared(dface::DfaceInfrared* p){
289 #ifdef _WIN32
290  //获得人脸比对通道工厂销毁函数
291  dface::DestroyInfrared *destroyInfrared = (dface::DestroyInfrared*)GetProcAddress(handle, "destroy_infrared");
292  if (destroyInfrared == NULL) {
293  throw "DfaceInfrared failed to destory";
294  }
295 #else
296  //获得红外活体检测通道工厂销毁函数
297  dface::DestroyInfrared *destroyInfrared = (dface::DestroyInfrared*)dlsym(handle, "destroy_infrared");
298  const char* dlsym_error = dlerror();
299  if (dlsym_error) {
300  throw "DfaceInfrared failed to destory";
301  }
302 #endif
303  //销毁红外活体检测通道
304  destroyInfrared(p);
305 }
306 
307 
311 inline dface::DfaceRgbAnti* load_dface_rgbanti()
312 {
313 #ifdef _WIN32
314  DWORD dwError = 0;
315  //加载动态库
316  if (handle == NULL)
317  {
318  throw "libdfacepro.dll library failed to load";
319  }
320  //获得单目活体认证通道工厂函数
321  dface::CreateRgbAnti* createRgbAnti = (dface::CreateRgbAnti*)GetProcAddress(handle, "create_rgbanti");
322  if (createRgbAnti == NULL) {
323  throw "DfaceRgbAnti failed to create";
324  }
325 #else
326  if (!handle)
327  {
328  throw "libdfacepro.so library failed to load";
329  }
330  //获得单目活体认证通道工厂函数
331  dface::CreateRgbAnti * createRgbAnti = (dface::CreateRgbAnti*)dlsym(handle, "create_rgbanti");
332  const char* dlsym_error = dlerror();
333  if (dlsym_error) {
334  throw "DfaceRgbAnti failed to create";
335  }
336 #endif
337  return createRgbAnti();
338 }
339 
340 
345 inline void destory_dface_rgbanti(dface::DfaceRgbAnti* p){
346 #ifdef _WIN32
347  //获得人脸比对通道工厂销毁函数
348  dface::DestroyRgbAnti *destroyRgbAnti = (dface::DestroyRgbAnti*)GetProcAddress(handle, "destroy_rgbanti");
349  if (destroyRgbAnti == NULL) {
350  throw "DfaceRgbAnti failed to destory";
351  }
352 #else
353  //获得单目活体通道工厂销毁函数
354  dface::DestroyRgbAnti *destroyRgbAnti = (dface::DestroyRgbAnti *)dlsym(handle, "destroy_rgbanti");
355  const char* dlsym_error = dlerror();
356  if (dlsym_error) {
357  throw "DfaceRgbAnti failed to destory";
358  }
359 #endif
360  //销毁单目活体通道
361  destroyRgbAnti(p);
362 }
363 
364 
365 
369 inline dface::DfaceTrack* load_dface_track()
370 {
371 #ifdef _WIN32
372  DWORD dwError = 0;
373  //加载动态库
374  if (handle == NULL)
375  {
376  throw "libdfacepro.dll library failed to load";
377  }
378  //获得人脸跟踪通道工厂函数
379  dface::CreateTrack* createTrack = (dface::CreateTrack*)GetProcAddress(handle, "create_track");
380  if (createTrack == NULL) {
381  throw "DfaceTrack failed to create";
382  }
383 #else
384  if (!handle)
385  {
386  throw "libdfacepro.so library failed to load";
387  }
388  //获得人脸跟踪通道工厂函数
389  dface::CreateTrack * createTrack = (dface::CreateTrack *)dlsym(handle, "create_track");
390  const char* dlsym_error = dlerror();
391  if (dlsym_error) {
392  throw "DfaceTrack failed to create";
393  }
394 #endif
395  return createTrack();
396 }
397 
398 
403 inline void destory_dface_track(dface::DfaceTrack* p){
404 #ifdef _WIN32
405  //获得人脸比对通道工厂销毁函数
406  dface::DestroyTrack *destroyTrack = (dface::DestroyTrack*)GetProcAddress(handle, "destroy_track");
407  if (destroyTrack == NULL) {
408  throw "DestroyTrack failed to destory";
409  }
410 #else
411  //获得人脸跟踪通道工厂销毁函数
412  dface::DestroyTrack *destroyTrack = (dface::DestroyTrack *)dlsym(handle, "destroy_track");
413  const char* dlsym_error = dlerror();
414  if (dlsym_error) {
415  throw "DestroyTrack failed to destory";
416  }
417 #endif
418  //销毁人脸跟踪通道
419  destroyTrack(p);
420 }
421 
422 
423 
424 #endif //DFACE_SYMBOL_H
DFace人脸识别(特征提取)API抽象层(DFaceRecognize)
Definition: dface_recognize.h:41
DFace人脸(物体)跟踪器(DfaceTrack) 基于深度学习的人脸(物体)跟踪器,能够跟踪任意物体 ...
Definition: dface_track.h:40
DFace单目活体认证 最先进的单目活体认证
Definition: dface_rgb_anti.h:25
DFace人脸姿态API抽象层(DFacePose)
Definition: dface_pose.h:40
DFace红外线活体检测API抽象层(DfaceInfrared)
Definition: dface_infrared.h:39
DFace人脸检测API抽象层(DFaceDetect)
Definition: dface_detect.h:39
DFace人脸比对API抽象层(DFaceCompare)
Definition: dface_compare.h:40