Get detailed barcode information

The Dynamsoft Barcode Reader SDK provides APIs for you to get the detailed barcode information like checksum digit, start/stop characters, error correction level, etc. To learn more about what information you can get, see the following API links:

Here we take QR Code as example and show how to get the version and model of a QR Code.

What is the version of a QR Code?

QRCode Version Modules
Version 1 21 x 21
Version 2 25 x 25
... ...
Version N (17 + N x 4) x (17 + N x 4)
Version 40 177 x 177

What is the model of a QR Code?

QRCode Model Description
Model 1 The original QR Code. It is a code capable of coding 1,167 numerals with its maximum version being 14 (73 x 73 modules).
Model 2 Created by improving Model 1 so that this code can be read smoothly even if it is distorted in some way. This code can encode up to 7,089 numerals with its maximum version being 40 (177 x 177 modules). Today, the term QRCode usually refers to QRCode Model 2.

Code snippet

C#
C
C++
BarcodeReader dbr = new BarcodeReader();
dbr.ProductKeys = "t0068MgAAAGotN***"; // Set the trial license
PublicRuntimeSettings settings = dbr.GetRuntimeSettings();
settings.BarcodeFormatIds = (int)EnumBarcodeFormat.BF_QR_CODE; // Read QR Code only
dbr.UpdateRuntimeSettings(settings);
// leave the template name empty ("") will use default settings for recognition
TextResult[] aryResult = dbr.DecodeFile(@"C:\Program Files (x86)\Dynamsoft\Barcode Reader 7.2\Images\AllSupportedBarcodeTypes.tif", ""); 
if (aryResult.Length == 0)
{
    Console.WriteLine("No barcode found.");
}
else
{
    for (var i = 0; i < aryResult.Length; i++)
    {
        QRCodeDetails details = (QRCodeDetails)aryResult[i].DetailedResult;
        Console.WriteLine("Barcode Index: {0}", (i + 1));
        Console.WriteLine("BarcodeFormat: {0}", aryResult[i].BarcodeFormat.ToString());
        Console.WriteLine("BarcodeText: {0}", aryResult[i].BarcodeText);
        Console.WriteLine("QRCode Model: {0}", details.Model.ToString()); // Get the Model
        Console.WriteLine("QRCode Version: {0}", details.Version.ToString()); // Get the Version
    }
}
// Define variables
void* hBarcode = NULL;
int iRet = -1;
int iIndex = 0;
int iLicMsg = -1;
char sError[512];
TextResultArray* pResult = NULL;
hBarcode = DBR_CreateInstance();
PublicRuntimeSettings runtimeSettings;
DBR_GetRuntimeSettings(hBarcode, &runtimeSettings);
runtimeSettings.barcodeFormatIds = BF_QR_CODE; // OneD barcode
DBR_UpdateRuntimeSettings(hBarcode, &runtimeSettings, sError, 512);
// Initialize license prior to any decoding
iLicMsg = DBR_InitLicense(hBarcode, "f0068MgAAAGnTM***");
//If error occurs to the license initialization
if (iLicMsg != DBR_OK)
{
    printf("Failed to initialize the license successfully: %d\r\n%s\r\n", iLicMsg, DBR_GetErrorString(iLicMsg));
    return iLicMsg;
}
// Started decoding
DBR_DecodeFile(hBarcode, "<input your image file path here>", "");
// Get the text result
iRet = DBR_GetAllTextResults(hBarcode, &pResult);
// If error occurs
if (iRet != DBR_OK)
{
    printf("Failed to read barcode: %d\r\n%s\r\n", iRet, DBR_GetErrorString(iRet));
    return iRet;
}
// If succeeds
printf("%d total barcode(s) found. \n", pResult->resultsCount);
for (iIndex = 0; iIndex < pResult->resultsCount; iIndex++)
{
    QRCodeDetails* qrd = (QRCodeDetails*)pResult->results[iIndex]->detailedResult;
    printf("QRCode Model:%d \r\n", qrd->model);
    printf("QRCode Version: %d \r\n", qrd->version);
    printf("Result %d\n", iIndex + 1);
    printf("Barcode Format: %s\n", pResult->results[iIndex]->barcodeFormatString);
    printf("Text reads: %s \n", pResult->results[iIndex]->barcodeText);
}
// Finally release BarcodeResultArray and destroy instance
DBR_FreeTextResults(&pResult);
DBR_DestroyInstance(hBarcode);
system("pause");
int iRet = -1;
int iLicMsg = -1;
TextResultArray* paryResult = NULL;
PublicRuntimeSettings* runtimeSettings = new PublicRuntimeSettings();
// Initialize license prior to any decoding
CBarcodeReader reader;
char sError[512];
iLicMsg = reader.InitLicense("f0068MgA4o***");
reader.GetRuntimeSettings(runtimeSettings);
runtimeSettings->barcodeFormatIds = BF_QR_CODE;
reader.UpdateRuntimeSettings(runtimeSettings, sError, 512);
//If error occurs to the license initialization
if (iLicMsg != DBR_OK)
{
    printf("Failed to initialize the license successfully: %d\r\n%s\r\n", iLicMsg, DBR_GetErrorString(iLicMsg));
    return iLicMsg;
}
// Start decoding
iRet = reader.DecodeFile("<please input your image file path>", "");
// If error occurs
if (iRet != DBR_OK)
{
    printf("Failed to read barcode: %d\r\n%s\r\n", iRet, DBR_GetErrorString(iRet));
    return iRet;
}
// If succeeds
reader.GetAllTextResults(&paryResult);
for (int iIndex = 0; iIndex < paryResult->resultsCount; iIndex++)
{
    QRCodeDetails* qrd = (QRCodeDetails*)paryResult->results[iIndex]->detailedResult;
    printf("QRCode Model:%d \r\n", qrd->model);
    printf("QRCode Version: %d \r\n", qrd->version);
    printf("BarcodeFormat: %s\r\n", paryResult->results[iIndex]->barcodeFormatString);
    printf("Text read: %s\r\n", paryResult->results[iIndex]->barcodeText);
}
// Finally release BarcodeResultArray
CBarcodeReader::FreeTextResults(&paryResult);
return 0;

results matching ""

    No results matching ""