-
Notifications
You must be signed in to change notification settings - Fork 89
Using PDF417 recognizer
dino.gustin edited this page Jun 14, 2016
·
2 revisions
PDF417 recognizer is responsible for scanning and reading 2D barcodes in PDF417 standard
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.
To use PDF417 Recognizer, you need to use PPPdf417RecognizerSettings
object for initialization, and PPPdf417RecognizerResult
for collecting results.
Back to "Getting started" guide.
Below is the sample source code which initializes the scanning for PDF417 barcodes, and specifies default values for all available parameteres.
// 3. ************* Setup Scan Settings **************/
// To specify we want to perform PDF417 recognition, initialize the PDF417 recognizer settings
PPPdf417RecognizerSettings *pdf417RecognizerSettings = [[PPPdf417RecognizerSettings alloc] init];
// Set this to YES to scan even barcode not compliant with standards
// For example, malformed PDF417 barcodes which were incorrectly encoded
// Use only if necessary because it slows down the recognition process
pdf417RecognizerSettings.scanUncertain = NO;
// Set this to YES to scan barcodes which don't have quiet zone (white area) around it
// Use only if necessary because it slows down the recognition process
pdf417RecognizerSettings.allowNullQuietZone = NO;
// Set this to YES to allow scanning barcodes with inverted intensities
// (i.e. white barcodes on black background)
// NOTE: this options doubles the frame processing time
pdf417RecognizerSettings.scanInverse = NO;
// Add PDF417 Recognizer setting to a list of used recognizer settings
[settings.scanSettings addRecognizerSettings:pdf417RecognizerSettings];
Below is the sample source code which collects results of PDF417 barcode 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 PDF417
if ([result isKindOfClass:[PPPdf417RecognizerResult class]]) {
// Cast result to PPPdf417RecognizerResults
PPPdf417RecognizerResult *pdf417Result = (PPPdf417RecognizerResult *)result;
// if you know barcode contains text, obtain string results
// If you don't know the exact encoding of the text use stringUsingGuessedEncoding
NSLog(@"%@", [pdf417Result stringUsingGuessedEncoding]);
// If you know exactly which encoding is used in the barcode, specify it manually
NSLog(@"%@", [pdf417Result stringUsingEncoding:NSUTF8StringEncoding]);
// If the barcode contains raw bytes instead of just text, obtain detailed barcode data
NSLog(@"%@", [pdf417Result rawData]);
}
};
// either resume scanning, or dismiss Scanning View controller
// [scanningViewController resumeScanningAndResetState:YES];
[scanningViewController dismissViewControllerAnimated:YES completion:nil];
}
- Getting Started with BlinkID SDK
- Obtaining scanning results
- Using Direct Processing API
- Customizing Camera UI
- Creating customized framework
- Upgrading from older versions
- Troubleshoot