Resource Base
Table of contents

Thanks for downloading Dynamsoft Barcode Reader Package!

Your download will start shortly. If your download does not begin, click here to retry.

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 Dynamsoft Capture Vision.
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.
receiveResultStream Receive the stream to listen all the barcode results after the library finishes scanning a frame.
decodeFile Decode barcodes from an image file.
enableResultVerification Enable result cross verification. The output result will be double-checked to make sure the accuracy.
setModeArgument Mode arguments are the optional settings of mode parameters in DBRRuntimeSettings. You can use setModeArgument to configure these arguments.
getModeArgument Get the value of the specified mode argument.
enableEnhancedFeatures Enable the specified enhanced feature(s).
disableEnhancedFeatures Disable the specified enhanced feature(s).
setZoomFactor Set the zoom factor.
setAutoZoomRange Set the auto zoom range.
getAutoZoomRange Get the auto zoom range.
getMaxZoomFactor Get the max zoom factor.

initLicense

Initialize the license of Dynamsoft Capture Vision.

static Future<bool> initLicense(String license)

Parameters

license: A license key.

Code Snippet

try {
    await DCVBarcodeReader.initLicense('Put-Your-License-Here');
} catch (e) {
    print('license error = $e');
}

createInstance

Create a barcode reader instance.

static Future<DCVBarcodeReader> createInstance() async

Return Value

A barcode reader instance.

Code Snippet

late final DCVBarcodeReader _barcodeReader;
_barcodeReader = await DCVBarcodeReader.createInstance();

getVersion

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

Future<String?> getVersion()

Return Value

The Version of DCVBarcodeReader.

Code Snippet

late final DCVBarcodeReader _barcodeReader;
_barcodeReader = await DCVBarcodeReader.createInstance();
String dbrVersion = await _barcodeReader.getVersion();

getRuntimeSettings

Get the current runtime settings of DCVBarcodeReader.

Future<DBRRuntimeSettings> getRuntimeSettings()

Return Value

An object of DBRRuntimeSettings that stores the runtime settings.

Code Snippet

late final DCVBarcodeReader _barcodeReader;
_barcodeReader = await DCVBarcodeReader.createInstance();
try {
  DBRRuntimeSettings currentSettings = await _barcodeReader.getRuntimeSettings();
} catch (e) {
  print('error = $e');
}

updateRuntimeSettings

Update the barcode decoding settings with a DBRRuntimeSettings struct.

Future<void> updateRuntimeSettings(DBRRuntimeSettings settings)

Parameters

Settings: An object that stores barcode reader runtime settings.

Code Snippet

late final DCVBarcodeReader _barcodeReader;
_barcodeReader = await DCVBarcodeReader.createInstance();
try {
  DBRRuntimeSettings settings = await _barcodeReader.getRuntimeSettings();
  // Configure your barcode settings.
  await _barcodeReader.updateRuntimeSettings(settings);
} catch (e) {
  print('error = $e');
}

updateRuntimeSettingsFromTemplate

Update the barcode decoding settings with a preset template.

Future<void> updateRuntimeSettingsFromTemplate(EnumDBRPresetTemplate template) 

Parameters

template: An enumeration member of EnumDBRPresetTemplate.

Code Snippet

late final DCVBarcodeReader _barcodeReader;
_barcodeReader = await DCVBarcodeReader.createInstance();
await _barcodeReader.updateRuntimeSettingsFromTemplate(EnumDBRPresetTemplate.DEFAULT);

updateRuntimeSettingsFromJson

Update the barcode decoding settings with a JSON template.

Future<void> updateRuntimeSettingsFromJson(String jsonString)

Parameters

jsonString: An JSON string that includes barcode reader settings.

Code Snippet

late final DCVBarcodeReader _barcodeReader;
_barcodeReader = await DCVBarcodeReader.createInstance();
try {
  await _barcodeReader.updateRuntimeSettingsFromJson("{\"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\"}");
} catch (e) {
  print('error = $e');
}

resetRuntimeSettings

Reset the barcode decoding settings.

Future<void> resetRuntimeSettings()

Code Snippet

late final DCVBarcodeReader _barcodeReader;
_barcodeReader = await DCVBarcodeReader.createInstance();
try {
  await _barcodeReader.resetRuntimeSettings();
} catch (e) {
  print('error = $e');
}

outputRuntimeSettingsToString

Output the barcode decoding settings to string.

Future<String?> outputRuntimeSettingsToString()

Return Value

A string that stores the barcode decoding settings. The barcode settings string can be applied to debug barcode decoding settings.

Code Snippet

late final DCVBarcodeReader _barcodeReader;
_barcodeReader = await DCVBarcodeReader.createInstance();
try {
  String settingString = await _barcodeReader.outputRuntimeSettingsToString();
} catch (e) {
  print('error = $e');
}

startScanning

Start the barcode decoding thread.

Future<void> startScanning()

Code Snippet

late final DCVBarcodeReader _barcodeReader;
_barcodeReader = await DCVBarcodeReader.createInstance();
await _barcodeReader.startScanning();

stopScanning

Stop the barcode decoding thread.

Future<void> stopScanning()

Code Snippet

late final DCVBarcodeReader _barcodeReader;
_barcodeReader = await DCVBarcodeReader.createInstance();
await _barcodeReader.stopScanning();

receiveResultStream

Receive the stream to listen all the barcode results after the library finishes scanning a frame.

Stream<List<BarcodeResult>> receiveResultStream()

Return Value

Stream that stores a list of BarcodeResult

Code Snippet

