Skip to content

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:

DocReader.shared.showScanner(self) { (action, result, error) in
    if action == .complete || action == .processTimeout {
        print(result)
    }
}
[RGLDocReader.shared showScanner:self completion:^(enum RGLDocReaderAction action, RGLDocumentReaderResults * _Nullable results, NSError * _Nullable error) {
    if (action == RGLDocReaderActionComplete || action == RGLDocReaderActionProcessTimeout) {
        NSLog(@"%@", results);
    }
}];

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

In scenarios that recognize document type, 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), the multipage processing is triggered.

In the RGL_SCENARIO_MRZ_AND_LOCATE and RGL_SCENARIO_LOCATE scenarios, if the SDK detects an ID1-sized document, it asks for a 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:
DocReader.shared.processParams.multipageProcessing = true
[RGLDocReader shared].processParams.multipageProcessing = @YES;
  • 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:
DocReader.shared.processParams.doublePageSpread = true
[RGLDocReader shared].processParams.doublePageSpread = @YES;

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 determines the location of holograms during the document processing.

Define whether to check the authenticity of holograms:

DocReader.shared.processParams.checkHologram = true
[RGLDocReader shared].processParams.checkHologram = @YES;

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>

Start the recognition process:

  • To process one or more than one image as UIImage, use:
DocReader.shared.recognizeImage(images, completion: { (action, result, error) in
    if action == .complete {
        print(result)
    }
})
[RGLDocReader.shared recognizeImages:images completion:^(RGLDocReaderAction action, RGLDocumentReaderResults * _Nullable results, NSError * _Nullable error) {
    if (action == RGLDocReaderActionComplete || action == RGLDocReaderActionProcessTimeout) {
        NSLog(@"%@", results);
    }
}];

Where images is an array of UIImage that are got from somewhere, for example, from the device's gallery.

  • To process one image as binary, rather than UIImage, use:
DocReader.shared.recognizeData(data, completion: { (action, result, error) in
    if action == .complete {
        print(result)
    }
})
[RGLDocReader.shared recognizeData:data completion:^(RGLDocReaderAction action, RGLDocumentReaderResults * _Nullable results, NSError * _Nullable error) {
    if (action == RGLDocReaderActionComplete || action == RGLDocReaderActionProcessTimeout) {
        NSLog(@"%@", results);
    }
}];

Where data is an image in .pdf, .jpg, .png or other format converted to Data.

Other methos used for frames processing can be found at our API Reference documentation.

Next Steps