Age Estimation Guide

TrustX provides an age estimation check that can be used to determine the estimated age of a captured face image. This functionality can be useful when creating identity verification flows that require the end-user to be a certain age to advance. Use cases could include

  • Age restricted content

  • Online purchases

  • Regulated services

For example, it may be required that the end-user must be over the age of 18 to successfully verify and complete the flow. As age estimation provides an estimated age, it is good practice to provide a buffer. For instance, age estimation results that are over 25 will be approved automatically, but under the age of 24 must complete a document-to-face match that verifies the age of the end-user.

Age Estimation Implementation Overview

A typical age estimation flow will consist of a face capture process that includes the 'Age Estimation Check v1.3' activity or performs age estimation via the TrustX API. When an estimated age is returned, a decision can be made depending on the result that either approves the end-user or directs them through another step in the Process Instance.

This guide will cover the following implementation:

  1. Capture a face image and perform quality checks.

  2. Perform an age estimation check based on the captured face image.

  3. Retrieve the estimated age value from the check:

    1. If result is 25+, approve and complete the verification flow.

    2. If result is 18+, continue to document verification flow.

The full integration described in this guide can be downloaded via GitHub:

Age Estimation Implementation

This section will walkthrough the backend processing steps and covers the following topics:

  1. Face Capture

  2. Face Quality Analysis

  3. Face Liveness Detection

  4. Age Estimation

The 'Face capture example' template provides a base from which steps 1-3 can be implemented.

To integrate this template, follow the steps below:

  1. Log in to the Backoffice application and select Process Definitions > New Process Definition.

  2. A pop-up will appear to create a Process Definition from scratch or use a pre-built template. Select the 'Face capture example' template.


Face Capture

A face can be captured from a Process Definition using the 'Capture Face Image' activity.


  1. In the Process Definition, add the 'Capture Face Image' activity to the Process Designer.

  2. Configure the activity by selecting it to open the right-side context menu. The activity provides the following configurable input parameters:

Parameter Description Type Default
Camera Height The height of the camera set during capture. INTEGER ${720}
Camera Width The width of the camera set during capture. INTEGER ${1280}
Face Image Format The format of the image to be captured. STRING jpeg
Face Key The identifier of the Face. STRING face1
List of Screens The list of screens to be presented to the user during the capture process. Possible values include: instructions, capture, and preview. LIST_STRINGS ["instructions", "capture", "preview"],
Starting Component ID The name of the capture step to be sent to the UI STRING face-capture
Timeout in Seconds Camera timeout in seconds. INTEGER ${60}
UI Component ID The name of the screen used in the capture UI. STRING instructions

When face capture is started in TrustWeb, the end-user will see the following page:


Pressing the 'Open camera' button will become the face capture process. This page and other TrustWeb pages can be customized using the Themes functionality.

Face Quality Analysis

Face quality analysis is performed to ensure the captured face image meets a certain quality threshold. For the purpose of age estimation, the 'Face Quality Assessment v1.3' activity is required.

  1. If using the 'Face capture example' template, the existing 'Face Quality Assessment' activity must be replaced with v1.3 of this activity. Click the existing activity to open additional options and click the 'delete' bin icon.


  1. The 'Face Quality Assessment v1.3' activity must be present after the face image is captured in the Process Definition.

  2. Using a sequence flow arrow, connect the 'Capture Face Image' activity to the 'Face Quality Assessment'.

  3. The activity provides a 'Failed face quality' boundary event that is triggered when the captured face image failed the face quality check. In the example below, this boundary event is connected to the 'Face Capture Entry Gateway'.


Face Liveness Detection

Face Liveness Assessment is performed on face to ensure that the submitted face image is genuine and not a recording taken from a desktop monitor or mobile device. It is performed using the 'Face Liveness Assessment v1.42' activity. The activity is configured accordingly:

  1. Add the 'Face Liveness Assessment v1.42' activity from the Process Designer. This activity can be added after the face quality check.

  2. Use a sequence flow arrow to connect the 'Face Quality Assessment v1.3' activity to the 'Face Liveness Assessment v1.42' activity.


Age Estimation

Age estimation is performed using the 'Age Estimation v1.3' activity. When designing a Process Definition that integrates age estimation, this activity can be added after the face liveness assessment.

