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.

How to use different localization modes

DBR provides a few localization modes to localize the barcode area. This article will introduce how to select the appropriate localization mode in different scenarios to obtain the best barcode localization results for further decoding.


Localizes barcodes by searching for connected blocks. This is optimized for clear images with obvious connected blocks, as shown below:


The image has clear connected blocks, which are highlighted below:



Localizes barcodes by searching for groups of lines. It is optimized for images with obvious straight lines. Compared with the LM_CONNECTED_BLOCKS mode, it can handle the situation where some bars (or lines) of the barcode stick to each other.

As shown in the image below, the connected blocks are destroyed because of the existence of two extra lines, which cannot be found by using LM_CONNECTED_BLOCKS.


But it still has obvious straight line characteristics, as shown in the image below. In this case, using LM_LINES is able to localize the barcode.



Localizes barcodes based on colour statistics. This mode is suitable for scenarios where the barcode area is severely damaged. For example, the original image is very large but the barcode area is small, so the barcode area may be severely damaged after image binarization, as shown in the image below:


After binarization, the position patterns is damaged, as shown below:


There are obvious black and white contrast near the barcode area, so the barcode can be successfully localized using LM_STATISTICS mode.


Localizes barcodes based on the direct scanning mode. It is the fastest among all localization modes, but it requires high barcode image quality, and the direction of the barcode must be horizontal or vertical. This mode is recommended in the real-time video scanning scenarios.

There are two additional argument parameters ScanStride and ScanDirection in this mode:

  • ScanStride

Sets the interval between adjacent scan lines. The unit is pixel. The default value is 0, which means that DBR automatically calculates the interval. The smaller the value is, the more likely it is to locate the code area, but it will also increase the time.

  • ScanDirection

Sets the scan direction, the allowed values are 0, 1, 2. The default value is 0, which means scanning in both horizontal and vertical directions. 1 means scanning only in the vertical direction, and 2 means scanning only in the horizontal direction. Setting the appropriate scanning direction can decrease the processing speed.


Localizes barcodes by dot matrix information. This mode is only applicable to DPM Code and DotCode. Below is a sample image of DotCode:



Localizes barcodes by statistics, connected blocks and straight lines. This mode is only applicable to Postal Code. Below is a sample image of Postal Code:



Localizes barcodes from centre. This mode uses the central area of the image as the suspected code area and then try to localize and decode.

Use intermediate results to obtain the localization result

If DBR successfully localizes the barcode zone, you can use the intermediate result IRT_TYPED_BARCODE_ZONE to obtain the localization result. The localization result includes “angle” (the angle of the barcode zone), “barcodeFormat” (barcode format), “confidence” (the confidence value of the barcode zone), “moduleSize” (barcode module size), “pageNumber” (0-based page number), “terminatePhase” (terminate phase), “x1y1x2y2x3y3x4y4” (the coordinates of the barcode zone).


Code snippet in C++:

    char sError[512];
    CBarcodeReader* reader = new CBarcodeReader();
    reader->InitLicense("Insert your license here");
    PublicRuntimeSettings* runtimeSettings = new PublicRuntimeSettings();
    reader->GetRuntimeSettings(runtimeSettings);          // Get the current runtime settings
    runtimeSettings->localizationModes[0] = LM_LINES;     // Only use LM_LINES as the localization mode
    runtimeSettings->localizationModes[1] = LM_SKIP;
    runtimeSettings->localizationModes[2] = LM_SKIP;
    runtimeSettings->localizationModes[3] = LM_SKIP;
    reader->DecodeFile("Insert the image file path here", "");// Start decoding
    TextResultArray* result = NULL;
    reader->GetAllTextResults(&result);                   // Get results
    int icount = result->resultsCount;
    delete runtimeSettings;
    delete reader;

Example JSON template:

    "ImageParameter": {
        "Name": "ImageParameter1", 
        "Description": "This is LocalizationMode demonstrate", 
    "Version": "3.0"

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

latest version

  • Latest version
  • Version 9.0.0
  • Version 8.9.3
  • Version 8.9.0
  • Version 8.8.7
  • Version 8.8.5
  • Version 8.8.3
  • Version 8.8.0
  • Version 8.6.3
  • Version 8.6.1
  • Version 8.6.0
  • Version 8.4.0
  • Version 8.2.5
  • Version 8.2.3
  • Version 8.2.1
  • Version 8.2.0
  • Version 8.1.3
  • Version 8.1.2
  • Version 8.1.0
  • Version 8.0.0
  • Version 7.6.0
  • Version 7.5.0
Change +
© 2003–2022 Dynamsoft. All rights reserved.
Privacy Statement / Site Map / Home / Purchase / Support