Web Demos

BARCODE READER SDK DEMO

Explore the flexibe barcode reading settings to optimize for your specific usage scenario.

WEB TWAIN SDK DEMO

Try the most popular web scanner features: scan images, import local images and PDF files, edit, save to local, upload to database, and etc.

BARCODE READER JAVASCRIPT DEMO

Transform any camera-equipped devices into real-time, browser-based barcode and QR code scanners.

MRZ SCANNER WEB DEMO

Detects the machine-readable zone of a passport, scans the text, and parses into human-readable data.

APP STORE DEMOS

BARCODE READER SDK FOR IOS

BARCODE READER SDK FOR ANDROID

VIEW MORE DEMOS >
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:

standard-acompanying-text

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", 
        "AccompanyingTextRecognitionModes":["ATRM_GENERAL"]
    }, 
    "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", 
        "AccompanyingTextRecognitionModes":[
            {
                "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;
reader->GetAllTextResults(&pResults);
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);
            break;
        }    
    }
    if(!accompany.empty())
    {
        cout << "accompanyText: " << accompany << endl;
    }
}
CBarcodeReader::FreeTextResults(&pResults);
delete reader;

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

latest version

    • Version {"value"=>"latest version"}
    • Version {"value"=>"9.x", "child"=>["9.2.13", "9.2.11", "9.2.10", "9.0.2", "9.0.1", "9.0.0"]}
    • Version {"value"=>"8.x", "child"=>["8.9.3", "8.9.0", "8.8.7", "8.8.5", "8.8.3", "8.8.0", "8.6.3", "8.6.0", "8.4.0", "8.2.5", "8.2.3", "8.2.1", "8.2.0", "8.1.3", "8.1.2", "8.1.0", "8.0.0"]}
    • Version {"value"=>"7.x", "child"=>["7.6.0", "7.5.0"]}
    Change +
    © 2003–2022 Dynamsoft. All rights reserved.
    Privacy Statement / Site Map / Home / Purchase / Support