Document Processing Settings
Processing Modes
- Set the scanning mode:
DocReader.shared.functionality.captureMode = CaptureMode.captureVideo
[RGLDocReader shared].functionality.captureMode = RGLCaptureModeCaptureVideo;
- To set a frame resolution, use one of the
AVCaptureSession.Preset
members:
DocReader.shared.functionality.videoSessionPreset = AVCaptureSession.Preset.hd1920x1080
[RGLDocReader shared].functionality.videoSessionPreset = AVCaptureSessionPreset1920x1080;
- Adjust a zoom level using the pinch gesture (in a range from 1x to 10x):
DocReader.shared.functionality.isZoomEnabled = true
[RGLDocReader shared].functionality.isZoomEnabled = YES;
- Set the zoom level (in a range from 1x to 10x):
DocReader.shared.functionality.zoomFactor = 2.0
[RGLDocReader shared].functionality.zoomFactor = 2.0;
- Control in the multipage processing mode:
DocReader.shared.functionality.manualMultipageMode = true
[RGLDocReader shared].functionality.manualMultipageMode = YES;
Warning
Do not use multipageProcessing and this one at the same time.
- Define the orientation of activities by using one of the
UIInterfaceOrientationMask
members:
Danger
Make sure that the selected orientation corresponds to your application’s orientation. Otherwise, it may lead to unexpected behavior.
DocReader.shared.functionality.orientation = UIInterfaceOrientationMask.portrait
[RGLDocReader shared].functionality.orientation = UIInterfaceOrientationMaskPortrait;
- Specify the position of a capture device for video sessions:
DocReader.shared.functionality.cameraPosition = AVCaptureDevice.Position.back
[RGLDocReader shared].functionality.cameraPosition = AVCaptureDevicePositionBack;
Record Processing
To record the scanning process, use:
DocReader.shared.functionality.recordScanningProcess = true
DocReader.shared.functionality.recordScanningProcessDelegate = self
[RGLDocReader shared].functionality.recordScanningProcess = YES;
[RGLDocReader shared].functionality.recordScanningProcessDelegate = self;
func recordingOutputFileURL() -> URL
Asks the delegate for a URL to use for the output file.
func recordingOutputFileURL() -> URL {
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
return paths[0].appendingPathComponent("video.mov")
}
- (NSURL *)recordingOutputFileURL {
NSArray *paths = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask];
return [paths[0] URLByAppendingPathComponent:@"video.mov"];
}
func didFinishRecording(URL)
Tells the delegate that the recording is finished and a URL of the output file can be obtained.
func didFinishRecording(toFile fileURL: URL) {
print("didFinishRecording: \(fileURL.absoluteURL)")
}
- (void)didFinishRecordingToFile:(NSURL *)fileURL {
NSLog(@"didFinishRecording: %@", [fileURL absoluteURL]);
}
func didFailWithError(Error)
Tells the delegate that an error has appeared.
func didFailWithError(_ error: Error) {
print("didFailWithError: \(error.localizedDescription)")
}
- (void)didFailWithError:(NSError *)error {
NSLog(@"didFailWithError: %@", [error localizedDescription]);
}
Frame Processing
- You can assing a scenario that will be used upon tapping the Capture button:
DocReader.shared.processParams.captureButtonScenario = RGL_SCENARIO_FULL_PROCESS
[RGLDocReader shared].processParams.captureButtonScenario = RGL_SCENARIO_FULL_PROCESS;
- To manually set the document's bounds, invoke:
DocReader.shared.processParams.manualCrop = true
[RGLDocReader shared].processParams.manualCrop = @YES;
- Set the following option to true if you know for sure that the image you provide contains an already cropped by edges document:
DocReader.shared.processParams.alreadyCropped = true
Barcode Recognition
There are documents that contain barcodes with data that can be parsed only if the document type verification is performed.
Use the following property to set up the barcode parser type which should be used during the recognition. In this case, the barcode data will be parced without performing the document type verification:
DocReader.shared.processParams.barcodeParserType = 123
[RGLDocReader shared].processParams.barcodeParserType = @123;
Metadata
Display the metadata over the camera preview during the document processing, namely the perspective angle value:
DocReader.shared.functionality.showMetadataInfo = true
[RGLDocReader shared].functionality.showMetadataInfo = YES;
Custom Params
Set a custom JSON that should be processed along with other process params:
// depersonalize the document's data
let data = [["allTextFields": true], ["allGraphicFields": true]]
DocReader.shared.processParams.customParams = ["dePersonalize": data]
// set the maximum DPI for an output image (if set to zero, the image is not resized):
DocReader.shared.processParams.customParams = ["imageDpiOutMax": 0]
// depersonalize the document's data
NSArray *data = @[@{@"allTextFields": @YES}, @{@"allGraphicFields": @YES}];
[RGLDocReader shared].processParams.customParams = @{@"dePersonalize": data};
// set the maximum DPI for an output image (if set to zero, the image is not resized):
[RGLDocReader shared].processParams.customParams = @{@"imageDpiOutMax": @0};