In this implementation, the age estimation check will determine if the end-user is 25+. If they are, the flow will be completed. If they are between the ages of 18 - 25, the 'Failed age estimation check' boundary event will be triggered, and the end-user will be directed to the Document Capture flow.

Info

It is not required to perform face template generation in the event that the age estimation returns a value is 25+. Face template generation will only be required for generating a face for document-to-face matching.

To configure the 'Age Estimation v1.3' activity, follow the steps outlined below:

  1. Add the 'Age Estimation v1.3' activity to the Process Designer.

  2. Connect the activity to the 'Face Liveness Assessment v1.42' activity using sequence flow arrows.

  3. For now, remove the 'Face Template Generation' activity.

  4. Add an end activity after 'Age Estimation v1.3'

  5. When each step is configured, the resulting Process Definition should appear as described below:


Configure Conditional Logic

Successful Flow

The age estimation activity provides an 'Expression' input parameter that can be used to define the conditional logic of the activity. To determine whether the captured face image is greater than or equal to 25, the input parameter can be set accordingly:

_faces[“face1”].currentCapture.ageEstimate.estimatedAge >= 25
The input parameter configured in the Backoffice

Failed age estimation check

In the event that the end-user has failed the age estimation check, it is necessary to generate a face template to begin the document capture and face matching flow. The 'Age Estimation Check v1.3' activity provides an error boundary event for 'Failed age estimation check' that can be used to handle this condition.

  1. From the error boundary event, create a 'Face Template Generation' activity and connect them using a sequence flow arrow.


  1. After the 'Face Template Generation', create a 'Confirm Face Image' activity that will confirm the face image.

  2. In the example below, the 'Confirm Face Timeout' is connected to a 'Timeout End' event. The 'Failed face template generation' returns to the beginning of the face capture process.


Document Capture Implementation

In the event that the face image does not pass the age estimation check, a document capture flow can be integrated to check an ID document, perform a document-to-face match check and verify the age of the end-user. This section will cover the steps required to configure the document capture flow, extract OCR document data, and perform a face match against the document.

Document Capture

The document capture process in this example will follow a standard flow. For this example, a front side document will be captured. The example Process Definition downloadable below includes a full sample for both front and back side documents.

To capture a document image, follow the steps below:

  1. From the Process Designer palette, add a 'Select Document Type V3' activity. This will request the end-user to select the type of document to be captured. See Document Activity Parameters for information on configurable input parameters.

  2. Add a new gateway that will be represent the start of the document capture flow. Connect the gateway to the 'Select Document Type V3' activity. In this example, the gateway is named "Front side document capture gateway".

  3. After the gateway, add a 'Capture Document Image - Front v3' activity. This will prompt the end-user to capture an image of their ID document.

  4. When all steps are followed, the Process Definition should be configured accordingly:


Screen Replay Detection and Forgery Detection

TrustX provides various methods of forgery and screen replay detection. This example will be configured to take advantage of each of the following methods of detection:

  • Document Quality Assessment

  • Screen Replay Detection

  • Black and White Copy Detection

  • Color Copy Detection

  • Photo Substitution Detection

For more information on each of these detection services, see the Document Capture guide.

Follow the instructions below to implement each of the services:

  1. Add each of the following activities and connect them using sequence flow arrows

    1. 'Document Quality Assessment v1.6.5'

    2. Screen Replay Detection - v2.5.0'

    3. 'Black and White Copy Detection 2.1.0'

    4. 'Color Copy Detection v1.4.0'

    5. 'Photo Substitution Detection v1.5.0'

  2. Each activity as a failed quality or forgery detected boundary gate (example: Screen replay detected). Connect each boundary gate to the 'Front side document capture entry' gateway.

Document Capture Complete

When all steps are configured, the Process Definition should appear as follows:


Configure Document Capture Failure Flow

In the event that a document could not be captured or the end-user exceeds the retry count for one of the forgery detection services, the process will end and a decision will be made. This section describes the steps required to configure this scenario.

  1. Create a new gateway that will define the beginning of the 'Switch to Desktop' flow.

  2. For each of the forgery detection count boundary events (example: "Exceed color copy detection count"), connect the boundary events to the gateway.

  3. After the gateway, add a 'Switch to Desktop' flow to switch back to desktop if the end-user is on mobile.

  4. Add a 'Device switch exit' gateway. This will be useful in scenarios where the end-user is already on desktop.

  5. Add a 'Simple Decider' to the Process Definition and connect to the device exit gateway.

  6. Finally, add an end event to complete the flow.

  7. When all steps are configured, the Process Definition should look as follows.

