Here is a short description of document liveness checking workflow using the SDK API:

  1. Create an instance of document liveness detector called LivenessPipeline. The only input parameter is a path to the configuration file provided within the release bundle.
  2. Prepare the image so that it is in a format that the liveness detector is able to process. Image can be loaded from the file path, from a byte array. We also support creating the Image object directly from the memory buffer by the pointer.
  3. Present the prepared image to the liveness pipeline and get results: CheckLiveness method is used to request the document liveness score, liveness probability and image quality warnings. It's possible to use different probability threshold calibrations to achieve either lower APCER or lower BPCER. You can find the up-to-date per-pipeline calibration support map here.
Field Description
status_code Image validation status code (image validation is performed beforehand each liveness check)
liveness_score Raw liveness checking score, can be used for calibration
liveness_probability Document liveness probability from 0 to 1
image_quality_warnings Image quality warnings

Liveness probability is the main response of the system, and it should always be used to make a liveness check decision. The image is accepted as "live" when probability is greater than 0.5. Probability value range is [0; 1].

Raw liveness score can be used for BPCER / APCER tuning and is provided mostly for calibration purposes. The range of score value is unbound.

We highly advise you to analyze the image quality warnings and reject inappropriate images.

Below sample programs illustrate using the SDK API from supported programming languages:

#include <docsdk/image.h>
#include <docsdk/liveness_pipeline.h>

int main() {
    docsdk::LivenessPipeline::Ptr pipeline = docsdk::LivenessPipeline::Create("/path/to/config.json");
    docsdk::Image::ptr image = docsdk::Image::Create("/path/to/image.png");
    docsdk::LivenessPipelineResult result = pipeline->CheckLiveness(image);
    return 0;
}
#include <docsdk/c_api.h>

int main(void) {
    DocSdkErrorCode error_code;
    DocSdkLivenessPipeline *pipeline = DocSdkCreateLivenessPipeline("/path/to/config.json", &error_code);
    DocSdkImage *image = DocSdkCreateImageFromFile("/path/to/image.png", &error_code);
    DocSdkLivenessPipelineResult result = DocSdkLivenessPipelineCheckLiveness(pipeline, image, NULL, &error_code);
    return 0;
}
package net.idrnd.docsdk.examples;

import net.idrnd.docsdk.Image;
import net.idrnd.docsdk.LivenessPipeline;
import net.idrnd.docsdk.LivenessPipelineResult;

public class LivenessPipelineExample {
    public static void main(String[] args) {
        try (LivenessPipeline pipeline = new LivenessPipeline("/path/to/config.json")) {
            try (Image image = new Image("/path/to/image.png")) {
                LivenessPipelineResult result = pipeline.checkLiveness(image);
            }
        }
    }
}
from DocSdk import Image, LivenessPipeline

pipeline = LivenessPipeline("/path/to/config.json")
image = Image("/path/to/image.png")
result = pipeline.check_liveness(image)

For more self-contained code examples including the necessary SDK setup please refer to the examples/ fodler of the SDK release bundle.