Scanning a document with MobbScan
Overview
MobbScan allows you to scan a document, extracting and validating all the information in it. It just takes a few steps to get it done.
API Initialization
First of all, you must initialize the API.
Scan a document side
Once you started the scan process, you can begin the scanning document task.
Each side of the document has to be scanned separately, specifying which side is scanned in each step.
You can choose to do the detection and scan processes all together or do them as two separated steps.
Detect and scan in just one call
This is the simplest way to do both the detection and scan processes. In the same call you will define two listeners that will be invoked in two different moments: when the document is detected on the video stream and it is isolated from the complete image, and when the data is extracted from the document.
self.mobbScanAPI.scanDocument(for: .FRONT, forScanId: "scanId", withDetectionResult: {result,resultData,error in
// your code for the listener here...
}, andScanResult: {result,resultData,error in
// your code for the listener here...
})
[self.mobbScanAPI scanDocumentForSide:side forScanId:self.currentScanId
withDetectionResult:^(MobbScanDetectionResult result, MobbScanDetectionResultData* resultData, NSError* error) {
// your code for the listener here...
}
andScanResult:^(MobbScanScanResult result, MobbScanScanResultData* resultData, NSError* error) {
// your code for the listener here...
}];
Detect and scan in two different calls
In cases where you need extra customization, you can separate the document detection step from the data extraction step. This way you can have both steps in different layouts and customize them as you need.
First, launch the document detection step:
self.mobbScanAPI.getInstance().detect(side, withDetectionResult: {
result,resultData,error in
// your code for the listener here...
})
[self.mobbScanAPI detectDocumentSide:self.side
withDetectionResult:^(MobbScanDetectionResult result, MobbScanDetectionResultData* resultData, NSError* error) {
// your code for the listener here...
}];
Then you can choose to start the scan as soon as you receive the detection event or save the image and use it later.
self.mobbScanAPI.scanDocument(with:detectedImage, for:documentSide, withScanResult: {
result,resultData,error in
// your code for the listener here...
})
[self.mobbscanAPI scanDocumentWithImage:detectedImage forSide:documentSide
withScanResult:^(MobbScanScanResult result, MobbScanScanResultData* resultData, NSError* error) {
// your code for the listener here...
}];