Skip to content

Record Processing

iOS

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]);
}

Timestamp on Recorded Video

If the document recognition is recorded, you can add the timestamp to the saved video. The timestamp is not displayed during the document processing.

Danger

Be aware that this feature consumes too much memory. This may lead to unexpected behavior if you set the resolution to high, for example, 4K.

By default, the timestamp is not added to the recorded video.

To display the timestamp in the recorded video, follow the steps:

  1. Enable recordScanningProcess parameter.
  2. Create RGLRecordingTimestampConfig configuration object.
  3. Optionally, change the config object's properties.
  4. Set the config object to recordingTimestampConfig property.

See the following example.

let timestampConfig = RGLRecordingTimestampConfig()

timestampConfig.position = .topRight
timestampConfig.backgroundColor = .purple
timestampConfig.textColor = .white
timestampConfig.textFont = .boldSystemFont(ofSize: 50)
timestampConfig.dateTimeFormat = "E, d MMM yyyy HH:mm:ss Z"
timestampConfig.timezoneName = "GMT+0"  

DocReader.shared.functionality.recordingTimestampConfig = timestampConfig
RGLRecordingTimestampConfig *timestampConfig = [[RGLRecordingTimestampConfig alloc] init];

timestampConfig.position = RGLRecordingTimestampPositionTopRight;
timestampConfig.backgroundColor = [UIColor purpleColor];
timestampConfig.textColor = [UIColor whiteColor];
timestampConfig.textFont = [UIFont boldSystemFontOfSize:50.0];
timestampConfig.dateTimeFormat = @"E, d MMM yyyy HH:mm:ss Z";
timestampConfig.timezoneName = @"GMT+0";

RGLDocReader.shared.functionality.recordingTimestampConfig = timestampConfig;

You can adjust the timestamp's appearance by the parameters as follows in the table.

Parameter Description Available values
position relative position of the timestamp on the video frame
  • top left
  • top right
  • bottom left
  • bottom right
background color color of the rectangle, where timestamp is displayed see the UIColor data type
text color color of the main text of the timestamp's font see the UIColor data type
text font style and typeface of the timestamp's font see the UIFont data type
date and time format textual format of date and time representation string formatted according to the NSDateFormatter data type
time zone name of the time zone in accordance with the tz database see the most recent official IANA Time Zone Database

The default parameters of the recordingTimestampConfig are as follows:

  • Position — bottom right
  • Background — transparent
  • Font — system, 16pt, bold, white color
  • Date and time format — "yyyy-MM-dd, HH:mm:ss"

Android

To record the scanning process, use:

private final VideoEncoderCompletion videoEncoderCompletion;
//in constructor:
this.videoEncoderCompletion = new VideoEncoderCompletion();
//implementation:
private class VideoEncoderCompletion implements IVideoEncoderCompletion { ... }
// set up completion
DocumentReader.Instance().setVideoEncoderCompletion(videoEncoderCompletion);
DocumentReader.Instance().functionality().edit().setDoRecordProcessingVideo(true).apply();
private var videoEncoderCompletion: VideoEncoderCompletion? = null
//in constructor:
videoEncoderCompletion = VideoEncoderCompletion()
//implementation:
private class VideoEncoderCompletion : IVideoEncoderCompletion { ... }
// set up completion
DocumentReader.Instance().setVideoEncoderCompletion(videoEncoderCompletion)
DocumentReader.Instance().functionality().edit().setDoRecordProcessingVideo(true).apply()

Warning

As we use a weak reference to handle the callback object, into setVideoEncoderCompletion, you should put an object with a life cycle longer than the method life cycle. For example, you can create a variable and put it into the method.

Flutter, React Native, Ionic, Cordova

To record the scanning process, use:

DocumentReader.instance.functionality.recordScanningProcess = true;
DocumentReader.instance.videoEncoderCompletion = (filePath) {
  print(filePath);
};
DocumentReader.setFunctionality({
    recordScanningProcess: true
}, (str) => { console.log(str) }, (error) => { console.log(error) });
DocumentReader.setFunctionality({
    recordScanningProcess: true
});
DocumentReader.setFunctionality({
    recordScanningProcess: true
}, function (m) { }, function (e) { console.log(e); });

.NET MAUI

To record the scanning process, use:

// Android
// implementation:
private class VideoEncoderCompletion : IVideoEncoderCompletion { ... }

private VideoEncoderCompletion videoEncoderCompletion = new VideoEncoderCompletion();

// set up completion
DocumentReader.Instance().SetVideoEncoderCompletion(videoEncoderCompletion);

// iOS
RGLDocReader.Shared.Functionality.RecordScanningProcess = true;
RGLDocReader.Shared.Functionality.RecordScanningProcessDelegate = this;

iOS-Specific

NSUrl recordingOutputFileURL()

Asks the delegate for a URL to use for the output file:

NSUrl recordingOutputFileURL()
{
    NSUrl[] paths = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User);
    return paths[0].Append("video.mov", false);
}

didFinishRecordingToFile(NSUrl fileURL)

Tells the delegate that the recording is finished and a URL of the output file can be obtained:

void didFinishRecordingToFile(NSUrl fileURL)
{
    Console.WriteLine("didFinishRecording: " + fileURL.AbsoluteUrl);
}

didFailWithError(NSError error)

Tells the delegate that an error has appeared:

void didFailWithError(NSError error)
{
    Console.WriteLine("didFailWithError: " + error.LocalizedDescription);
}

Next Steps