Adds a CapturedResultFilter object to filter non-essential results. It will return the CapturedResultFilter added itself, convenient to use removeFilter method.
Code snippet:
let router = await CaptureVisionRouter.getInstance();
let receiver = router.addFilter(new MultiFrameResultCrossFilter());
//...
router.removeFilter(filter);
The result filter object, of type CapturedResultFilter.
return the result filter added in CapturedResultReceiver.
Can only add MultiFrameResultCrossFilter object for now.
Adds a CapturedResultReceiver object as the receiver of captured results. It will return the receiver added itself, convenient to use removeResultReceiver method.
Code Snippet:
let router = await CaptureVisionRouter.getInstance();
let receiver = router.addResultReceiver({
onCapturedResultReceived: result => {
// Do something with the result
},
});
The receiver object, of type CapturedResultReceiver.
return the receiver added in CapturedResultReceiver.
Processes ImageData object to derive important information.
Code Snippet:
let cameraEnhancer = CameraEnhancer.getInstance();
let router = CaptureVisionRouter.getInstance();
let imageData = cameraEnhancer.getImage();
let result = router.capture(imageData, "ReadSingleBarcode");
for(let i = 0; i < result.items.length; i++) {
//...
}
An ImageData object that contains image info.
Specifies a “CaptureVisionTemplate” to use. The following value are available for this parameter:
A CapturedResult object which contains the derived information from the image processed. If an error occurs when processing the image, the CapturedResult object will include error code and error message that describes the reason of the error.
Processes a file containing a single image to derive important information.
Code Snippet:
let router = CaptureVisionRouter.getInstance();
let result = router.capture("absolute-image-file-path", "ReadSingleBarcode");
for(let i = 0; i < result.items.length; i++) {
//...
}
The absolute file path and name that you want to capture data from. You have to specify the file name with extension name in the filePath. Supported file type includes “.bmp”, “.jpg”, “.png”, “.gif” or one-page “.tiff”.
Specifies a “CaptureVisionTemplate” to use. The following value are available for this parameter:
A CapturedResult object which contains the derived information from the image processed. If an error occurs when processing the image, the CapturedResult object will include error code and error message that describes the reason of the error.
Processes An ArrayBuffer object that points to a file in memory to derive important information.
An ArrayBuffer object that points to a file in memory.
Specifies a “CaptureVisionTemplate” to use. The following value are available for this parameter:
A CapturedResult object which contains the derived information from the image processed. If an error occurs when processing the image, the CapturedResult object will include error code and error message that describes the reason of the error.
Get a simplified settings object for the specified template name.
Specify a template with a templateName for the data capturing. If not specified, the preset template named 'Default' will be used.
Error - If getSimplifiedSettings fails, the promise will be rejected with an error. The error may occur when
Configures runtime settings using a provided JSON string, which contains settings for one or more CaptureVisionTemplates.
A JSON string that contains Capture Vision settings.
Configures runtime settings using a provided JSON file, which contains settings for one or more CaptureVisionTemplates.
Absolute path of a JSON file that contains Capture Vision settings.
Get a JSON string that contains settings for the specified templateName.
The name of the template that you want to output.
Generates a JSON file download containing the settings for the specified templateName and saved to specified file path.
The name of the template that you want to output.
The absolute file path that you want to save the template.
Removes all CapturedResultReceiver object added in.
Removes the specified MultiFrameResultCrossFilter object.
The specified result filter object removed, of type CapturedResultFilter.
Removes the specified CapturedResultReceiver object.
Code Snippet:
let router = await CaptureVisionRouter.getInstance();
let receiver = router.addResultReceiver({
onCapturedResultReceived: result => {
// Do something with the result
},
});
//...
router.removeResultReceiver(receiver);
The receiver object, of type CapturedResultReceiver.
Restores all runtime settings to their original default values.
Sets up an image source to provide images for continuous processing.
Code Snippet:
let router = await CaptureVisionRouter.getInstance();
let cameraEnhancer = CameraEnhancer.getInstance();
router.setInput(cameraEnhancer);
The image source which is compliant with the ImageSourceAdapter interface.
Initiates a capturing process based on a specified template. This process is repeated for each image fetched from the source.
Code Snippet:
let router = CaptureVisionRouter.getInstance();
await router.startCapturing('ReadSingleBarcode');
Specifies a “CaptureVisionTemplate” to use. The following value are available for this parameter:
Promise
Error - If the capturing process fails to start, the promise will be rejected with an error. The error may occur due to invalid template names, or a capturing process is already in progress, etc.
Stops the capturing process.
Code Snippet:
let router = await CaptureVisionRouter.getInstance();
await router.startCapturing("ReadSingleBarcode");
// ...
router.stopCapturing();
Updates the specified templateName with an updated SimplifiedCaptureVisionSettings object. Defined properties will be updated, and undefined properties will retain their original values.
Code Snippet:
let router = CaptureVisionRouter.getInstance();
let settings = {
timeout: 1000,
maxParallelTasks: 1,
barcodeSettings: {
expectedBarcodesCount: 999,
barcodeFormatIds: EnumBarcodeFormats.BF_ONED | EnumBarcodeFormats.BF_QR_CODE,
}
};
//Only timeout, maxParallelTasks, expectedBarcodesCount and barcodeFormatIds will be updated.
router.updateSettings("ReadSingleBarcode", settings);
Optional
settings: null | SimplifiedCaptureVisionSettingsAn object of SimplifiedCaptureVisionSettings. If undefined, will not change settings.
Specify the name of the template that you want to update. If undefined, the preset template named 'Default' will be used.
Error - If updateSettings fails, the promise will be rejected with an error. The error may occur when
Static
getGet the singleton instance of CaptureVisionRouter.
This method ensures that only one instance of CaptureVisionRouter is created and reused throughout the application. If an instance already exists, it will return the existing one. Otherwise, it will create a new instance and return it.
The singleton instance of CaptureVisionRouter.
The CaptureVisionRouter class defines how a user interacts with image-processing and semantic-processing products in their applications. A CaptureVisionRouter instance accepts and processes images from an image source and returns processing results which may contain Final results or Intermediate Results.
In js end of react-native, CaptureVisionRouter uses singleton mode. You can only get CaptureVisionRouter instance by CaptureVisionRouter.getInstance.