Face encoding

Face encoding is the process of extracting facial features from a detected face. It outputs a face template to be used for face comparison or face search.

Important

The face encoder requires a machine learning model to be loaded into memory. The model should be selected according to the target platform and use-case.
See AI Models for details.

Note

Call the FaceLibrary.loadModel Method to load the chosen model on application start.

Hint

On startup, call the FaceEncoder.warmUp Method to prepare inference of the AI model.

Face template

A face template is a small representation of a face, only 140 bytes or 264 bytes depending on the encoding model used. It is used for face comparison or face search.

A face template can be also exported to the format required by id3 Face Match-on-Card solution.

Encoding quality

The component also provides a quality estimator that aims at predicting the power of matching of a created template.

Important

This functionality requires the model FaceEncodingQualityEstimator_2A to be loaded.

Example

The example below demonstrates how to encode a face image and generate a FaceTemplate:

# initializes a FaceEncoder and warm it up.
face_encoder = FaceEncoder(
    thread_count=4
)

# warm up the face encoder
face_encoder.warm_up()

# create the template from the detected face.
face_template = face_encoder.create_template(image, face)

# dispose all resources
del face_encoder

See also