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_database.h"
9 #include "./exception/dface_db_exceptio.h"
10 
11 #ifdef _WIN32
12 #include <Windows.h>
13 #else
14 #include <dlfcn.h>
15 #endif
16 
17 #ifdef _WIN32
18 //加载动态库
19 static HMODULE handle = LoadLibraryEx("libdfacedb.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
20 #else
21 //加载动态库
22 static void *handle = dlopen("libdfacedb.so", RTLD_LAZY);
23 #endif
24 
25 
29 inline DfaceDB* load_dface_db(){
30 #ifdef _WIN32
31  if (handle == NULL)
32  {
33  throw "libdfacedb.dll library failed to load";
34  }
35  //获得人脸检测工厂函数
36  CreateDfaceDB* createDfaceDB = (CreateDfaceDB*)GetProcAddress(handle, "create_dfacedb");
37  if (createDfaceDB == NULL) {
38  throw "DfaceDB failed to create";
39  }
40 #else
41  if (!handle)
42  {
43  throw "libdfacedb.so library failed to load";
44  }
45  //获得人脸检测工厂函数
46  CreateDfaceDB* createDfaceDB = (CreateDfaceDB*)dlsym(handle, "create_dfacedb");
47  const char* dlsym_error = dlerror();
48  if (dlsym_error) {
49  throw "DfaceDB failed to create";
50  }
51 #endif
52  return createDfaceDB();
53 }
54 
59 inline void destory_dface_db(DfaceDB* p){
60 #ifdef _WIN32
61  //获得人脸检测通道工厂销毁函数
62  DestroyDfaceDB* destroyDfaceDB = (DestroyDfaceDB*)GetProcAddress(handle, "destroy_dfacedb");
63  if (destroyDfaceDB == NULL) {
64  throw "DfaceDB failed to destory";
65  }
66 #else
67  //获得人脸检测通道工厂销毁函数
68  DestroyDfaceDB* destroyDfaceDB = (DestroyDfaceDB*)dlsym(handle, "destroy_dfacedb");
69  const char* dlsym_error = dlerror();
70  if (dlsym_error) {
71  throw "DfaceDB failed to destory";
72  }
73 #endif
74  //销毁检测通道
75  destroyDfaceDB(p);
76 }
77 
78 
79 
80 #endif //DFACE_SYMBOL_H
DFaceDB人脸数据库API抽象层(DfaceDB) 非关系nosql人脸数据库(单文件),支持动态添加属性,适应任意应用场景...
Definition: dface_database.h:19