API Reference

init_sdk

def init_sdk() -> int:

Name

init_sdk

Description

Initializes the SDK.

Input

None

Output

Status code indicating the result of the initialization.

  • 0: Success

  • Non-zero: Initialization failed

get_attribute

def get_attribute(image: np.ndarray, width: int, height: int, face_results: ctypes.POINTER(FaceResult), max_face_num: int, mode: int) -> int:

Name

get_attribute

Description

Detects and analyzes face.

Input

  • image (numpy.ndarray): Input image matrix

  • width (int): Width of the input image

  • height (int): Height of the input image

  • face_results (ctypes.POINTER): Pointer to a structure containing face results

  • max_face_num (int): Maximum number of faces to detect

  • mode (int): 0-> Enroll mode, 1-> Identify mode

Output

Status code indicating the result of getting attribute.

  • >0: Number of detected faces

  • 0: No Face

  • otherwise: Error

Here is FaceResult Structure.

class FaceResult(Structure):
    _fields_ = [
        ("x1", c_int32),
        ("y1", c_int32),
        ("x2", c_int32),
        ("y2", c_int32),
        ("liveness", c_int32),
        ("mask", c_int32),
        ("glass", c_int32),
        ("age", c_int32),
        ("gender", c_int32),
        ("feature", c_ubyte * 2056)
    ]

(x1, y1)

Coordinate of the top-left corner of the bounding box of the detected face.

(x2, y2)

Coordinate of the bottom-right corner of the bounding box of the detected face.

liveness

Liveness score of detected face

  • 0 -> SPOOF

  • 1 -> REAL

  • -3 -> TOO SMALL FACE

  • -4 -> TOO LARGE FACE

  • -102 -> NO FACE

  • -103 -> LIVENESS CHECK FAILED

mask

Mask detection of the detected face

  • 0 -> No, 1 -> Yes

glass

Glass detection of the detected face

  • 0 -> No, 1 -> Yes

age

Estimated age of the detected face

gender

Gender prediction of the detected face

  • 0 -> Male, 1 -> Female

feature

Template buffer. Extracted template will be stored

calculate_similarity

def calculate_similarity(feature_1: np.ndarray, feature_2: np.ndarray) -> float:

Name

calculate_similarity

Description

Calculates the similarity between two features

Input

  • feature_1 (numpy.ndarray): 1st feature

  • feature_2 (numpy.ndarray): 2nd feature

Output

Similarity score between the two features

The score ranges from 0.0 to 1.0 Default Threshold is 0.82

Last updated