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 >
Dev Center
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.

Read a Specific Area/Region

DBR will locate the code region and decode the entire image by default. However, if only a specific region of the image or video is required to locate the barcode, you can define a Region Of Interest (ROI) via the parameter RegionDefinition. After defining a specific region, DBR will only decode barcodes within that region. Of course, this is very conducive to increasing the speed. To learn more about RegionDefinition and how it works, please refer to this section of the Structure and Interfaces page.

RegionDefinition is the struct that is designed to specify the ROI.

  • RegionTop: The y coordinate of the Top border of the region.
  • RegionBottom: The y coordinate of the Bottom border of the region.
  • RegionLeft: The x coordinate of the left border of the region.
  • RegionRight: The x coordinate of the right border of the region.
  • RegionMeasuredByPercentage: If measured by percentage, the above values will be recognized as percentages (1 to 100). Otherwise, the above values will be recognized as pixel length.

Notes:

  • You can either configure these settings via the PublicRuntimeSettings struct or via a JSON template.
  • When using PublicRuntimeSettings, you can only specify one region.
  • When using JSON template, you can either specify one or more regions.

Single Region Specification

To update the setting via PublicRuntimeSettings:

  • JavaScript
  • Android
  • Objective-C
  • Swift
  • Python
  • Java
  • C#
  • C++
  • C
// Obtain current runtime settings of `reader` instance.
let settings = await scanner.getRuntimeSettings();
settings.region.regionTop = 10;
settings.region.regionBottom = 90;
settings.region.regionLeft = 10;
settings.region.regionRight = 90;
settings.region.regionMeasuredByPercentage = 1;
settings.barcodeFormatIds = Dynamsoft.DBR.EnumBarcodeFormat.BF_ONED | Dynamsoft.DBR.EnumBarcodeFormat.BF_QR_CODE;
// Update the settings.
await scanner.updateRuntimeSettings(settings);
// Obtain current runtime settings of `reader` instance.
PublicRuntimeSettings settings = reader.getRuntimeSettings();
settings.region.regionTop = 10;
settings.region.regionBottom = 90;
settings.region.regionLeft = 10;
settings.region.regionRight = 90;
settings.region.regionMeasuredByPercentage = 1;
settings.barcodeFormatIds = EnumBarcodeFormat.BF_QR_CODE | EnumBarcodeFormat.BF_ONED;
// Update the settings.
reader.updateRuntimeSettings(settings);
NSError* err = nil;
// Obtain current runtime settings of `reader` instance.
iPublicRuntimeSettings* settings = [reader getRuntimeSettings:&err];
settings.region.regionTop = 10;
settings.region.regionBottom = 90;
settings.region.regionLeft = 10;
settings.region.regionRight = 90;
settings.region.regionMeasuredByPercentage = 1;
// Update the settings.
[reader updateRuntimeSettings:settings error:&err];
// Obtain current runtime settings of `barcodeReader` instance.
let settings = try? barcodeReader.getRuntimeSettings()
settings?.region.regionTop = 10
settings?.region.regionBottom = 90
settings?.region.regionLeft = 10
settings?.region.regionRight = 90
settings?.region.regionMeasuredByPercentage = 1
// Update the settings.
try? barcodeReader.updateRuntimeSettings(settings!)
# Obtain current runtime settings of `reader` instance.
settings = reader.get_runtime_settings()
settings.region.region_top = 10
settings.region.region_bottom = 90
settings.region.region_left = 10
settings.region.region_right = 90
settings.region.region_measured_by_percentage = 1
# Update the settings.
reader.update_runtime_settings(settings)
// Obtain current runtime settings of `reader` instance.
PublicRuntimeSettings settings = reader.getRuntimeSettings();
settings.region.regionTop = 10;
settings.region.regionBottom = 90;
settings.region.regionLeft = 10;
settings.region.regionRight = 90;
settings.region.regionMeasuredByPercentage = 1;
settings.barcodeFormatIds = EnumBarcodeFormat.BF_ONED | EnumBarcodeFormat.BF_QR_CODE;
// Update the settings.
reader.updateRuntimeSettings(settings);
// Obtain current runtime settings of `reader` instance.
PublicRuntimeSettings settings = reader.GetRuntimeSettings();
settings.Region.RegionTop = 10;
settings.Region.RegionBottom = 90;
settings.Region.RegionLeft = 10;
settings.Region.RegionRight = 90;
settings.Region.RegionMeasuredByPercentage = 1;
// Update the settings.
reader.UpdateRuntimeSettings(settings);
PublicRuntimeSettings settings;
char szErrorMsg[256] = {0};
// Obtain current runtime settings of `reader` instance.
reader.GetRuntimeSettings(&settings);
settings.region.regionTop = 10;
settings.region.regionBottom = 90;
settings.region.regionLeft = 10;
settings.region.regionRight = 90;
settings.region.regionMeasuredByPercentage = 1;
// Update the settings.
reader.UpdateRuntimeSettings(&settings, szErrorMsg, 256);
PublicRuntimeSettings settings;
char szErrorMsg[256] = {0};
// Obtain current runtime settings of `reader` instance.
DBR_GetRuntimeSettings(reader, &settings);
settings.region.regionTop = 10;
settings.region.regionBottom = 90;
settings.region.regionLeft = 10;
settings.region.regionRight = 90;
settings.region.regionMeasuredByPercentage = 1;
// Update the settings.
DBR_UpdateRuntimeSettings(reader, &settings, szErrorMsg, 256);

To do the same with a JSON Template. Read more on RuntimeSettings and templates:

{ 
   "ImageParameter": {
      "BarcodeFormatIds": ["BF_ALL"],
      "RegionDefinitionNameArray": ["RP_1"]
   }, 
   "RegionDefinition": {
      "Name": "RP_1",
      "Top": 10,
      "Bottom": 90,
      "Left": 10,
      "Right": 90,
      "MeasuredByPercentage": 1,
   },
   "Version": "3.0"
}

Multiple Region Specification

If you need to specify more than one ROI, you have to use a JSON template. Furthermore, you can even configure different barcode-decoding parameter settings for each region. Read more on RuntimeSettings and templates:

{
   "ImageParameter": {
      "RegionDefinitionNameArray": ["RP_1", "RP_2"]
   },
   "RegionDefinitionArray": [
      {
         // Settings for ROI 1
         "Name": "RP_1",
         "BarcodeFormatIds": ["BF_CODE_39"],
         "Top": 20,
         "Bottom": 80,
         "Left": 20,
         "Right": 80,
         "ExpectedBarcodesCount": 10,
         "MeasuredByPercentage": 0
      },
      {
         // Settings for ROI 2
         "Name": "RP_2",
         "BarcodeFormatIds": ["BF_CODE_93"],
         "BarcodeFormatIds_2": ["BF_DOTCODE"],
         "Top": 30,
         "Bottom": 70,
         "Left": 30,
         "Right": 80,
         "MeasuredByPercentage": 1
      }
   ],
   "Version": "3.0"
}

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

In this article:

latest version

    • Latest version
    • Version 9.x
      • Version 9.6.0
      • Version 9.4.0
      • Version 9.2.0
      • Version 9.0.0
    • Version 8.x
      • Version 8.8.0
      • Version 8.6.0
      • Version 8.4.0
      • Version 8.2.0
      • Version 8.1.2
      • Version 8.1.0
      • Version 8.0.0
    • Version 7.x
      • Version 7.6.0
      • Version 7.5.0
    Change +