Liveness Check

The Liveness Check is a process of determining whether the presented face is a real person, or if the presented face has been faked during some kind of so-called spoof attack. This process is sometimes also called a Spoof Check.

We recognize two approaches to a Liveness Check:

  • Active Liveness is where the person needs to perform an extra action to prove genuineness and liveness
  • Passive Liveness is proving genuineness and liveness without requiring the user to perform any additional action

The SmartFace currently supports Passive Liveness only, which is recommended for applications where the user’s experience and seamless app flow are paramount.

Neural Networks have been trained to detect real faces and various kinds of spoof attacks. Such spoof attacks include:

  • Faces displayed on electronic screens
  • Printed faces
  • 2D masks
  • 3D masks

The example of a presentation attack performed by the printed image.

Supported Passive Liveness Types

There are two passive liveness types available in the SmartFace Platform. They are optimized for different usage and use cases:

  • distant passive liveness – suggested to be used on wild images (not recommended for selfies)
  • nearby passive liveness – suggested to be used on selfie/enrollment images

Passive Liveness Inputs

The SmartFace Platform provides the passive liveness detection in :

A common rule “the better input the better result” applies to the Liveness Check even more. When designing an Access Control solution, some rules need to be followed to have a successful Liveness Check.

The recommended minimum requirements for the input are:

  1. Consider a camera placement and position - take the most frontal face image as possible
  2. A facial image with sufficient background must be submitted for evaluation
  3. A face should not be near the side of the image
  4. Not too strong backlight or sidelight
  5. No overexposed or underexposed images - mind a constant artificial light
  6. An image should not be cropped or compressed between the capture and processing step

Evaluating liveness explained

Liveness Check flow

Depending on the input for the liveness the evaluation flow is slightly different

  1. In real-time video processing only matched faces are evaluated for the liveness. If the detected face is not matched then no Liveness Check is performed. Keep in mind this condition while testing and configuring liveness during deploymnent.
  2. During direct API call, no matching is performed and Liveness Check is performed always.
  3. For the Watchlist Search API call same rule as for realtime video processing applies. Please see the flow chart.

Passive liveness conditions

When evaluating a liveness for provided image you can adjust Liveness Conditions in the spoofCheckConfig. There are two sets of Liveness Conditions. One set is for the nearby Liveness Check, the other one is for the distant Liveness Check.

"spoofCheckConfig": {
    "distantLivenessScoreThreshold": 90,
    "nearbyLivenessScoreThreshold": 90,
    "distantLivenessConditions": "default",
    "nearbyLivenessConditions": "default",
    "keepEvaluatingConditionsAfterFirstFail": false
  }

The default values can be adjusted as needed however the default sets are recommended unless the environmental conditions of the image request it.

Default conditions to start distant passive liveness evaluation

Example for distant Liveness Condition string:

 FACE_CONFIDENCE: [1000; 10000]

You can set additional attributes according to your use case.

Example for distant Liveness Condition string with additional attributes:

 FACE_CONFIDENCE: [1000; 10000] && FACE_SIZE: [30; inf] && FACE_RELATIVE_AREA: [0.009; inf] && FACE_RELATIVE_AREA_IN_IMAGE: [0.9; inf] && YAW_ANGLE: [-20; 20] && PITCH_ANGLE: [-20; 20] && SHARPNESS_RAW: [5000; 70000] && BRIGHTNESS_RAW: [40000; 230000] && CONTRAST_RAW: [10000; 90000] && SPECULARITY_RAW: [5000; 80000]

Tables below list the additional parameters, description and their possible values.

AttributeMinMax
FACE_CONFIDENCE100010000
FACE_SIZE30infinity
FACE_RELATIVE_AREA0.09infinity
FACE_RELATIVE_AREA_IN_IMAGE0.9infinity
YAW_ANGLE-2020
PITCH_ANGLE-2020
SHARPNESS_RAW500070000
BRIGHTNESS_RAW40000230000
CONTRAST_RAW1000090000
SPECULARITY_RAW500080000
AttributeDecription
FACE_CONFIDENCE <0,10000>Face attribute for evaluating confidence score of the face related to face detection.
FACE_SIZEFace attribute representing face size - the maximum of eye distance and eye-mouth distance.
FACE_RELATIVE_AREAArea of face relative to image size.
FACE_RELATIVE_AREA_IN_IMAGEArea of face visible in image relative to total area of face. This value implies the percentage of face area outside the image.
YAW_ANGLEFace attribute representing angle rotation of head towards camera reference frame around Y-axis as per DIN9300.
PITCH_ANGLEFace attribute representing angle rotation of head towards camera reference frame around X-axis as per DIN9300.
SHARPNESS_RAWFace attribute representing sharpness of the image before normalization.

Default conditions to start nearby passive liveness evaluation

Example for nearby Liveness Condition string:

FACE_CONFIDENCE: [1000; 10000]

You can set additional attributes according to your use case.

Example for nearby Liveness Condition string with additional attributes:

