Class DCVBarcodeReader
DCVBarcodeReader
accesses the camera via a DCVCameraView
object at the native level, then perform continuous barcode scanning on the incoming frames.
class DCVBarcodeReader
Method | Description |
---|---|
createInstance |
Create an instance of DCVBarcodeReader . |
initLicense |
Initialize the license of Dynamsoft Barcode Reader. |
getVersion |
Get the version of DCVBarcodeReader , which is packaged in Dynamsoft Capture Vision. |
getRuntimeSettings |
Get the current runtime settings of DCVBarcodeReader . |
updateRuntimeSettings |
Update the runtime settings of DCVBarcodeReader with a DBRRuntimeSettings object, a preset template or a JSON String. |
resetRuntimeSettings |
Reset the runtime settings of DCVBarcodeReader to default. |
outputRuntimeSettingsToString |
Output the runtime settings of DCVBarcodeReader to string. |
startScanning |
Start the barcode decoding thread. |
stopScanning |
Stop the barcode decoding thread. |
addResultListener |
Specifies an event handler that fires after the library finishes scanning a frame. |
createInstance
Create an instance of DCVBarcodeReader
.
static createInstance(): Promise<DCVBarcodeReader>;
Return Value
An instance of DCVBarcodeReader
.
Code Snippet
dbr = await Dynamsoft.DCVBarcodeReader.createInstance()
initLicense
Initialize the license of the Barcode Reader module.
static initLicense(license: String): Promise<void>;
Parameters
license
: A license key.
Code Snippet
try {
await Dynamsoft.DCVBarcodeReader.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
} catch (e) {
console.log(e)
}
getVersion
Get the version of DCVBarcodeReader
, which is packaged in Dynamsoft Capture Vision.
static getVersion(): Promise<string>;
Return Value
The Version of DCVBarcodeReader
.
getRuntimeSettings
Get the current runtime settings of DCVBarcodeReader
.
getRuntimeSettings(): Promise<DBRRuntimeSettings>;
Return Value
An object of DBRRuntimeSettings
that stores the runtime settings.
Code Snippet
let settings = await dbr.getRuntimeSettings();
updateRuntimeSettings
Update the barcode decoding settings with a DBRRuntimeSettings
struct, a preset template (from the EnumDBRPresetTemplate
items) or a JSON String.
updateRuntimeSettings(settings: String | DBRRuntimeSettings | EnumDBRPresetTemplate): Promise<void>;
Parameters
Settings
: The parameter should be one of the following types:
settings (DBRRuntimeSettings)
: An object that storesDBRRuntimeSettings
.settings (EnumDBRPresetTemplate)
: One of theEnumDBRPresetTemplate
member that indicates a preset template.settings (String)
: A stringified JSON data that contains barcode decoding settings. The available settings include but not limited inDBRRuntimeSettings
. You can access full feature of DBR when upload the settings from a JSON data.
Code Snippet
// Update runtime settings from a DBRRuntimeSettings object.
let settings = await dbr.getRuntimeSettings()
settings.expectedBarcodesCount = 5;
settings.timeout = 1000;
dbr.updateRuntimeSettings(settings)
// Update runtime settings from a preset template
dbr.updateRuntimeSettings(Dynamsoft.EnumDBRPresetTemplate.VIDEO_SPEED_FIRST)
// Update runtime settings from a JSON template.
dbr.updateRuntimeSettings("{\"ImageParameter\":{\"BarcodeFormatIds\":[\"BF_ALL\"],\"BarcodeFormatIds_2\":null,\"DeblurLevel\":0,\"ExpectedBarcodesCount\":0,\"LocalizationModes\":[{\"Mode\":\"LM_SCAN_DIRECTLY\",\"ScanDirection\":1},{\"Mode\":\"LM_CONNECTED_BLOCKS\"}],\"Name\":\"video-speed-first\",\"ScaleDownThreshold\":2300,\"Timeout\":500},\"Version\":\"3.0\"}")
resetRuntimeSettings
Reset the barcode decoding settings to default value.
resetRuntimeSettings(): void;
outputRuntimeSettingsToString
Output the barcode decoding settings to string.
outputRuntimeSettingsToString(): Promise<string>;
Return Value
A string that stores the barcode decoding settings. The barcode settings string can be applied to debug barcode decoding settings.
startScanning
Start the barcode decoding thread.
startScanning(): void;
stopScanning
Stop the barcode decoding thread.
stopScanning(): void;
addResultListener
Specifies an event handler that fires after the library finishes scanning a frame.
addResultListener(listener: (results: BarcodeResult[]) => void): void;
Code Snippet
The following code snippet shows how to use barcode reader module to decode from video stream.
dbr.addResultListener((results) => {
const resultElement = document.getElementById('show_result');
var resultStr = ""
if (results && results.length > 0) {
for (i = 0; i < results.length; i++) {
resultStr=resultStr + results[i].barcodeFormatString+":"+results[i].barcodeText+'\n'
}
resultElement.innerHTML = (resultStr)
} else {
resultElement.innerHTML = "No barcode detected in this frame."
}
document.querySelector('#camera_view').appendChild(resultElement)
})
setMinImageReadingInterval
Set the minimum image reading interval.
setMinImageReadingInterval(interval: number): void;
getMinImageReadingInterval
Get the minimum image reading interval.
getMinImageReadingInterval(): Promise<number>;