Dev Center
Swift
Objective-C
Table of contents

Quickly Adjust on the Performance

By following the previous guide, I believe you have managed to create your own barcode reader project. However, you might be still stuck in some aspects:

  • There are some barcodes I can’t recognize.
  • The processing speed is too slow.
  • There are misreading results.

In this article, we will share some solutions to help you solve the above issues.

How to Decode the Unrecognized Barcodes

There are several reasons that may cause a barcode unrecognized.

Enhance Barcode Localization

LocalizationModes is the parameter that determines how the library find a barcode zone from the image. If set multiple modes for the parameter, the library will continue to try other LocalizationModes until the barcode count reaches the expected count, or all modes have been run. The candidate modes are available as follow:

  • LM_CONNECTED_BLOCKS
  • LM_STATISTICS
  • LM_LINES
  • LM_SCAN_DIRECTLY
  • LM_STATISTICS_MARKS
  • LM_STATISTICS_POSTAL_CODE
  • LM_CENTRE
  • LM_ONED_FAST_SCAN

The LocalizationModes is available for setting via either SimplifiedCaptureVisionSettings or the template file.

Update LocalizationModes via SimplifiedCaptureVisionSettings

try {
   // Obtain current runtime settings. `cvr` is an instance of `CaptureVisionRouter`.
   // Here we use `EnumPresetTemplate.PT_READ_BARCODES` as an example. You can change it to your own template name or the name of other preset template.
   SimplifiedCaptureVisionSettings captureVisionSettings = cvr.getSimplifiedSettings(EnumPresetTemplate.PT_READ_BARCODES);
   captureVisionSettings.barcodeSettings.localizationModes = new int[]{EnumLocalizationModes.LM_CONNECTED_BLOCKS,EnumLocalizationModes.LM_STATISTICS,EnumLocalizationModes.LM_LINES};
   // Update the settings. Remember to specify the same template name you used when getting the settings.
   cvr.updateSettings(EnumPresetTemplate.PT_READ_BARCODES, captureVisionSettings);
} catch (CaptureVisionRouterException e) {
   e.printStackTrace();
}

Update LocalizationModes via Template

Modify the LocalizationModes section of your template file and upload it with initSettingsFromFile method.

{
   "LocalizationModes" :
   [
      {
         "Mode" : "LM_CONNECTED_BLOCKS"
      },
      {
         "Mode" : "LM_STATISTICS"
      },
      {
         "Mode" : "LM_LINES"
      }
   ]
}

Process Blurry Barcode Zone

DeblurModes is the parameter that determines how to decode the localized barcode zone, which is the last stage of the barcode decoding algorithm. The more DeblurModes you enable, the higher possibilty the barcode zone is decoded. The parameter is available for setting via both SimplifiedCaptureVisionSettings and the template file.

Update DeblurModes via SimplifiedCaptureVisionSettings

try {
   // Obtain current runtime settings. `cvr` is an instance of `CaptureVisionRouter`.
   // Here we use `EnumPresetTemplate.PT_READ_BARCODES` as an example. You can change it to your own template name or the name of other preset template.
   SimplifiedCaptureVisionSettings captureVisionSettings = cvr.getSimplifiedSettings(EnumPresetTemplate.PT_READ_BARCODES);
   captureVisionSettings.barcodeSettings.deblurModes = new int[]{EnumDeblurMode.DM_THRESHOLD_BINARIZATION,EnumDeblurMode.DM_DIRECT_BINARIZATION,EnumDeblurMode.DM_GRAY_EQUALIZATION,EnumDeblurMode.DM_DEEP_ANALYSIS};
   // Update the settings. Remember to specify the same template name you used when getting the settings.
   cvr.updateSettings(EnumPresetTemplate.PT_READ_BARCODES, captureVisionSettings);
} catch (CaptureVisionRouterException e) {
   e.printStackTrace();
}

Update DeblurModes via Template

Modify the DeblurModes section of your template file and upload it with initSettingsFromFile or initSettings method.

{
    "DeblurModes":
    [
        {
            "Mode": "DM_BASED_ON_LOC_BIN"
        },
        {
            "Mode": "DM_THRESHOLD_BINARIZATION" 
        },
        {
            "Mode": "DM_DIRECT_BINARIZATION" 
        },
        {
            "Mode": "DM_GRAY_EQUALIZATION" 
        },
        {
            "Mode": "DM_DEEP_ANALYSIS" 
        }
    ]
}

Read Small Scaled Barcode

Generally, it is suggested to zoom-in the camera to enlarge the module size of the barcode. If you are using DynamsoftCameraEnhancer (DCE) to setup the image source, you can use its zoom features to control the zoom-in/out of the camera. If the camera control is not available for use device or you are going to decode from a still image, please read about how to use the ScaleUpMode to enlarge the barcode zone.

Enable the auto-zoom feature of DCE:

try {
   dce.enableEnhancedFeatures(EnumEnhancerFeatures.EF_AUTO_ZOOM);
} catch (CameraEnhancerException e) {
   e.printStackTrace();
}

Use DCE to set the zoom factor:

try {
   dce.setZoomFactor(2.5f);
} catch (CameraEnhancerException e) {
   e.printStackTrace();
}

How to Improve the Speed

You use the following attempts to speed up the barcode decoding:

How to use the SimplifiedCaptureVisionSettings and the template is introduced above in the Enhance Barcode Localization section. Please reference the above documents.

How to Reduce the Misreading Results

  • Implement result filter via SimplifiedCaptureVisionSettings.
    • barcodeSettings.minResultConfidence to filter out the low confidence results;
    • barcodeSettings.minBarcodeTextLength & barcodeSettings.barcodeTextRegExPattern to filter out unnecessary results;
  • Implement multi-frame cross filter.

How to Implement Multi-frame Cross Filter

MultiFrameResultCrossFilter filter =  new MultiFrameResultCrossFilter();
filter.enableResultCrossVerification(EnumCapturedResultItemType.CRIT_BARCODE,true);
cvr.addResultFilter(filter);

Further Improvements

Feel free to contact us for further improvements on your performance . DBR has a lot of built-in parameters for image processing, localization supporting and barcode decoding. Please feedback your problems to us so that our technical support team will help you configure the parameters to match your requirements.

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.2.10
    • Version 10.0.21
    • Version 10.0.20
    • Version 10.2.10
    • Version 10.0.21
    • Version 10.0.20
  • Version 9.x
    • Version 9.6.40
    • Version 9.6.20
    • Version 9.6.11
    • Version 9.6.10
    • Version 9.6.0
    • Version 9.4.0
    • Version 9.2.11
    • Version 9.2.10
    • Version 9.0.2
    • Version 9.0.1
    • Version 9.0.0
    • Version 9.6.40
    • Version 9.6.20
    • Version 9.6.10
    • Version 9.6.0
    • Version 9.4.0
    • Version 9.2.13
    • Version 9.2.10
    • Version 9.0.2
    • Version 9.0.1
    • Version 9.0.0
  • Version 8.x
    • Version 8.9.3
    • Version 8.9.1
    • Version 8.9.0
    • Version 8.8.0
    • Version 8.6.0
    • Version 8.4.0
    • Version 8.2.1
    • Version 8.2.0
    • Version 8.1.2
    • Version 8.1.0
    • Version 8.0.0
    • Version 8.9.3
    • Version 8.9.1
    • Version 8.9.0
    • Version 8.8.0
    • Version 8.6.0
    • Version 8.4.0
    • Version 8.2.1
    • 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
    • Version 7.6.0
    • Version 7.5.0
Change +