Skip to content

Using Detector recognizer

Jurica Cerovec edited this page Feb 8, 2016 · 2 revisions

Detector recognizer is used to perform a detection of a document and return position of the detected document on the image or video frame.

If you completed Obtaining scanning results guide, you learned that in order to use a specific recognizer, you need to specify Recognizer Settings object in the initialization stage, and collect Recognizer Result object in the success callback.

Here we explain how to use Detector recognizer, it's settings class PPDetectorRecognizerSettings, and result class PPDetectorRecognizerResult to obtain the location of detected object.

Back to "Getting started" guide.

Initializing Detector recognizer

To activate Detector Recognizer, you need to create PPDetectorRecognizerSettings and add it to RecognizerSettings array. When creating PPDetectorRecognizerSettings, you need to initialize it with already prepared PPDetectorSettings. Check the chapter r for more information about available detectors and how to configure them.

You can use the following code snippet to create DetectorRecognizerSettings and add it to RecognizerSettings array:

private RecognizerSettings[] setupSettingsArray() { DetectorRecognizerSettings sett = new DetectorRecognizerSettings(setupDetector());

// now add sett to recognizer settings array that is used to configure
// recognition
return new RecognizerSettings[] { sett };

} Please note that snippet above assumes existance of method setupDetector() which returns a fully configured DetectorSettings as explained in chapter Detection settings and results.

Retrieving results

Detection settings and results

Detection of documents with Machine Readable Zone

This section discusses how to use MRTD detector to perform detection of Machine Readable Zones used in various Machine Readable Travel Documents (MRTDs - ID cards and passports). This detector is used internally in Machine Readable Travel Documents recognizer to perform detection of Machine Readable Zone (MRZ) prior performing OCR and data extraction.

Setting up MRTD detector

To use MRTD detector, you need to create PPMrtdDetectorSettings and give it to appropriate recognizer. You can use following snippet to perform that:

PPDocumentDecodingInfo *mrtdInfo = [[PPDocumentDecodingInfo alloc] init];
[mrtdInfo addEntry:[[PPDocumentDecodingInfoEntry alloc] initWithLocation:CGRectMake(0.0, 0.0, 1.0, 1.0) dewarpedHeight:700]];

PPMrtdDetectorSettings *mrtdDetectorSettings = [[PPMrtdDetectorSettings alloc] initWithDocumentDecodingInfo:mrtdInfo];

// with following setter you can control whether you want to detect
// machine readable zone only or full travel document
mrtdDetectorSettings.detectFullDocument = NO;

As you can see from the snippet, MRTDDetectorSettings can be tweaked with following methods:

detectFullDocument(BOOL)

This method allows you to enable detection of full Machine Readable Travel Documents. The position of the document is calculated from location of detected Machine Readable Zone. If this is set to false (default), then only location of Machine Readable Zone will be returned.

Obtaining MRTD detection result

MRTD detector produces PPMrtdDetectorResult objects. You can use isKindOfClass: method to check if obtained PPDetectorResult is instance of PPMrtdDetectorResult class. See the following snippet for an example:

The available getters of PPMrtdDetectorResults are as follows:

Detection of documents with Document Detector

Setting up of Document Detector

Obtaining document detection result

Combining detectors with MultiDetector

Setting up Multi Detector

Obtaining results from Multi Detector

Clone this wiki locally