Example End Configuration

Face Match (Document-to-Face)

This step in the guide will describe the steps to process the captured document and perform face matching against the face image captured in the Face Capture section above.

This flow will also integrate a second age estimation check that validates the age of the face image extracted from the document.

Follow the steps below to perform document processing and face matching:

  1. Starting from the 'Document confirmed' gateway created during the Document Capture process, add a sequence flow arrow that connects to a 'Regula Document Processor 7.4' activity. This will begin processing the document captured in the previous steps.

  2. Add an 'Acceptable Document Type' activity. This will determine that the captured document is among the accepted document types. Connect this new activity to the 'Regula Document Process 7.4' activity using a sequence flow arrow.

  3. Add a 'Document to Face Matching v2' activity to the Process Designer and connect to the 'Acceptable Document Type' activity. This activity will perform a match against a captured face image and document face image. The activity has the following input parameters:

Error navigation screen
Parameter Description Type Default
Document Key The identifier of the document. STRING doc1
The screen to navigate to when an error occurs STRING_LIST [instructions]
Exception on Max Attempts Exceeded If the maxAttempts is exceeded, should exceedFailedLivenessCount exception be thrown BOOLEAN ${true}
Face Key The identifier of the face. STRING face1
Face Match Threshold The threshold value which determines if a face is considered a match. DOUBLE ${0.339689}
Internal Face Match Threshold The internal face matching threshold determines whether v4 of the face matching algorithm will be used alongside the v3 algorithm. If the result of the match against the v3 is higher than the internal threshold, a v4 template is generated. The v4 score will then be compared to the face matching threshold. DOUBLE ${0.29408}
Max Attempts The number of failed attempts of face liveness before the exceedFailedLivenessCount exception is thrown. INTEGER ${3}
  1. When configuring the input parameters, ensure the the Document Key and Face Key match those of the document and face image captured during the Process Definition.


  1. In the example above, the failed error boundary event are configured to return to the beginning of the capture process.

Date of Birth Extraction and Age Calculation

The next step of the process involves performing an age estimation check against the age value extracted from the document to determine whether the document itself is compliant with the age requirements. This is performed using another 'Age Estimation Check v1.3' activity.

  1. After the 'Document to Face Matching v2' activity, add an 'Age Estimation Check v1.3' activity and connect them with a sequence flow arrow.

  2. In the input parameters of the age estimation check, configure the 'Expression' parameter as follows:

_idDocs.doc1.currentDocumentCapture.extractedText.ocrData.visualZone["185"].value >= 18
  1. This check expression will check to determine the extracted age value is greater than or equal to 18

    1. doc1 - Represents the Document Key belonging to the captured document.

    2. currentDocumentCapture - The current capture of the document.

    3. extractedText - This table contains the extracted document text.

    4. ocrData - The OCR data extracted from the document.

    5. visualZone["185"] - This holds the age value within the OCR data extracted from the current document capture.

  2. After the age estimation check, add a 'Switch to Desktop' and 'Simple Decider' flow to conclude the process. See the example above for designing this flow.

  3. The resulting configuration will appear as follows:


Failed Document Age Estimation Attempts

Failed attempts to pass the age estimation check can be augmented to include a count of failed attempts, enabling end-users to try again until this count is exceeded. The age estimation activity provides two error boundary events that trigger on a failed estimation check or failed quality check.

  1. Add a 'Counter v1' activity to the Process Definition and connect them to the error boundary events of the age estimation activity. In this example, an additional gateway is added between them.

  2. After the 'Counter v1' activity, add a new gateway. This gateway will handle the conditional flow that checks whether the age is less than 18.

  3. Add a sequence flow arrow that connects the gateway back to the recapture flow.

  4. Select the floe arrow to open the right-side contextual menu.

  5. Under the 'Condition' input parameter, add the expression: ${ageCheckCounter < 3} . This will allow the end-user to attempt the capture process until the retry counter is exceeded.