late final DCVBarcodeReader _barcodeReader;
_barcodeReader = await DCVBarcodeReader.createInstance();
_barcodeReader.startScanning();
_barcodeReader.receiveResultStream().listen((List<BarcodeResult> res) {});

decodeFile

Decode barcodes from an image file.

Future<List<BarcodeResult>> decodeFile(String path)

Parameters

path: The Path of the image file.

Code Snippet

late final DCVBarcodeReader _barcodeReader;
_barcodeReader = await DCVBarcodeReader.createInstance();
final result = await _barcodeReader.decodeFile("Your file path");

enableResultVerification

Enable result cross verification. The output result will be double-checked to make sure the accuracy.

Future enableResultVerification(bool isEnable)

Parameters

isEnable: Set the bool value to true to enable the result cross verification.

Code Snippet

late final DCVBarcodeReader _barcodeReader;
_barcodeReader = await DCVBarcodeReader.createInstance();
_barcodeReader.enableResultVerification(true);

setModeArgument

Added in version 1.2.0.

Mode arguments are the optional settings of mode parameters in DBRRuntimeSettings. You can use setModeArgument to configure these arguments.

Future setModeArgument(String modesName, int index, String argumentName, String argumentValue)

Parameters

modesName: The name of the mode parameter that you want to make changes. index: The array index of mode parameter. argumentName: The name of the mode argument to set. argumentValue: The value of the mode argument to set.

Code Snippet

Suppose that you specified [BM_LOCAL_BLOCK, BM_THRESHOLD] for mode parameter binarizationModes and you want to set the value of mode argument BlockSizeX of mode BM_LOCAL_BLOCK to 50. The following code snippet is how you can make the settings:

/// Configure the mode parameters first.
DBRRuntimeSettings currentSettings = await _barcodeReader.getRuntimeSettings();
currentSettings.binarizationModes = [EnumBinarizationMode.BM_LOCAL_BLOCK, EnumBinarizationMode.BM_THRESHOLD];
await _barcodeReader.updateRuntimeSettings(currentSettings);
/// Set mode argument
await _barcodeReader.setModeArgument("binarizationModes",0,"BlockSizeX","50");

getModeArgument

Added in version 1.2.0.

Get the current setting of the specified mode argument.

Future getModeArgument(String modesName, int index, String argumentName)

Parameters

modesName: The name of the mode parameter that you want to make changes. index: The array index of mode parameter. argumentName: The name of the mode argument to set.

Code Snippet

String blockSizeX = await _barcodeReader.getModeArgument("binarizationModes",0,"BlockSizeX");

enableEnhancedFeatures

Added in version 1.3.0.

Enable the specified enhanced feature(s).

Available features:

Feature Description Enumeration Member
Frame Filter Filter out low quality frames by sharpness evaluation. EF_FRAME_FILTER
Sensor Control Filter out all frames produced when the device is shaking (sensor is required). EF_SENSOR_CONTROL
Enhanced focus Additional focus control mechanism that helps device to focus. EF_ENHANCED_FOCUS
Auto Zoom Enable the camera to auto zoom-in to close up to the barcode. EF_AUTO_ZOOM
Smart torch Display the torch button only when the environment light is too dark. EF_SMART_TORCH
Future<void> enableEnhancedFeatures (EnumEnhancedFeatures features)

Parameters

features: Specify the enhanced feature(s) to enable. You can use a combined value of EnumEnhancedFeatures to specify multiple features.

disableEnhancedFeatures

Added in version 1.3.0.

Disable the specified enhanced feature(s).

Future<void> disableEnhancedFeatures (EnumEnhancedFeatures features)

Parameters

features: Specify the enhanced feature(s) to enable. You can use a combined value of EnumEnhancedFeatures to specify multiple features.

setZoomFactor

Added in version 1.3.0.

Set the zoom factor.

Future<void> setZoomFactor(double factor)

Parameters

factor: The zoom factor.

setAutoZoomRange

Added in version 1.3.0.

Set the auto zoom range.

Future<void> setAutoZoomRange (RangeValue zoomFactor)

Parameters

zoomFactor: The auto zoom range.

getAutoZoomRange

Added in version 1.3.0.

Get the auto zoom range.

Future<RangeValue> getAutoZoomRange ()

Parameters

getMaxZoomFactor

Added in version 1.3.0.

Get the max zoom factor.

Future<double> getMaxZoomFactor ()

This page is compatible for:

Version 1.0

Is this page helpful?

YesYes NoNo

In this article:

latest version

    • Latest version
    • Version 2.x
      • Version 2.2.10
      • Version 2.0.21
      • Version 2.0.20
      • Version 2.0.10
      • Version 2.2.10
      • Version 2.0.21
      • Version 2.0.20
      • Version 2.0.10
    • Version 1.x
      • Version 1.2.1
      • Version 1.2.0
      • Version 1.1.0
      • Version 1.0.0
      • Version 1.0.4
      • Version 1.0.3
      • Version 1.0.2
      • Version 1.0.1
      • Version 1.0.0
      • Version 1.1.13
      • Version 1.1.12
      • Version 1.1.11
      • Version 1.1.9
      • Version 1.1.8
      • Version 1.1.7
      • Version 1.1.6
      • Version 1.1.5
      • Version 1.1.4
      • Version 1.1.3
      • Version 1.1.2
      • Version 1.1.1
      • Version 1.1.0
      • Version 1.0.0
      • Version 1.0.4
      • Version 1.0.3
      • Version 1.0.2
      • Version 1.0.1
      • Version 1.0.0
    Change +
    © 2003–2024 Dynamsoft. All rights reserved.
    Privacy Statement / Site Map / Home / Purchase / Support