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

Dynamsoft Barcode Reader (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 TargetROIDef. After defining a specific region, DBR will only decode barcodes within that region. Of course, this is very conducive to increasing the speed. Please refer to Design of the TargetROIDef Object to learn more about TargetROIDef and how it works,.

Single Region Specification

  • Configure region via SimplifiedCaptureVisionSettings
  • C++
char szErrorMsg[256] = {0};
// Obtain current runtime settings of `CCaptureVisionRouter` instance.
CCaptureVisionRouter* cvr = new CCaptureVisionRouter;
SimplifiedCaptureVisionSettings settings;
cvr->GetSimplifiedSettings(CPresetTemplate::PT_READ_BARCODES, &settings);
// Specify the ROI
settings.roi.points[0].Set(10, 10);
settings.roi.points[1].Set(90, 10);
settings.roi.points[2].Set(90, 90);
settings.roi.points[3].Set(10, 90);
settings.roiMeasuredInPercentage = 1;
// Update the settings.
cvr->UpdateSettings(CPresetTemplate::PT_READ_BARCODES, &settings, szErrorMsg, 256);
  • Configure region via JSON Template
{
    "CaptureVisionTemplates": [
        {
            "Name" : "CV_0",
            "ImageROIProcessingNameArray": ["TA_0" ]
        }       
    ],
    "TargetROIDefOptions" : [
        {
            "Name" : "TA_0",
            "Location":
            {
               "Offset": 
               {
                  "ReferenceObjectOriginIndex": 0,
                  "ReferenceObjectSizeType": "default",
                  "MeasuredByPercentage" : 1,
                  "FirstPoint" : [ 10, 10 ],
                  "SecondPoint" : [ 90, 10 ],
                  "ThirdPoint" : [ 90, 90 ],
                  "FourthPoint" : [ 10, 90 ]
               }
            },
            "TaskSettingNameArray": [ "BR_0" ]
        }
    ],
    "BarcodeReaderTaskSettingOptions": [
        {
            "Name" : "BR_0"
        }
    ]
}

Apply the above settings following the article Use Templates for Configuring Parameters.

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.

Below is an example template illustrating how to configure two ROIs with different barcode format parameter settings.

{
    "CaptureVisionTemplates": [
        {
            "Name" : "CV_0",
            "ImageROIProcessingNameArray": ["TA_0", "TA_1"]
        }       
    ],
    "TargetROIDefOptions" : [
        {
            "Name" : "TA_0",
            "Location":
            {
               "Offset": 
               {
                  "ReferenceObjectOriginIndex": 0,
                  "ReferenceObjectSizeType": "default",
                  "MeasuredByPercentage" : 1,
                  "FirstPoint" : [ 0, 0 ],
                  "SecondPoint" : [ 100, 0 ],
                  "ThirdPoint" : [ 100, 20 ],
                  "FourthPoint" : [ 0, 20 ]
               }
            },
            "TaskSettingNameArray": ["BR_0"]
        },
        {
            "Name" : "TA_1",
            "Location":
            {
               "Offset": 
               {
                  "ReferenceObjectOriginIndex": 0,
                  "ReferenceObjectSizeType": "default",
                  "MeasuredByPercentage" : 1,
                  "FirstPoint" : [ 0, 80 ],
                  "SecondPoint" : [ 100, 80 ],
                  "ThirdPoint" : [ 100, 100 ],
                  "FourthPoint" : [ 0, 100 ]
               }
            },
            "TaskSettingNameArray": ["BR_1"]
        }
    ],
    "BarcodeReaderTaskSettingOptions": [
        {
            "Name" : "BR_0",
            "BarcodeFormatIds": ["BF_ONED"]
        },
        {
            "Name" : "BR_1",
            "BarcodeFormatIds": ["BF_QR_CODE"]
        }
    ]
}

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

In this article:

latest version

  • Latest version
  • Version 10.x
    • Version 10.0.21
    • Version 10.0.20
    • Version 10.0.10
    • Version 10.0.0
  • Version 9.x
    • Version 9.6.33
    • Version 9.6.32
    • Version 9.6.31
    • Version 9.6.30
    • Version 9.6.20
    • Version 9.6.10
    • 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 +