Skip to main content

Face matching and liveness

Face matching confirms that the person in front of the camera is alive and is the holder of the document. The SDK captures a short selfie video, the server checks liveness (presentation attack detection) and compares the face with the document portrait.

Before you begin

Complete a document scan in the same process (scanId), so the server has the document portrait to compare against.

Choose a validation mode​

MobbScanFaceValidationModeWhat the user doesLiveness
LIVENESS_VIDEO_PASSIVE (recommended)Looks at the camera for a few seconds✓ passive, no gestures
DEFAULTTakes a selfie✗ face match only

Use LIVENESS_VIDEO_PASSIVE for remote identity verification. DEFAULT does not protect against photos or screens and should not be used for remote onboarding.

Verify the face​

validateFace opens the face capture screen, records the video, and returns the liveness and matching result:

MobbScanAPI.getInstance().validateFace(scanId, MobbScanFaceValidationMode.LIVENESS_VIDEO_PASSIVE, { result, faceData, error ->
// Optional: the selfie, as soon as it is captured
}, { state, validationData, error ->
// Liveness and face matching result
})

The FaceAcquisitorListener is optional; pass it only if you need the selfie in the app.

Read the result​

ValidationCheckListener receives three values:

MobbScanValidationStateMeaning
VALIDThe validation passed
NOT_VALIDThe validation was performed and did not pass
NOT_CHECKEDThe validation could not be performed or does not apply

In liveness modes, cast MobbScanValidationResultData to MobbScanValidationVideoResultData for the detailed result:

PropertyDescription
livenessValidationMobbScanValidationState of the liveness check
faceMatchingValidationMobbScanValidationState of the face comparison
identityVerificationValidationOverall MobbScanValidationState
livenessScoreLiveness confidence
faceMatchingScoreSimilarity between the selfie and the document portrait
identityVerificationScoreOverall confidence
imageFaceNowFace extracted from the selfie video
imageFaceDocumentPortrait extracted from the document

The validation thresholds are configured on the server. Use the states, not the raw scores, to drive your UI, and take the final decision in your backend.

Other options​

Use your own selfie​

If you capture the selfie yourself, send it for matching. No liveness check is performed in this case.

val selfies = arrayListOf(selfieBitmap)
MobbScanAPI.getInstance().validateFace(scanId, selfies) { state, validationData, error ->
// Face matching result
}

Capture only​

detectFace runs the face capture without validating it. Use it to capture first and validate later with the method above, or to build your own face screen.

MobbScanAPI.getInstance().detectFace(MobbScanFaceValidationMode.DEFAULT) { result, faceData, error ->
// result == FACE_ACQUIRED: faceData contains the captured face images
}

To also get the liveness video (MobbScanVideoAcquisitorData.videoStream), use detectFaceVideoLiveness(mode, faceListener, videoListener) with a liveness mode.

Verify against a reference image​

To verify a user without a document scan — for example, against a portrait you already hold — pass the reference image instead of a scanId. The SDK records the liveness video and compares it with that image:

MobbScanAPI.getInstance().validateFace(null, referenceImage, MobbScanFaceValidationMode.LIVENESS_VIDEO_PASSIVE,
{ result, faceData, error -> },
{ state, validationData, error -> /* result */ })