FACE_CONFIDENCE: [1000; 10000] && FACE_SIZE: [60; inf] && FACE_RELATIVE_AREA: [0.25; inf] && YAW_ANGLE: [-20; 20] && PITCH_ANGLE: [-20; 20] && BRIGHTNESS: [-7800; 5000] && CONTRAST: [-5000; 6000] && SHARPNESS_RAW: [4000; inf] && UNIQUE_INTENSITY_LEVELS: [500; 10000]
AttributeMinMax
FACE_CONFIDENCE100010000
FACE_SIZE60infinity
FACE_RELATIVE_AREA0.25infinity
YAW_ANGLE-2020
PITCH_ANGLE-2020
BRIGHTNESS-78005000
CONTRAST-50006000
SHARPNESS_RAW4000infinity
UNIQUE_INTENSITY_LEVELS50010000
AttributeDecription
FACE_CONFIDENCE <0,10000>Face attribute for evaluating confidence score of the face related to face detection.
FACE_SIZEFace attribute representing face size - the maximum of eye distance and eye-mouth distance.
FACE_RELATIVE_AREAArea of face relative to image size.
YAW_ANGLEFace attribute representing angle rotation of head towards camera reference frame around Y-axis as per DIN9300.
PITCH_ANGLEFace attribute representing angle rotation of head towards camera reference frame around X-axis as per DIN9300.
BRIGHTNESS <-10000~dark, 10000~light>Face attribute for evaluating whether an area of face is correctly exposed.
CONTRAST <-10000~low, 10000~high>Face attribute for evaluating whether an area of face is contrast enough.
SHARPNESS_RAW <-10000~blurry, 10000~sharp>Face attribute representing sharpness of the image before normalization.
UNIQUE_INTENSITY_LEVELS <-10000~few levels, 10000~enough levels>Face attribute for evaluating whether an area of face has appropriate number of unique intensity levels.
⚠️ If the conditions for passive liveness are not fulfilled, evaluation will not be done. You can add additional attributes or modify ranges for existing ones in default conditions before the passive liveness detection process runs.

Passive liveness thresholds

The final decision of whether a face is real, or a spoof, should be determined by the passive liveness score and threshold. If the score is above the threshold, this can be interpreted as accepted. If the score is below the threshold, it is rejected.

Setting the correct threshold depends on the security/convenience balance that is required for the specific use case.

Thresholds for distant passive liveness:

False Accept Rate [%]False Reject Rate [%]Threshold
19.9940.05567.01692199707031
9.9920.06869.2877197265625
1.9960.80678.48787689208984
0.9982.43283.84744262695312
0.19810.70090.17024993896484
0.09418.09292.82566833496094
0.01051.72297.27446746826172

Thresholds for nearby passive liveness:

False Accept Rate [%]False Reject Rate [%]Threshold
19.9990.30574.63423156738281
9.9981.53681.77136993408203
2.0008.80089.43424987792969
1.00013.52391.35359954833984
0.19926.42594.28164672851562
0.09933.64695.55736541748047
0.01954.97897.1170883178711
0.00859.24897.44188690185547

Example:
Let’s set the threshold of nearby passive liveness to 89.76. If we have a representative set of 10,000 real faces, statistically 220 of the faces will be on average incorrectly marked as spoofs, even though they were real faces (False Reject Rate). If we have a set of 10,000 spoofs, statistically 10 of the spoofs will be on average wrongly marked as real faces (False Accept Rate).

Parameters for the Liveness call

When setting up a call to the POST /api/v1/Faces/SpoofCheck endpoint the parameter spoofDetectorResourceIds represents an array of liveness detectors what should be run during the spoof check.

"spoofDetectorResourceIds": [
    "none"
  ],

Possible values are liveness_distant_any_remote or liveness_distant_cpu_remote or liveness_distant_gpu_remote for a distant passive Liveness Check and liveness_nearby_any_remote or liveness_nearby_cpu_remote or liveness_nearby_gpu_remote for a nearby passive Liveness Check.

⚠️ If you want to use the gpu version of spoof detector resources you need to have GPU acceleration properly set up. For more information about setting up the GPU acceleration please read this page.

You can set thresholds for the Liveness Checks, ie. the number your Liveness score is compared against to decide whether the Liveness Check has passed. The threshold for the distant Liveness Check is set as distantLivenessScoreThreshold and the threshold for a nearby Liveness Check is set as nearbyLivenessScoreThreshold.

The value of keepEvaluatingConditionsAfterFirstFail allows you to have full information about the reasons why the Liveness Check was not performed instead of only providing information about the first reason why it is not being performed.

"spoofCheckConfig": {
    "distantLivenessScoreThreshold": 90,
    "nearbyLivenessScoreThreshold": 90,
    "distantLivenessConditions": "default",
    "nearbyLivenessConditions": "default",
    "keepEvaluatingConditionsAfterFirstFail": false
  }

Responses of the Liveness call

The POST /api/v1/Faces/SpoofCheck endpoint responds with information about whether the Liveness Check was performed and whether it has succeeded. If it has succeeded the Liveness Check score is provided. The first level of information is an aggregation of both nearby and distant Liveness Checks. Then each check provides its information.

If the face is detected but the Liveness Check is not done due to the condition string not being fulfilled then the notPerformedReasons.reasonMessage provides information about what condition(s) was/were not fulfilled.

{
  "performed": true,
  "passed": true,
  "distantLivenessSpoofCheck": {
    "performed": true,
    "passed": true,
    "score": 0,
    "notPerformedReasons": [
      {
        "reasonMessage": "string"
      }
    ]
  },
  "nearbyLivenessSpoofCheck": {
    "performed": true,
    "passed": true,
    "score": 0,
    "notPerformedReasons": [
      {
        "reasonMessage": "string"
      }
    ]
  }
}

Terms explained:
performed is true, if Liveness Checks fulfilled all the conditions.
passed is true, if Liveness Checks passed the Liveness Check.

Liveness Call Flow Chart

SpoofCheck response flowchart