How to read barcodes with different colors

Common barcodes are black and white. However, some barcodes could be in different colors such as the below left barcode. Also, in some cases, a QR code may appear with an image or a logo inside as shown below right. Dynamsoft can decode such special barcodes as well.

In some other cases, the barcodes can be white with a dark background color as shown on the right part of the image below:

To decode such kind of barcodes, the default runtime settings may fail. You can adjust the PublicRuntimeSettings like below:

C
C++
Java
void *hBarcode = NULL;
char sError[512];
TextResultArray* pResult = NULL;
PublicRuntimeSettings runtimeSettings;
hBarcode = DBR_CreateInstance();
// Initialize license prior to any decoding
//Replace "<Put your license key here>" with your own license
DBR_InitLicense(hBarcode, "<Put your license key here>");

//Change the runtime settings to read barcodes with inverted color
DBR_GetRuntimeSettings(hBarcode, &runtimeSettings);
runtimeSettings.furtherModes.grayscaleTransformationModes[0] = GTM_INVERTED;
DBR_UpdateRuntimeSettings(hBarcode, &runtimeSettings,sError,512);

//Replace "<Put the path of your file here>" with your own file path
DBR_DecodeFile(hBarcode,"<Put your file path here>","");
DBR_GetAllTextResults(hBarcode, &pResult);
DBR_FreeTextResults(&pResult);
DBR_DestroyInstance(hBarcode);
char sError[512];
TextResultArray* paryResult = NULL;
PublicRuntimeSettings* runtimeSettings = new PublicRuntimeSettings();
CBarcodeReader* reader = new CBarcodeReader();
//Initialize license prior to any decoding
//Replace "<Put your license key here>" with your own license
reader->InitLicense("<Put your license key here>");
    
//Change the runtime settings to read barcodes with inverted color
reader->GetRuntimeSettings(runtimeSettings);
runtimeSettings->furtherModes.grayscaleTransformationModes[0] = GTM_INVERTED;
reader->UpdateRuntimeSettings(runtimeSettings, sError, 512);

//Replace "<Put your file path here>" with your own file path
reader->DecodeFile("<Put your file path here>", "");
// If succeeds
reader->GetAllTextResults(&paryResult);
CBarcodeReader::FreeTextResults(&paryResult);
delete runtimeSettings;
delete reader;
BarcodeReader dbr = new BarcodeReader();
PublicRuntimeSettings rts = dbr.getRuntimeSettings();
rts.furtherModes.grayscaleTransformationModes[0]= EnumGrayscaleTransformationMode.GTM_INVERTED; 
dbr.updateRuntimeSettings(rts);
//Initialize license prior to any decoding
dbr.initLicense("Put your license key here");
TextResult[] result = dbr.decodeFile("Put your file path here","");

results matching ""

    No results matching ""