MobbScan Cordova: Face Matching
Introduction
MobbScan allows you to perform a face biometric matching between the user using the app and the picture on the ID document.
Once the document scan is completed, you need to call a new method MobbScanAPI.validateFace
that will guide the user to capture their face biometrics to be able to match it against the document picture.
In the next section, the details of this method will be exposed.
MobbScanAPI.validateFace
This method opens the camera UI and starts the face matching process. The method has four parameters:
scanID
: Identifier of the scan process provided byMobbScanAPI.startScanForDocumentType
.validationMode
: Type of validation that will be performed, which could be one of the following values:MobbScanFaceValidationMode.DEFAULT
: Face recognition, without liveness checks.MobbScanFaceValidationMode.LIVENESS_HEAD_MOVEMENT
: Face recognition plus an extra check where users will be asked to perform some head movements to confirm that they are an actual person.MobbScanFaceValidationMode.LIVENESS_SMILE
: Face recognition plus an extra check where users will be asked to smile to confirm that they are an actual person.MobbScanFaceValidationMode.LIVENESS_VIDEO_HEAD_MOVEMENT
: Face recognition with head movement recorded. This mode performs a face detection and records a video that is used to perform the facial validation in the server. If you want to get the recorded video, you must use thesetVideoAcquisitorListener
plugin method, which you can check at the end of this section.
validateFaceSuccess
: Function which will be called when the face recognition finishes successfully. It will receive an object with the following attributes:result
: This could be"VALID"
or"NOT_VALID"
.scanId
: Current scan ID.resultData
: Extra data about the validation result, it contains the follwing attributes:face
: Image of the captured face encoded in base64.score
: It is a score over 100 that represents the similarity between the face that appears in the document and the face detected by MobbScan. It can be used to establish your own threshold instead of relying on theresult
value.livenessScore
: Confidence value estimated in the liveness check process.
validateFaceFailure
: Function which will be called when the face recognition fails for any reason. It will receive an object with the error that happened in theerror
attribute. That error includes anerrorCode
which identifies it.
MobbScanAPI.validateFaceOldInterface
Warning: We strongly recommend not to use this method, as this is a deprecated interface and it will be deleted in future versions.
From v2.21.0
developers can use this method in order to use the old oval facial detection interface. The method has four parameters:
scanID
: Identifier of the scan process provided byMobbScanAPI.startScanForDocumentType
.validateFaceSuccess
: This callback is managed the same way as the previous method.validateFaceFailure
: This callback is managed the same way as the previous method.
MobbScanAPI.detectFaceVideoLiveness
This methods allows the plugin to perform a facial detection with the MobbScanFaceValidationMode.LIVENESS_VIDEO_HEAD_MOVEMENT
mode. This method is similar to the previous one, but with the difference that no facial matching is performed, only facial detection.
Here's an execution code sample:
MobbScanAPI.detectFaceVideoLiveness(MobbScanFaceValidationMode.LIVENESS_VIDEO_HEAD_MOVEMENT, validateFaceSuccess, validateFaceFailure);
If you need to obtain the recorded video, you should use the setVideoAcquisitorListener
method to fetch it. Here is an execution example:
MobbScanAPI.setVideoAcquisitorListener(function(data) {
console.log(data);
});
In this data
object, you will obtain a temporary url of the video in the videoUrl
property.