Skip to content

Using EUDL recognizer

juraskrlec edited this page Aug 23, 2017 · 1 revision

EUDL recognizer is responsible for scanning, decoding and parsing front side of EU Driving licenses - EUDLs

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 EUDL recognizer, it's settings class PPEudlRecognizerSettings, and result class PPEudlRecognizerResult to obtain Driver's license information from the scanning results.

Back to "Getting started" guide.

Initializing the scanning of UK driver's licenses

Below is the sample source code which initializes the scanning for UK driver's licenses.

// 3. ************* Setup Scan Settings **************/

// To specify we want to perform EUDL (EU Driving license) recognition, initialize the EUDL recognizer settings
// Initializing with PPEudlCountryAny performs the scanning for all supported EU driver's licenses, while initializing with a specific EUDL country (i.e. PPEudlCountryGermany) performs the scanning only for UK dirver's licenses
PPEudlRecognizerSettings *eudlRecognizerSettings = [[PPEudlRecognizerSettings alloc] initWithCountry:PPEudlCountryAny];

// Add EUDL Recognizer setting to a list of used recognizer settings
[settings.scanSettings addRecognizerSettings:eudlRecognizerSettings];

Retrieving results

By default, scanningViewController:didOutputResults: callback returns results as a PPRecognizerResults object. When the instance of this result is of type PPEudlRecognizerResult, this means we got the result of EUDL scanning and parsing.

Below is the sample source code which demonstrates how to collect results of EUDL scanning.

- (void)scanningViewController:(UIViewController<PPScanningViewController> *)scanningViewController
              didOutputResults:(NSArray<PPRecognizerResult *> *)results {

    // Here you process scanning results. Scanning results are given in the array of PPRecognizerResult objects.

    // first, pause scanning until we process all the results
    [scanningViewController pauseScanning];

    // Collect data from the result
    for (PPRecognizerResult* result in results) {

        // Check if result is EUDL result
        if ([result isKindOfClass:[PPEudlRecognizerResult class]]) {

            // Cast result to PPEudlRecognizerResult
            PPEudlRecognizerResult *eudlResult = (PPEudlRecognizerResult *)result;

            // Fields of the driver's license can be obtained by using methods defined in PPEudlRecognizerResult.h header file

            // for First name, use ownerFirstName method
            NSLog(@"First name: %@\n", [eudlResult ownerFirstName]);

            // for Last name, use ownerLastName method
            NSLog(@"Last names: %@\n", [eudlResult ownerLastName]);

            // for Address, use ownerAdress method
            NSLog(@"Address: %@\n", [eudlResult ownerAdress]);

            // for Birth data, use ownerBirthData method
            NSLog(@"Birth data: %@\n", [eudlResult ownerBirthData]);

            // for Document issue date, use documentIssueDate method
            NSLog(@"Document issue date: %@\n", [eudlResult documentIssueDate]);

            // for Document exipiry date, use documentExpiryDate method
            NSLog(@"Document expiry date: %@\n", [eudlResult documentExpiryDate]);

            // for Driver number, use driverNumber method
            NSLog(@"Driver number: %@\n", [eudlResult driverNumber]);
        }
    };

    // either resume scanning, or dismiss Scanning View controller
    // [scanningViewController resumeScanningAndResetState:YES];
    [scanningViewController dismissViewControllerAnimated:YES completion:nil];
}
Clone this wiki locally