The Preview of Dynamsoft Barcode Reader v6.0 for Windows

Dynamsoft Barcode Reader 6.0 is on the way. The major upgrade version improves the performance of barcode detection and recognition dramatically. It is over two times faster than version 5.2. In this post, I will disclose some new features and demonstrate the corresponding APIs.

Dynamsoft Barcode Reader SDK v6.0 Preview

Parameter templates

The new barcode SDK version aims to simplify API usage by dynamically loading customized parameter templates. A template is just a JSON file:

    "Version": "1.0",
    "ImageParameters": {
        "Name": "CUSTOM",
        "Timeout": 2147483647,
        "MaxImageDimension": 4000000,
        "PDFRasterDPI": 300,
        "ImageType": "AutoDetection",
        "TextFilterMode": "Enable",
        "MinImageDimensionToFilterText": 1000000,
        "RegionPredetectionMode": "Enable",
        "MinImageDimensionToPredetectRegion": 1000000,
        "LocalizationMode": "Lines",
        "BarcodeFormatIds": "ALL",
        "MaxBarcodesCount": 2147483647,
        "MaxThreadCount": 4,
        "DeblurLevel": 9,
        "Pages": "",
        "BarcodeInvertMode": "DarkOnLight"

The key “Name” is necessary. Once you set a pair of key and value, it will overwrite the default one.

You can create as many as templates you like, and then add them to a global setting file default.settings.json:

    "Version": "1.0",
    "GlobalParameters": {
        "Name": "GLOBAL_DEFAULT",
        "MaxThreadCount": 4
    "ParameterTemplateArray": [

Use function LoadSettingsFromFile() to load the global setting file.

int iRet = reader.LoadSettingsFromFile(templatePath, szErrorMsg, 256);

The templatePath has to be an absolute path. Usually, we put executable files and templates together. Use following C++ code to get the base path and compose the absolute path:

    char szErrorMsg[256];
    char basePath[255] = "";
    _fullpath(basePath, argv[0], sizeof(basePath));
    // Get the directory
    int iLast = 0;
    for (int i = 0; ; i++) {
        char tmp = basePath[i];
        if (tmp == '\\')
            iLast = i;
        else if (tmp == '\0')

    char templatePath[1024];
    strncpy_s(templatePath, basePath, iLast);

    // Get the full path
    const char\* pszSettingFile = "\\templates\\default.settings.json";
    strcat_s (templatePath, pszSettingFile);

API changes

The template feature is pretty convenient and flexible in my view. According to different scenes and cases, I don’t need always to modify my code. The only thing I need to do is to adjust the parameters in JSON file. To make the customized template work, set the template name when calling barcode detection API.

iRet = reader.DecodeFile(pszImageFile, "CUSTOM");

If you just provide a file name, the method will load default settings internally.

There is also some code difference between 5.2 and 6.0 when getting the barcode results.

dbr 5.2 vs. dbr 6.0

CMake: how to copy template directory to the output folder

After building the project, you have to copy the templates folder to the target directory if you use a path relative to the executable file. The command is copy_directory:

add_custom_command(TARGET BarcodeReader POST_BUILD 
        COMMAND ${CMAKE_COMMAND} -E copy_directory
        $<TARGET_FILE_DIR:BarcodeReader>/"templates" )

Performance comparison: 5.2 vs. 6.0

Let’s take a glimpse of the performance comparison.

DBR v5.2

PS G:\cmake> .\build\Debug\BarcodeReader.exe G:\cmake\images\AllSupportedBarcodeTypes.tif
Barcode Reader Version 5.2
Total barcode(s) found: 13. Total time spent: 0.219 seconds

Dynamsoft Barcode Reader 5.2

DBR v6.0

PS F:\cmake\build> .\Debug\BarcodeReader.exe F:\cmake\images\AllSupportedBarcodeTypes.tif
Barcode Reader Version 6.0
Total barcode(s) found: 13. Total time spent: 0.094 seconds

Dynamsoft Barcode Reader 6.0 Preview

Dynamsoft Barcode Reader 6.0 is apparently the winner that has better performance and flexibility.

Source Code

Search Blog Posts