Table of contents
Swift
Objective-C

How to Read Barcodes with Small Module Size

A module is the narrowest “bar” in a 1D barcode, or the smallest “box” in a 2D barcode. Keep in mind this “bar” or “box” can be either light or dark. The figure below illustrates the module size of 1D and 2D barcodes.

Module size of barcodes

Figure 1 – Module size of 1D and 2D barcodes

In some scenarios, the barcode is very small relative to the entire image, and its module size is even smaller, making it difficult for the library to read the barcode. In this case, we can use the parameter BarcodeScaleModes in to enlarge the barcode symbol for easier processing.

For linear barcodes, a practical recommendation is to keep the narrowest module (X-dimension) at or above 2 pixels.

Particular Parameter Required

Dynamsoft Barcode Reader (DBR) provides a parameter BarcodeScaleModes that allows you to control the scale-up process when targets in the image are too small.

Scale-up is condition-based: when module size is smaller than ModuleSizeThreshold and the acute angle with the X axis is greater than AcuteAngleWithXThreshold, DBR enlarges the symbol iteratively until the effective module size reaches TargetModuleSize.

Example

Below is an example illustrating how to configure the parameter BarcodeScaleModes.

  • Update parameter BarcodeScaleModes in your JSON template

      {
          "CaptureVisionTemplates": [
              {
                  "Name": "CV_0",
                  "ImageROIProcessingNameArray": ["TA_0" ]
              }       
          ],
          "TargetROIDefOptions" : [
              {
                  "Name": "TA_0",
                  "TaskSettingNameArray": [ "BR_0" ]
              }
          ],
          "BarcodeReaderTaskSettingOptions": [
              {
                  "Name" : "BR_0",
                  "SectionArray": [
                      {
                          "Section": "ST_REGION_PREDETECTION",
                          "ImageParameterName": "IP_0"
                      },
                      {
                          "Section": "ST_BARCODE_LOCALIZATION",
                          "ImageParameterName": "IP_0"
                      },
                      {
                          "Section": "ST_BARCODE_DECODING",
                          "ImageParameterName": "IP_0",
                          "StageArray": [
                              {
                                  "Stage": "SST_SCALE_BARCODE_IMAGE",
                                  "BarcodeScaleModes": [
                                      {
                                          "Mode": "BSM_LINEAR_INTERPOLATION", 
                                          "ModuleSizeThreshold": 3,
                                          "TargetModuleSize": 8,
                                          "AcuteAngleWithXThreshold": 0
                                      },
                                  ]
                              }
                          ]
                      }
                  ]
              }
          ],
          "ImageParameterOptions": [
              {
                  "Name": "IP_0"
              }
          ]
      }
    
  • Apply the above settings following the article Use Templates for Configuring Parameters.

This page is compatible for: