Face Liveness Detection SDK - Server

This stands for face liveness check, face liveness detection, face anti-spoofing, 3D passive liveness, face fraudulent checker, fraud prevention on server

We implemented face liveness detection SDK via docker container in Python language

We provide the Face Liveness Detection SDK for both Windows and Linux.

Features

License

We offer lifetime licenses per machine for Servers (Windows, Linux).

To request a license, please contact us:

Email: contact@kby-ai.com

Telegram: @kbyai

WhatsApp: +19092802609

Skype: live:.cid.66e2522354b1049b

System Requirements

1. Windows

  • CPU: 2 cores or more (Recommended: 8 cores)

  • RAM: 4 GB or more (Recommended: 8 GB)

  • HDD: 4 GB or more (Recommended: 8 GB)

  • OS: Windows 7 or later

  • Architecture: x64

  • Dependency: OpenVINO™ Runtime (Version: 2022.3), ncnn Runtime(20220721), Vulkan SDK Runtime(1.3.250)

2. Linux

  • CPU: 2 cores or more (Recommended: 8 cores)

  • RAM: 4 GB or more (Recommended: 8 GB)

  • HDD: 4 GB or more (Recommended: 8 GB)

  • OS: Ubuntu 20.04 or later

  • Architecture: x64

  • Dependency: OpenVINO™ Runtime (Version: 2022.3)

Import SDK

  1. Python

from facesdk import getMachineCode
from facesdk import setActivation
from facesdk import faceDetection
from facesdk import initSDK
from facebox import FaceBox
  1. C++

#include "facesdk.h"
# CMake for Windows
target_link_libraries(your_app_name
    /path/to/library/facesdk1.lib
)

# CMake for Linux
target_link_libraries(your_app_name
    /path/to/library/libfacesdk1.so
)

Initializing SDK

  1. Step one

  • First, obtain the machine code for activation and request a license based on the machine code.

# Python code example

machineCode = getMachineCode()
print("machineCode: ", machineCode.decode('utf-8'))
// C++ code example

printf("machine code: %s\n", getMachineCode());
  1. Step Two

  • Next, activate the SDK using the received license.

# Python code example

setActivation(license.encode('utf-8'))
// C++ code example

int ret = setActivation("...");
  • If activation is successful, the return value will be SDK_SUCCESS. Otherwise, an error value will be returned.

  1. Step Three

  • After activation, call the initialization function of the SDK.

# Python code example

initSDK("data".encode('utf-8'))
// C++ code example

ret = initSDK("data");
  • The first parameter is the path to the model.

  • If initialization is successful, the return value will be SDK_SUCCESS. Otherwise, an error value will be returned.

Enums and Structure

1. SDK_ERROR

This enumeration represents the return value of the 'initSDK' and 'setActivation' functions.

2. FaceBox

This class represents the output of the face detection function that contains the detected face rectangle, liveness score, and facial angles such as yaw, roll, and pitch.

APIs

1. getMachineCode

First, obtain the machine code for activation and request a license based on the machine code.

# Python code example

machineCode = getMachineCode()
print("machineCode: ", machineCode.decode('utf-8'))
// C++ code example

printf("machine code: %s\n", getMachineCode());

2. setActivation

Next, activate the SDK using the received license.

# Python code example

setActivation(license.encode('utf-8'))
// C++ code example

int ret = setActivation("...");

If activation is successful, the return value will be SDK_SUCCESS. Otherwise, an error value will be returned.

3. initSDK

After activation, call the initialization function of the SDK.

# Python code example

initSDK("data".encode('utf-8'))
// C++ code example

ret = initSDK("data");

The first parameter is the path to the model.

When using Windows, it is necessary to provide the complete file path for the model.

For Example:

model_path = "C:\path\to\model"

If initialization is successful, the return value will be SDK_SUCCESS. Otherwise, an error value will be returned.

4. faceDetection

The Face SDK provides a single API for detecting faces, performing liveness detection, determining face orientation (yaw, roll, pitch), assessing face quality, detecting facial occlusion, eye closure, mouth opening, and identifying facial landmarks.

The function can be used as follows:

# Python code example

faceBoxes = (FaceBox * maxFaceCount)()
faceCount = faceDetection(image_np, image_np.shape[1], image_np.shape[0], faceBoxes, maxFaceCount)
// C++ code example

FaceBox* faceBoxes = (FaceBox*)malloc(sizeof(FaceBox) * maxFaceCount);
memset(faceBoxes, 0, sizeof(FaceBox) * maxFaceCount);

ret = faceDetection(image.data, image.cols, image.rows, faceBoxes, maxFaceCount);

This function requires 5 parameters.

  • The first parameter: the byte array of the RGB image buffer.

  • The second parameter: the width of the image.

  • The third parameter: the height of the image.

  • The fourth parameter: the 'FaceBox' array allocated with 'maxFaceCount' for storing the detected faces.

  • The fifth parameter: the count allocated for the maximum 'FaceBox' objects.

The function returns the count of the detected face.

Default Thresholds

 livenessThreshold = 0.7 
 yawThreshold = 10 
 pitchThreshold = 10 
 rollThreshold = 10 
 occlusionThreshold = 0.9 
 eyeClosureThreshold = 0.8 
 smallFaceThreshold = 100 
  • If the liveness score exceeds 0.7, the face is a real face.

  • If the absolute values of the face angles are less than 10.0, the face is identified as a fronted face.

  • If the occlusion value is higher than 0.9, the face is occluded.

  • If the eye close value is higher than 0.8, it indicates that the eyes are closed.

  • If the eye's distance is less than 100, it indicates that the face is too small.

Last updated