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.
Complete a document scan in the same process (scanId), so the server has the document portrait to compare against.
Choose a validation mode
MobbScanFaceValidationMode | What the user does | Liveness |
|---|---|---|
LIVENESS_VIDEO_PASSIVE (recommended) | Looks at the camera for a few seconds | ✓ passive, no gestures |
DEFAULT | Takes 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:
- Kotlin
- Java
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
})
MobbScanAPI.getInstance().validateFace(scanId, MobbScanFaceValidationMode.LIVENESS_VIDEO_PASSIVE, new FaceAcquisitorListener() {
@Override
public void onFaceAcquired(MobbScanFaceAcquisitorResult result, MobbScanFaceAcquisitorData faceData, MobbScanAPIError error) {
// Optional: the selfie, as soon as it is captured
}
}, new ValidationCheckListener() {
@Override
public void onValidationChecked(MobbScanValidationState state, MobbScanValidationResultData validationData, MobbScanAPIError 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:
MobbScanValidationState | Meaning |
|---|---|
VALID | The validation passed |
NOT_VALID | The validation was performed and did not pass |
NOT_CHECKED | The validation could not be performed or does not apply |
In liveness modes, cast MobbScanValidationResultData to MobbScanValidationVideoResultData for the detailed result:
| Property | Description |
|---|---|
livenessValidation | MobbScanValidationState of the liveness check |
faceMatchingValidation | MobbScanValidationState of the face comparison |
identityVerificationValidation | Overall MobbScanValidationState |
livenessScore | Liveness confidence |
faceMatchingScore | Similarity between the selfie and the document portrait |
identityVerificationScore | Overall confidence |
imageFaceNow | Face extracted from the selfie video |
imageFaceDocument | Portrait 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.
- Kotlin
- Java
val selfies = arrayListOf(selfieBitmap)
MobbScanAPI.getInstance().validateFace(scanId, selfies) { state, validationData, error ->
// Face matching result
}
ArrayList<Bitmap> selfies = new ArrayList<>();
selfies.add(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.
- Kotlin
- Java
MobbScanAPI.getInstance().detectFace(MobbScanFaceValidationMode.DEFAULT) { result, faceData, error ->
// result == FACE_ACQUIRED: faceData contains the captured face images
}
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:
- Kotlin
- Java
MobbScanAPI.getInstance().validateFace(null, referenceImage, MobbScanFaceValidationMode.LIVENESS_VIDEO_PASSIVE,
{ result, faceData, error -> },
{ state, validationData, error -> /* result */ })
MobbScanAPI.getInstance().validateFace(null, referenceImage, MobbScanFaceValidationMode.LIVENESS_VIDEO_PASSIVE,
(result, faceData, error) -> { },
(state, validationData, error) -> { /* result */ });
Related
- How liveness works and biometric accuracy.
- Theme and texts of the face screen.