-
Notifications
You must be signed in to change notification settings - Fork 3
Direct processing API
This guide will in short present you how to process UIImage objects with PhotoPay SDK, without starting the camera video capture.
With this feature you can solve various use cases like:
- recognizing text on images in Camera roll
- taking full resolution photo and sending it to processing
- scanning barcodes on images in e-mail
- etc.
This guide will be essentially the same as in the "Getting Started" guide. It also closely follows NoCamera-sample app in the SDK repository.
NoCamera-sample demo app here will present UIImagePickerController for taking full resolution photos, and then process it with MicroBlink SDK to get scanning results using Direct processing API.
The same as in "Getting Started" guide.
The same as in "Getting Started" guide.
To initiate the scanning process, first decide where in your app you want to add scanning functionality. Usually, users of the scanning library have a button which, when tapped, starts the scanning process. Initialization code is then placed in touch handler for that button. Here we're listing the initialization code as it looks in a touch handler method.
/**
* Method allocates and initializes the Scanning coordinator object.
* Coordinator is initialized with settings for scanning
*
* @param error Error object, if scanning isn't supported
*
* @return initialized coordinator
*/
- (PPCoordinator*)coordinatorWithError:(NSError **)error {
// Check if photopay is supported
if ([PPCoordinator isScanningUnsupported:error]) {
return nil;
}
// 1. ******* Instantiate Scanning settings ********/
PPSettings* settings = [[PPSettings alloc] init];
// 2. ************* Setup UI Settings **************/
// Instantiate PhotoPay UI settings. This allows more customization in the initialization process.
PPPhotoPayUiSettings* photopayUiSettings = [[PPPhotoPayUiSettings alloc] init];
settings.uiSettings = photopayUiSettings;
// Use german language
photopayUiSettings.language = @"de";
// Help is available so present it just in the first app run
photopayUiSettings.helpDisplayMode = PPHelpDisplayModeFirstRun;
// Use Toast messages
photopayUiSettings.presentToast = YES;
// Autorotate overlay
photopayUiSettings.autorotateOverlay = YES;
// 3. ************* Setup Scan Settings **************/
// Add recognizer for Austrian payslips
[settings.scanSettings addRecognizerSettings:[[PPAusSlipRecognizerSettings alloc] init]];
// Add QR code recognizer for Austrian payslips
[settings.scanSettings addRecognizerSettings:[[PPAusQrRecognizerSettings alloc] init]];
// 4. ************* Setup License Settings **************/
// Set your license key here. This specific key is for demo purposes only!
settings.licenseSettings.licenseKey = @"DBRWHNRH-YLGPHFUJ-Q7TGEPYE-G22L7IFY-2V2E7NTP-DB5I5T2P-WZXRQ6UO-Z5H56WZN";
// Allocate the recognition coordinator object
PPCoordinator *coordinator = [[PPCoordinator alloc] initWithSettings:settings];
return coordinator;
}
- (IBAction)takePhoto:(id)sender {
NSLog(@"Take photo!");
/** Instantiate the scanning coordinator */
NSError *error;
self.coordinator = [self coordinatorWithError:&error];
/** If scanning isn't supported, present an error */
if (self.coordinator == nil) {
NSString *messageString = [error localizedDescription];
[[[UIAlertView alloc] initWithTitle:@"Warning"
message:messageString
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil] show];
return;
}
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
// Use rear camera
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
cameraUI.cameraDevice = UIImagePickerControllerCameraDeviceRear;
// Displays a control that allows the user to choose only photos
cameraUI.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *)kUTTypeImage, nil];
// Hides the controls for moving & scaling pictures, or for trimming movies.
cameraUI.allowsEditing = NO;
// Shows default camera control overlay over camera preview.
cameraUI.showsCameraControls = YES;
// set delegate
cameraUI.delegate = self;
// Show view
[self presentViewController:cameraUI animated:YES completion:nil];
}
#pragma mark - UIImagePickerControllerDelegate
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
// Handle a still image capture
if (CFStringCompare((CFStringRef) mediaType, kUTTypeImage, 0) == kCFCompareEqualTo) {
UIImage *originalImage = (UIImage *)[info objectForKey: UIImagePickerControllerOriginalImage];
// call process image
[self.coordinator processImage:originalImage
scanningRegion:CGRectMake(0.0, 0.0, 1.0, 1.0)
delegate:self];
}
[self dismissViewControllerAnimated:YES completion:nil];
}
The same as in "Getting Started" guide.
Now you've seen how to implement the Direct processing API.
In essence, this API consists of two steps:
-
Initialization of the scanner.
-
Call of
processImage:scanningRegion:delegate
method for eachUIImage
you have.
- Getting Started with PhotoPay SDK
-
Obtaining scanning results
- Scanning Austrian payslips
- Scanning Belgian payslips
- Scanning Croatian HUB payslips / barcodes
- Scanning Dutch Acceptgiros
- Scanning German payslips
- Scanning Hungarian payslips
- Scanning SEPA payment QR codes
- Scanning Slovenian payslips
- Using BlinkID recognizers
- Using MRTD Recognizer for scanning ID documents
- Using EUDL Recognizer
- Using USDL Recognizer
- Using MyKad recognizer
- Using PDF417 Recognizer
- Using BarDecoder Recognizer
- Using ZXing Recognizer
- Using Barcode Recognizer
- Using Templating API
- Using Detector Recognizer
- Using BlinkInput OCR Recognizer
- Troubleshoot
- Using Direct Processing API
- Customizing Camera UI
- Creating customized framework
- Upgrading from older versions