Running multiple OCRs
OneSDK enables you to perform multiple Optical Character Recognition (OCR) operations on different Government IDs (GovIDs). To achieve this, you must specify the number of documents during OneSDK initialization:
Sample initialisation code
const oneSdk = await OneSdk({
session: sessionObjectFromBackend,
recipe: {
ocr: {
maxDocumentCount: 2,
}
}
});
Afterwards, you can create two (or multiple) OCR components and execute the second OCR after obtaining results of the first one, or even following Biometrics process:
Sample code for executing second OCR
const ocr1 = oneSdk.component('ocr');
const ocr2 = oneSdk.component('ocr');
ocr1.mount(mountElement);
ocr1.on('results', ({ document }) => {
// Present the details of the document that were detected from the uploaded image or images.
// Decide whether to proceed to the next stage of the onboarding process
// depending on whether document verification was successful.
if (document) {
console.log(document);
ocr2.mount(mountElement);
} else {
console.log('No document returned');
}
});
When you run an OCR, a document object containing the OCR results is generated and associated with the entity. Once the maximum document limit is reached, subsequent OCR runs on the same entity will skip capturing a new document. Instead, OneSDK will return the results of the most recent OCRed document under the results
event.
Should you choose to run a second OCR, you have the option to either overwrite the existing document, or create a new one attached to the entity (enabled via a configurations change).
Updated 7 months ago