DocumentReaderProcessor settings
You can change the default settings for video streaming and document recognition. The settings must be set before the document recognition process.
streamParam
Sets the video stream settings:
processor.streamParam = {
cameraMode: 'user', // Camera facing mode. Can be 'environment' or 'user'. By default 'user'.
preferredCameraId: '', // Selecting a camera by ID. The camera ID can be obtained using navigator.mediaDevices.enumerateDevices();. Not set by default.
resolution: { // Video resolution. By default 1280x720.
width: 1280,
height: 720,
},
}
recognizerProcessParam
Sets the settings for recognizing a document from the camera (startRecognition
method):
processor.recognizerProcessParam = {
processParam: {
returnUncroppedImage: true, // When enabled, returns input images in output. Disabled by default.
scenario: 'MrzAndLocate', // Recognition scenario. Can be 'MrzAndLocate', 'MrzOrLocate', 'Mrz', 'Locate'. By default 'MrzAndLocate'.
multipageProcessing: true, // Enables multi-page document processing mode. By default false.
timeout: 20000, // Recognition timeout in milliseconds. After this time process will be finished. By default 20000.
resultTypeOutput: [], // Types of results to return in response. By default [] - all available types.
imageQa: { // Quality checks.
expectedPass: ['dpiThreshold', 'glaresCheck'],
dpiThreshold: 130,
glaresCheck: true,
glaresCheckParams: {
imgMarginPart: 0.05,
maxGlaringPart: 0.01,
},
},
},
}
imageProcessParam
Sets the settings for recognizing a document as a file (processImage
method):
processor.imageProcessParam = {
processParam: {
returnUncroppedImage: true, // When enabled, returns input images in output. Disabled by default.
scenario: 'MrzAndLocate', // Recognition scenario. Can be 'MrzAndLocate', 'MrzOrLocate', 'Mrz', 'Locate'. By default 'MrzAndLocate'.
resultTypeOutput: [], // Types of results to return in response. By default [] - all available types.
},
}
recognizeListener
Sets the callback function that takes in the processing result for each frame:
/**
* @param {object} response - The result of processing each frame.
*/
function listener(response) {
console.log(response);
}
processor.recognizeListener = listener; // Not set by default.
videoElement
Sets the video element to display the video stream from the camera. This setting will change the video element that you set when creating the instance new DocumentReaderProcessor(videoElement)
:
const videoElement = document.getElementById('HTMLVideoElement');
processor.videoElement = videoElement; // By default null.
isPrepared
Read-only property. Returns true if the processor has been prepared.
processor.isPrepared; // True or false.
isInitialized
Read-only property. Returns true if the processor has been initialized.
processor.isInitialized; // True or false.
isProcessing
Read-only property. Returns true if document recognition is not completed.
processor.isProcessing; // True or false.