The sequence flow arrow returns the end-user back to the start of the document capture process
  1. In the event that the counter is exceeded, the flow will end and the decision will fail. This flow is similar to the one defined in the example above and requires that the 'Simple Decider' input parameters are set to 'FAIL'.


Viewing Results

After the age estimation flow has been completed, a result will be stored in TrustX and can be retrieved from the Backoffice application or using the TrustX API. This section will describe how to check age estimation in both scenarios.

Backoffice Results

The Backoffice provides age estimation results within a Process Instance page.

  1. Log in to the Backoffice application.

  2. Select Process Instances from the left-side vertical menu.

  3. This page will show a list of Process Instances in TrustX. Select the Process Instance to view by clicking the 'View Process Instance' eye button under the 'Actions' column.

An overview of the results can be found in the 'Verification' section of the Process Instance page. Results will include:

  • Age estimation check

  • Portrait Face Match

  • The face (left) and document (right) images used

  • Passive Face Liveness

  • Overall quality check


Specific details about individual checks performed during the Process Instance can be found under the 'Checks' section of the page. For age estimation, the results can be found under the ageEstimation check where all age estimation results can be found.


TrustX API Results

Age estimation results can be retrieved from the TrustX API. The tenant will require additional permissions to retrieve this data. This section highlights some of the queries and privileges needed to retrieve this information.

The example below returns check information by providing the Process Definition and Process Instance ID.

Permissions: TNT#{tenantid}#UserDataServer:getChecksByKey

Example Request:

GET https://{{tenant}}.{{region}}.trustx.com/api/userdata-server/processDefinitions/{processDefnId}/processInstances/{processInstanceId}/userdata/checks Content-Type: application/json X-API-Key: {{apiKey}} {}

Example Response:

{ "faceQuality": { "id": "faceQuality", "nested": { "face1": { "id": "face1", "outcome": "PASS", "metaData": { "result": "PASS", "feedback": "No feedback", "metrics": { "EyesOpenConfidence": 1.0, "UniformLightingConfidence": 0.8, "FrontalPosePass": true, "FaceFoundPass": true, "PoseAngleRoll": 1, "Name": "SnapIn-DaonFaceV5", "FaceCntrPositionY": 747, "FaceCntrPositionX": 340, "SharpnessPass": true, "FaceBoxUpperLeftCornerY": 581, "Version": "1.1.0.13", "FaceBoxUpperLeftCornerX": 173, "OnlyOneFaceConfidence": 1.0, "InterEyesDistancePass": true, "ExposurePass": true, "FaceBoxLowerRightCornerX": 507, "RightEyePositionX": 424, "Age": 30, "FaceBoxLowerRightCornerY": 912, "RightEyePositionY": 675, "GrayscaleDensityPass": true, "LeftEyePositionY": 673, "PoseAngleRollPass": true, "LeftEyePositionX": 277, "FrontalPoseConfidence": 0.9, "EyesOpenPass": true, "Exposure": 57, "EyesFoundConfidence": 0.94454, "UniformLightingPass": true, "Sharpness": 67, "GrayscaleDensity": 204, "InterEyesDistance": 146, "GlobalFaceQualityScore": 0.916124, "GlobalFaceQualityPass": true, "OnlyOneFacePass": true, "FaceFoundConfidence": 1.0, "EyesFoundPass": true } } } } }, "ageEstimate": { "id": "ageEstimate", "nested": { "face1": { "id": "face1", "outcome": "PASS", "metaData": { "faceQualityFeedback": "No feedback", "expression": "_faces[\"face1\"].currentCapture.ageEstimate.estimatedAge >= 25", "estimatedAge": 30, "faceQualityOutcome": "PASS" } } } }, "faceLiveness": { "id": "faceLiveness", "nested": { "face1": { "id": "face1", "outcome": "PASS", "metaData": { "valid": true, "faceLivenessResult": { "score": 2.6163397, "quality": 0.97077256, "probability": 0.9319058 }, "faceCaptureFailure": false, "service": "/api/idlive-face-v1-42/check_liveness" } } } } }

The example response above provides all face quality, liveness and age estimation checks performed during the Process Instance.

Full Integration Example

A full sample Process Definition that integrates the age estimation flow described in this document can be downloaded via Github from the link below.