Web Demos

BARCODE READER SDK DEMO

Explore the flexibe barcode reading settings to optimize for your specific usage scenario.

WEB TWAIN SDK DEMO

Try the most popular web scanner features: scan images, import local images and PDF files, edit, save to local, upload to database, and etc.

BARCODE READER JAVASCRIPT DEMO

Transform any camera-equipped devices into real-time, browser-based barcode and QR code scanners.

MRZ SCANNER WEB DEMO

Detects the machine-readable zone of a passport, scans the text, and parses into human-readable data.

APP STORE DEMOS

BARCODE READER SDK FOR IOS

BARCODE READER SDK FOR ANDROID

VIEW MORE DEMOS >
Resource Base
Table of contents

DCVBarcodeReader Class

A barcode reader object accesses to a camera via DCVCameraView object at native level, then perform continuous barcode scanning on the incoming frames.

Methods Description
initLicense Initialize the license of the Dynamsoft Barcode Reader module.
createInstance Create a barcode reader instance.
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 struct or a template.
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.
removeAllResultListeners Remove all existing result listener.
decodeFile Decode barcodes from a specified image file.

initLicense

Initialize the license of Dynamsoft Capture Vision - Barcode Reader Module.

static initLicense(license: String): Promise<void>;

Parameters

license: A license key.

Code Snippet

try {
  await DCVBarcodeReader.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
} catch (e) {
  // Catch and log the error message when license activation is failed.
  console.log(e)
}

createInstance

Create a barcode reader instance.

static createInstance(): Promise<DCVBarcodeReader>

Return Value

A barcode reader instance.

Code Snippet

this.reader = await DCVBarcodeReader.createInstance();

getVersion

Get the version of DCVBarcodeReader, which is packaged in Dynamsoft Capture Vision.

getVersion(): Promise<string>

Return Value

The Version of DCVBarcodeReader.

Code Snippet

let dbrVersion = await this.reader.getVersion();

getRuntimeSettings

Get the current runtime settings of DCVBarcodeReader. To learn more about the currently available runtime settings, please visit DBRRuntimeSettings interface page.

getRuntimeSettings(): Promise<DBRRuntimeSettings>

Return Value

An object that stores the runtime settings.

Code Snippet

let settings = await this.reader.getRuntimeSettings();

updateRuntimeSettings

Update the barcode decoding settings with a DBRRuntimeSettings struct, a preset template (from the EnumDBRPresetTemplate items) or a JSON String.

updateRuntimeSettings(settings: DBRRuntimeSettings | EnumDBRPresetTemplate | String): Promise<boolean>

Parameters

Settings: The parameter should be one of the following types:

  • settings (DBRRuntimeSettings): An object that stores DBRRuntimeSettings.
  • settings (EnumDBRPresetTemplate): One of the EnumDBRPresetTemplate member that indicates a preset template.
  • settings (String): A stringified JSON data that contains barcode decoding settings. The available settings include but not limited in DBRRuntimeSettings. You can access full feature of DBR when upload the settings from a JSON data.

Code Snippet

/* How to update runtime settings using runtime settings object */
let settings = await this.reader.getRuntimeSettings();
settings.barcodeFormatIds = EnumBarcodeFormat.BF_ONED | EnumBarcodeFormat.BF_QR_CODE;
settings.expectedBarcodeCount = 1;
await this.reader.updateRuntimeSettings(settings);

/* How to update using one of the preset templates */
await this.reader.updateRuntimeSettings(EnumDBRPresetTemplate.VIDEO_SPEED_FIRST);

/* How to update the settings using a JSON string */
await this.reader.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.

resetRuntimeSettings(): Promise<boolean>

Code Snippet

await this.reader.resetRuntimeSettings();

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.

Code Snippet

let settingString = await this.reader.outputRuntimeSettingsToString();

startScanning

Start the barcode decoding thread.

startScanning(): Promise<void>

Code Snippet

await this.reader.startScanning();

stopScanning

Stop the barcode decoding thread.

stopScanning(): Promise<void>

Code Snippet

await this.reader.stopScanning();

addResultListener

Specifies an event handler that fires after the library finishes scanning a frame.

addResultListener(listener: (results: BarcodeResult[]) => void): void

Parameters

listener: The event listener that handles callback when barcode result is returned by the library.

Code Snippet

state = {
  results: null
};
componentDidMount() {
  (async () => {
    try {
      await DCVBarcodeReader.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
    } catch (e) {
      console.log(e);
    }
    this.reader = await DCVBarcodeReader.createInstance();
    await this.reader.startScanning();
    this.reader.addResultListener((results) => {
      this.setState({results});
    });
  })();
}

removeAllResultListeners

Remove all existing result listener.

removeAllResultListeners(): void;

Code Snippet

async componentWillUnmount() {
  ...
  // Remove the result listener when your component is unmount.
  this.reader.removeAllResultListeners()
}

decodeFile

Decode barcodes from an image file.

decodeFile(filePath: string): Promise<BarcodeResult[]>;

Parameters

filePath: The Path of the image file.

Code Snippet

try {
  await DCVBarcodeReader.initLicense("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9")
} catch (e) {
  console.log(e);
}
reader = await DCVBarcodeReader.createInstance();
result = reader.decodeFile("Your file path");

This page is compatible for:

Version 1.0

Is this page helpful?

YesYes NoNo

In this article:

latest version

  • Latest version
Change +
© 2003–2022 Dynamsoft. All rights reserved.
Privacy Statement / Site Map / Home / Purchase / Support