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.

How to recognize accompanying text

In some scenarios, especially for 1D barcodes, a barcode can be accompanied by human readable text. This accompanying text might be useful for barcode value verification, or for further use in your application. Currently, DBR only supports the recognition of the accompanying text with 1D barcodes.

DBR provides the AccompanyingTextRecognitionModes parameter which allows you to recognize the accompanying text near the barcode. The parameter AccompanyingTextRecognitionModes is an array of AccompanyingTextRecognitionMode values.

AccompanyingTextRecognitionMode has the following enumeration values:

Enumeration Member Enumeration Value Description
ATRM_SKIP 0x00 Turn off accompanying text recognition
ATRM_GENERAL 0x01 Turn on accompanying text recognition

The default searching area for accompanying text

When AccompanyingTextRecognitionMode is set to ATRM_GENERAL, the accompanying text recognition feature is enabled. By default, DBR uses the successfully decoded barcode as a reference, and tries to recognize possible accompanying text in close proximity around the barcode.

The following is a sample image:


DBR is able to recognize the accompanying text marked by the red when accompanying text recognition is enabled.

JSON template example:

    "ImageParameter": {
        "Name": "ImageParameter1", 
        "Description": "This is acompanying text demonstrate", 
    "Version": "3.0"

Set a custom area for accompanying text

In some scenarios, the accompanying text you need is not in the immediate vicinity of the barcode. You can set a custom area to search by using the successfully decoded barcode as a reference via top, bottom, left and right values. The unit is in percentage.

Let’s take the following image as an example. In this sample image, the information we would like to recognize is within the green box, but it is a relatively far from the barcode. We can specify a custom searching area (marked by the red box) by setting the following arguments:

RegionBottom = -150, RegionLeft = -12, RegionRight = 85, RegionTop = -250

a card image demo that has a customed acompanying text recognition range

Example JSON template:

    "ImageParameter": {
        "Name": "ImageParameter1", 
        "Description": "This is a acompanying text demonstrate", 
                "Mode" : "ATRM_GENERAL",
                "RegionBottom" : -150,
                "RegionLeft" : -12,
                "RegionRight" : 85,
                "RegionTop" : -250
    "Version": "3.0"

How to get the result of recognized accompanying text

The result of the accompanying text is stored in the decoding result: ExtendedResult -> type RT_STANDARD_TEXT. The following code snippet shows how to get the result of recognized accompanying text.

CBarcodeReader * reader = new CBarcodeReader;
reader->InitLicense("Insert your license here");
char error[512];
int ret = reader->InitRuntimeSettingsWithFile("JsonTemplate.txt",CM_OVERWRITE,error,512);
ret = reader->DecodeFile("Insert image file path here");
TextResultArray* pResults = NULL;
for(int resultId = 0; resultId < pResults->resultsCount; ++resultId)
    TextResult* pBarcode = pResults->results[resultId];
    string accompany;
    // Loop through all ExtendedResult
    for(int extendId = 0; extendId < pBarcode->resultsCount; ++extendId)
        PExtendedResult pExtend = pBarcode->results[extendId];
        if(pExtend->resultType == RT_STANDARD_TEXT)
            unsigned char * accompanyStr = pExtend->accompanyingTextBytes;
            int strLen = pExtend->accompanyingTextBytesLength;
            accompany = string(accompanyStr,accompanyStr + strLen);
        cout << "accompanyText: " << accompany << endl;
delete reader;

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

latest version

    • Latest version
    • Version 9.0.0
    • Version 8.9.3
    • Version 8.9.0
    • Version 8.8.7
    • Version 8.8.5
    • Version 8.8.3
    • Version 8.8.0
    • Version 8.6.3
    • Version 8.6.1
    • Version 8.6.0
    • Version 8.4.0
    • Version 8.2.5
    • Version 8.2.3
    • Version 8.2.1
    • Version 8.2.0
    • Version 8.1.3
    • Version 8.1.2
    • Version 8.1.0
    • Version 8.0.0
    • Version 7.6.0
    • Version 7.5.0
    Change +
    © 2003–2022 Dynamsoft. All rights reserved.
    Privacy Statement / Site Map / Home / Purchase / Support