The Hidden Image Data of Dynamsoft Barcode SDK You Don’t Know

While scanning single or multiple barcodes with a barcode SDK, most of the developers only concern about the trade-off between decoding speed and recognition accuracy, for they cannot get other data. Since from version 8.0, Dynamsoft exposes more parameters and intermediate results (E.g., grayscale image, binary image, barcode localization results, etc.) to developers for app debugging and optimizing, which makes Dynamsoft Barcode SDK stand out from commercial barcode SDKs. In this article, I will go through some relevant parameters and APIs.


  • CMake
  • OpenCV 4.5.0. For Windows, you need to add “OpenCV_DIR = C:\opencv\build" to system environment variables.

Linking OpenCV and Dynamsoft Barcode SDK in CMake Project

If you have successfully installed OpenCV, linking OpenCV libraries is quite simple:

As for Dynamsoft Barcode SDK, the link directories are set manually:

Getting Transformed Images and Predicted Barcode Bounding Boxes

Let’s look under the hood to see how Dynamsoft barcode reader works.

The general way of scanning barcodes with Dynamsoft Barcode Reader is as follows:

As a matter of fact, you can get more than just the final results. All transformed image data generated during the barcode decoding process can be saved for further use.

There are some enumeration types defined in the DynamsoftBarcodeReader.h header file:

According to the definitions, it is easy to infer what image processing algorithms that Dynamsoft has adopted. Now, I write some code snippets to demonstrate how to get grayscale image, binary image and barcode bounding boxes.

Before decoding barcode images, configure the intermediate data you want to acquire:

By default, the saving mode is IRSM_MEMORY. If you want to save data to file system, you can change it to IRSM_FILESYSTEM. The scaleDownThreshold is used to control the input image size. If the width of your input image is larger than the threshold, the image will be scaled down.

After calling a decoding method, we can invoke GetIntermediateResults() to get a list of mixed data:

If the data type is IMRDT_IMAGE, you can get an image buffer:

If the data type is IMRDT_LOCALIZATIONRESULT, you can get barcode bounding boxes:

We use OpenCV imshow() function to display the transformed images and barcode bounding boxes.

Grayscale Image

Binary Image

Barcode Bounding Box

You can write your code to explore more intermediate data generated by Dynamsoft Barcode SDK.


Source Code

Originally published at on December 15, 2020.

Manager of Dynamsoft Open Source Projects | Tech Lover

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store