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.

Manually Define Region of Interest

By default, DBR will locate the code region and decode in the entire image, but if the user is concerned about some specific regions rather than the entire image, you can define a Region of Interest, referred to as ROI, by the parameter RegionDefinition. After defining a specific region, DBR will only decode barcodes within that region. Of course, this is very conducive to a faster performance. This article will introduce the definition of ROI and its configurable parameters: ExpectedBarcodesCount, BarcodeFormatIds,BarcodeFormatIds_2, FormatSpecificationNameArray.

Definition of ROI RegionDefinition

If the user is only concerned about certain regions of the image, then in JSON, you can define one or more areas through the RegionDefinition object. You need to specify the four-corner coordinates of the area Top, Left, Right, Bottom and Nameof different ROIs. The parameter MeasuredByPercentage can be used to set whether the four-corner coordinate unit of the ROI is pixels or a percentage, which is defined the original image width and height as 100%.

To use the defined RegionDefinition, please specify the ROI Name through RegionDefinitionNameArray.

Expected count of barcodes in ROI - ExpectedBarcodesCount

In RegionDefinition, ExpectedBarcodesCount can be used to specify the number of expected barcodes in the region. The clear expectation of the number of barcodes helps DBR to determine whether it has met the requirements and exit in time.

Barcode Format in ROI - BarcodeFormatIds, BarcodeFormatIds_2

These two parameters set the code type to be processed in the ROI. Specific configuration barcode format can be used to improve the processing speed of DBR, otherwise DBR may waste time on irrelevant barcode format.

Specific barcode format configuration used by ROI - FormatSpecificationNameArray

This parameter sets names corresponding to FormatSpecifications used by the current ROI. Afterwards, the ROI will use the corresponding FormatSpecifications configuration. The default value is empty, using the global FormatSpecifications configuration. If you want to configure some specific barcode format in ROI, you should use this parameter. For a detailed description of FormatSpecifications, please refer to our documentation Specific barcode format configuration.

Examples

The following shows how to use RuntimeSetting and JSON template to demonstrate the usage of RegionDefinition parameter.

  • RuntimeSetting
    CBarcodeReader* reader = new CBarcodeReader();     
    reader->InitLicense("Insert license");    
    PublicRuntimeSettings* runtimeSettings = new PublicRuntimeSettings();     
    reader->GetRuntimeSettings(runtimeSettings); //get current RuntimeSettings      
    runtimeSettings->region.regionTop = 10;         
    runtimeSettings->region.regionBottom = 50;      
    runtimeSettings->region.regionLeft = 20;        
    runtimeSettings->region.regionRight = 30;      
    runtimeSettings->regionMeasurdByPercentage = 1; //define Region range in Percentage
    char sError[512];     
    reader->UpdateRuntimeSettings(runtimeSettings, sError, 512); //update RuntimeSettings    
    reader->DecodeFile("File Path", ""); //decoding      
    TextResultArray* paryResult = NULL;     
    reader->GetAllTextResults(&paryResult); //get decoded results  
    dynamsoft::dbr::CBarcodeReader::FreeTextResults(&paryResult);     
    delete runtimeSettings;     
    delete reader;  
    
  • JSON Template
    { 
      "ImageParameter": {
          "BarcodeFormatIds": ["BF_ALL"],
          "RegionDefinitionNameArray": ["RP_1", "RP_2"]
      }, 
      "RegionDefinitionArray": [
          {
              "Name": "RP_1",   
              "BarcodeFormatIds": ["BF_CODE_39"],
              "Top": 20,         
              "Bottom": 80,      
              "Left": 20,        
              "Right": 80,      
              "ExpectedBarcodesCount": 10,
              "MeasuredByPercentage": 0
          }, 
          {
              "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

latest version

  • Latest version
  • Version 10.x
    • Version 10.2.0
    • Version 10.0.21
    • Version 10.0.20
    • Version 10.0.10
    • Version 10.0.0
  • Version 9.x
    • Version 9.6.40
    • 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 +