Start Processing
When the initialization is completed successfully and the scenario is set, you can start the document recognition processing.
There are two ways to do this:
Camera UI module
Add the NSCameraUsageDescription
permission to your Info.plist - it's needed to access the device's camera:
<key>NSCameraUsageDescription</key>
<string>Is used to access your device's camera</string>
Start the camera controller:
DocumentReader.showScanner(function(m) {
// handle completion
}, function(e) {})
During the processing, actions that demonstrate the state of the camera are received. For example, COMPLETE
means that the processing is completed and the processing results can be handled. All available actions and their description can be found at our API Reference documentation.
Configure processing
You can enhance the document processing by enabling multipage processing, hologram detection, and other configurations. Make sure to declare them before invoking the showScanner
method.
Multipage processing
If the multipage processing is enabled, the SDK processes the front side of the document, recognizes the document type and checks in the database how many pages should be available for this document type. If there are any child documents (second page, back side) for this document type, the multipage processing is triggered. This concerns scenarios that recognize document types.
The exceptions are the SCENARIO_MRZ_AND_LOCATE and SCENARIO_LOCATE scenarios. In this case, if the SDK detects an ID1-sized document, it asks for the second page. The multipage processing is not triggered for documents of other formats.
- To process more than one page of a document for several iterations, use:
DocumentReader.setConfig({
processParams: {
multipageProcessing: true
},
}, function (m) { }, function (e) { console.log(e); });
- To process up to two pages of the document (a so-called "double-page spread") in one shot if they are presented on the frame (image), use:
DocumentReader.setConfig({
processParams: {
doublePageSpread: true
},
}, function (m) { }, function (e) { console.log(e); });
Info
This option is available for the following scenarios only: DOCTYPE, OCR, FULL_PROCESS, MRZ_OR_BARCODE_OR_OCR, MRZ_OR_OCR, LOCATE_VISUAL_AND_MRZ_OR_OCR.
Hologram detection
Holograms are used in creating fraud resistant security identity documents. If hologram detection is enabled, the SDK automatically determine the location of holograms during the document processing.
Define whether to check the authenticity of holograms:
DocumentReader.setConfig({
processParams: {
checkHologram: true
},
}, function (m) { }, function (e) { console.log(e); });
Gallery
iOS
Add the NSPhotoLibraryUsageDescription
permission to your Info.plist - it's need to access the device's gallery:
<key>NSPhotoLibraryUsageDescription</key>
<string>Is used to pick images from the gallery</string>
Android
Add the READ_EXTERNAL_STORAGE
permission to your AndroidManifest - it's need to access the device's gallery:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Start the recognition process:
- To process one or more than one image as Base64, use:
DocumentReader.recognizeImages(images,
function(m) {
// handle completion
}, function(e) {})
Where images
is an array of Base64 that are got from somewhere, for example, from the device's gallery.
- To process one image as binary, rather than Base64, use:
DocumentReader.recognizeData(image,
function(m) {
// handle completion
}, function(e) {})
Where image
is an image in .pdf
, .jpg
, .png
or other format converted to the bytes array.