Skip to content

Commit e7ffeec

Browse files
committed
The initial version has been implemented.
1 parent ba11c0c commit e7ffeec

31 files changed

+114390
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
__pycache__/facebox.cpython-38.pyc
3+
__pycache__/facesdk.cpython-38.pyc
4+
*.bin
5+
lib/facesdk1.dll

facebox.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from ctypes import *
2+
3+
class FaceBox(Structure):
4+
_fields_ = [("x1", c_int32), ("y1", c_int32), ("x2", c_int32), ("y2", c_int32),
5+
("liveness", c_float),
6+
("yaw", c_float), ("roll", c_float), ("pitch", c_float),
7+
("face_quality", c_float), ("face_luminance", c_float), ("eye_dist", c_float),
8+
("left_eye_closed", c_float), ("right_eye_closed", c_float),
9+
("face_occlusion", c_float), ("mouth_opened", c_float),
10+
("landmark_68", c_float * 136)
11+
]

facesdk.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import os
2+
3+
from ctypes import *
4+
from numpy.ctypeslib import ndpointer
5+
from facebox import FaceBox
6+
7+
libPath = os.path.abspath(os.path.dirname(__file__)) + '/lib/facesdk1.dll'
8+
facesdk = cdll.LoadLibrary(libPath)
9+
10+
getMachineCode = facesdk.getMachineCode
11+
getMachineCode.argtypes = []
12+
getMachineCode.restype = c_char_p
13+
14+
setActivation = facesdk.setActivation
15+
setActivation.argtypes = [c_char_p]
16+
setActivation.restype = c_int32
17+
18+
initSDK = facesdk.initSDK
19+
initSDK.argtypes = [c_char_p]
20+
initSDK.restype = c_int32
21+
22+
faceDetection = facesdk.faceDetection
23+
faceDetection.argtypes = [ndpointer(c_ubyte, flags='C_CONTIGUOUS'), c_int32, c_int32, POINTER(FaceBox), c_int32]
24+
faceDetection.restype = c_int32
25+

header/facesdk.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#pragma once
2+
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
enum SDK_ERROR
8+
{
9+
SDK_SUCCESS = 0,
10+
SDK_LICENSE_KEY_ERROR = -1,
11+
SDK_LICENSE_APPID_ERROR = -2,
12+
SDK_LICENSE_EXPIRED = -3,
13+
SDK_NO_ACTIVATED = -4,
14+
SDK_INIT_ERROR = -5,
15+
};
16+
17+
typedef struct _tagFaceBox
18+
{
19+
int x1, y1, x2, y2;
20+
float liveness;
21+
float yaw, roll, pitch;
22+
float face_quality, face_luminance, eye_dist;
23+
float left_eye_closed, right_eye_closed, face_occlusion, mouth_opened;
24+
float landmark_68[68 * 2];
25+
} FaceBox;
26+
27+
/*
28+
* Get the machine code for SDK activation
29+
*/
30+
const char* getMachineCode();
31+
32+
/*
33+
* Activate the SDK using the provided license
34+
*/
35+
36+
int setActivation(char* license);
37+
38+
/*
39+
* Initialize the SDK with the specified model path
40+
*/
41+
int initSDK(char* modelPath);
42+
43+
/*
44+
* Detect faces, perform liveness detection, determine face orientation (yaw, roll, pitch),
45+
* assess face quality, detect facial occlusion, eye closure, mouth opening, and identify facial landmarks.
46+
*/
47+
int faceDetection(unsigned char* rgbData, int width, int height, FaceBox* faceBoxes, int faceBoxCount);
48+
49+
#ifdef __cplusplus
50+
}
51+
#endif

lib/cache.json

Lines changed: 114134 additions & 0 deletions
Large diffs are not rendered by default.

lib/facesdk1.lib

157 KB
Binary file not shown.

lib/gna.dll

2.98 MB
Binary file not shown.

lib/ncnn.dll

8.81 MB
Binary file not shown.

lib/openvino.dll

11.5 MB
Binary file not shown.

lib/openvino_auto_batch_plugin.dll

306 KB
Binary file not shown.

0 commit comments

Comments
 (0)