Detect and scan MRZ
You can use this feature to detect and scan a Machine Readable Zone (MRZ). All official ID cards and Passports complying with ICAO 9303 standard contain this section from which it is possible to retrieve most of personal data without the need to indicate the particular ID type or issuing state beforehand. By using this method, we will be able to scan and get information from worldwide documents.
Extra Configuration
In order to use this feature you must add to your project the MobbScanOffline.xcframework
file, the same way you added the other frameworks.
MRZ detection and scan
Note: To start the MRZ detection and scan, you should have previously started the process to get the
scanId
. Keep in mind that the document type you have to now use isIDDocumentMRZ
.
let operation:ScanOperationMRZ = ScanOperationMRZ()
operation.scanMRZMode = MobbScanMRZMode.DEFAULT
MobbScanAPI.getInstance().scanMRZDocument(operation, detectionResult: {_,resultData,error in
// Here you will receive document image
}, scanResult: {result,resultData,error in
// Here you will receive document extracted data
}
ScanOperationMRZ *operation = [[ScanOperationMRZ alloc] init];
operation.scanMRZMode = MobbScanMRZMode_DEFAULT;
[[MobbScanAPI getInstance] scanMRZDocument:operation
detectionResult:^(MobbScanDetectionResult result, MobbScanDetectionResultData *resultData, NSError *error) {
// Here you will receive document image
} scanResult:^(MobbScanScanResult result, MobbScanScanResultData *resultData, NSError *error) {
// Here you will receive document extracted data
}];
You can select any of these modes to detect the MRZ and the document:
Scan MRZ Mode | Description |
---|---|
MobbScanMRZMode_DEFAULT | Doesn't crop the document |
MobbScanMRZMode_WITH_CROPPED_DOCUMENT | Tries to crop the document from the frame where the MRZ was detected. If not available, returns the full frame |
MobbScanMRZMode_FORCE_CROPPED_DOCUMENT | Forces the document detection. Always returns the cropped document. |
MRZ validations
It is possible to generate a list (validationList
) with all required fields that the scanning process must get and validate before notifying the process back as a successful result. By default, the name and the surname will always be checked and validated as non null values.
You can set the list by the ScanOperationMRZ
object:
var validationList = NSMutableArray()
validationList.add("validationPersonalNumberFormat")
validationList.add("validationDateOfBirth")
validationList.add("validationSurnameNotEmpty")
. . .
var operation:ScanOperationMRZ = ScanOperationMRZ()
operation.scanMRZMode = MobbScanMRZMode.DEFAULT
operation.listValidation = validationList
NSMutableArray* validationList = [[NSMutableArray alloc] init];
[validationList addObject:@"validationPersonalNumberFormat"];
[validationList addObject:@"validationDateOfBirth"];
[validationList addObject:@"validationNameNotEmpty"];
[validationList addObject:@"validationSurnameNotEmpty"];
. . .
ScanOperationMRZ *operation = [[ScanOperationMRZ alloc] init];
operation.scanMRZMode = MobbScanMRZMode_DEFAULT;
operation.listValidation = validationList;