Skip to content

How to use#

Each liveness test is implemented as state machine which modifies it state with each call of update() method. Current state can be identified by error value returned after update call. So in common scenario user should submit images for processing and analyze returned error.

Error types:

ERR_OK - denotes that result is ready for acquisition. ERR_NOT_INITIALIZED - denotes that liveness test is not initialized, it happens in critical cases when LivenessEngine or FaceEngine core objects were not initialized. Make sure that data and configuration paths are correct and try to recreate core modules, or call loadSettings() method. ERR_NOT_READY - denotes that result is not ready and additional update calls are required. ERR_PRECONDITION_FAILED - denotes that test has not yet begun and preconditions are not done (Preconditions can vary depending on liveness type). ERR_INTERNAL - denotes that internal error occurred, please dump input data and contact your SDK advisor.

Right error sequence described below:\ ERR_NOT_INITIALIZED -> ERR_PRECONDITION_FAILED -> ERR_NOT_READY -> ERR_NOT_READY -> ... -> ERR_NOT_READY -> ERR_OK

The following is the common usage of the liveness detector types:

1) Initialize video capture.

2) Create FaceEngine and LivenessEngine structures:

auto resFaceEngine = createFaceEngine(...);

if (!resFaceEngine) { ... }

IFaceEnginePtr faceEngine = resFaceEngine.getValue();

auto resLivenessEngine =

createLivenessEngine(faceEngine, ...);

if (!resLivenessEngine) { ... };

auto livenessEngine = resLivenessEngine.getValue();

3) Create required liveness test type:

auto resLiveness = livenessEngine->createLiveness(LivenessAlgoritmType::LA_INFRARED);

if (!resLiveness) { ... };

auto liveness = resLiveness.getValue();

4) In cycle acquire image from video stream, preprocess it if necessary.

5) Submit photos and check result status:

ResultValue result = liveness->update(img);

In case of complex liveness:

ResultValueresult = depthLiveness->update(color,depth);

6) If result is not erroneous retrieve result:

if (result.getResult() == LSDKError::ERR_OK)

liveness = result.getValue();

For more detailed information about liveness usage please refer to example_liveness and example_depth located at /examples folder of the LivenessEngine package.