Skip to main content
Version: 3.16.1 (latest)

Liveness Estimation

In this section you'll learn how to integrate Liveness Estimator to your C++ project.

2D RGB Liveness Estimation (C++)#

1. Creating a Liveness Estimator#

1.1. To create a Liveness Estimator, follow steps 1-3 described in Creating a Processing Block and specify the value "LIVENESS_ESTIMATOR" for the "unit_type" key. When creating a Liveness Estimator, you can leave out the value for the "model_path" key or pass an empty string "".

configCtx["unit_type"] = "LIVENESS_ESTIMATOR";
// optional
configCtx["capturer_config"] = "common_capturer_uld_fda.xml";
configCtx["liveness_config"] = "liveness_2d_estimator_v3.xml";

1.2. Create a Liveness Estimator Processing Block:

pbio::ProcessingBlock livenessEstimator = service->createProcessingBlock(configCtx);

2. Liveness Estimation#

2.1. Create a Context container ioData for input-output data using the createContext() method:

auto ioData = service->createContext();

2.2. Create a Context container imgCtx with RGB-image following the steps described on Creating a Context container with RGB-image.

2.3. Put input image to the input-output data container:

ioData["image"] = imgCtx;

2.4. Call the livenessEstimator and pass the context with source image ioData:


Accurate estimation requires only one person's face in the frame, looking at the camera, otherwise the status "MULTIPLE_FACE_FRAMED" will be returned.

If multiple faces are captured, only one of them (order is not guaranteed) will be processed.

The result of calling livenessEstimator() will be appended to ioData container. The format of the output data is presented as a list of objects with the "objects" key. Each object in the list has the "class" key with the "face" value.

The "liveness" key contains a Context with 2 elements:

  • "value" key contains a value of type string that matches one of the pbio::Liveness2DEstimator::Liveness state
  • "confidence" key contains a number of type double in a range of [0,1]
"objects": [{ "id": {"type": "long", "minimum": 0}
"class": "face",
"liveness": {
"value": {
confidence: {"type": "double", "minimum": 0, "maximum": 1}

3. GPU Acceleration#

Liveness Estimator doesn't support GPU acceleration.

Last updated on