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. - To use the built-in face screen, add
MobbScan_MobbFaceUXandMobbFaceUX. See Installation.
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 presents the face capture screen, records the video, and returns the liveness and matching result:
- Swift
- Objective-C
let params = MobbScanFaceValidationParams()
params.faceValidationMode = .LIVENESS_VIDEO_PASSIVE
MobbScanAPI.getInstance().validateFace(forScanId: scanId, params: params, withFaceAcquisitorResult: { result, faceData, error in
// Optional: the selfie, as soon as it is captured
}, withCheckResult: { state, validationData, error in
// Liveness and face matching result
})
MobbScanFaceValidationParams *params = [MobbScanFaceValidationParams new];
params.faceValidationMode = MobbScanFaceValidationMode_LIVENESS_VIDEO_PASSIVE;
[[MobbScanAPI getInstance] validateFaceForScanId:scanId params:params
withFaceAcquisitorResult:^(MobbScanFaceAcquisitorResult result, MobbScanFaceAcquisitorData *faceData, NSError *error) {
// Optional: the selfie, as soon as it is captured
}
withCheckResult:^(MobbScanValidationState state, MobbScanValidationResultData *validationData, NSError *error) {
// Liveness and face matching result
}];
The face acquisition block is optional; pass it only if you need the selfie in the app.
Read the result
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 MSIdentityVerificationValidationResultData 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 |
faceSelfie | Face extracted from the selfie video |
faceDocument | Portrait extracted from the document |
In DEFAULT mode, cast it to FaceRecognitionValidationResultData to read currentFace (the selfie) and score.
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.
- Swift
- Objective-C
MobbScanAPI.getInstance().validateFace(forScanId: scanId, withFace: selfieImage) { state, validationData, error in
// Face matching result
}
[[MobbScanAPI getInstance] validateFaceForScanId:scanId withFace:selfieImage
withCheckResult:^(MobbScanValidationState state, MobbScanValidationResultData *validationData, NSError *error) {
// Face matching result
}];
Capture only
detectFace runs the face capture without validating it. In liveness modes, it also returns the recorded video (faceVideo).
- Swift
- Objective-C
let params = MobbScanFaceValidationParams()
params.faceValidationMode = .LIVENESS_VIDEO_PASSIVE
MobbScanAPI.getInstance().detectFace(params) { result, faceData, error in
// result == .FACE_ACQUIRED: faceData.faces and faceData.faceVideo
}
[[MobbScanAPI getInstance] detectFace:params
completion:^(MobbScanFaceAcquisitorResult result, MobbScanFaceAcquisitorData *faceData, NSError *error) {
// FACE_ACQUIRED: faceData.faces and faceData.faceVideo
}];
Compare with another portrait
- Swift
- Objective-C
MobbScanAPI.getInstance().validateFace(forScanId: scanId, withDocumentImage: chipPortrait, params: params,
withFaceAcquisitorResult: nil,
withCheckResult: { state, validationData, error in /* result */ })
[[MobbScanAPI getInstance] validateFaceForScanId:scanId withDocumentImage:chipPortrait params:params
withFaceAcquisitorResult:nil
withCheckResult:^(MobbScanValidationState state, MobbScanValidationResultData *validationData, NSError *error) {
// result
}];
Related
- How liveness works and biometric accuracy.
- Theme and texts for the face screen.