How to turn on or off text filter

In some cases, the image may be filled with a lot of characters and numbers. This could affect the barcode recognition. With text filter on, it can filter and remove the characters and numbers from the image and improve the barcode recognition accuracy. However, you may want to turn off text filter when barcodes are the only content of the image or when the speed is the prority.

The text filter is on by default.

The following code snippet shows how to set text filter function by changing the TextFilterModes parameter.

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>");

DBR_GetRuntimeSettings(hBarcode, &runtimeSettings);
// Turn off the text filter function. The enumeration includes TFM_GENERAL_CONTOUR, 
// which is used to turn on the function. 
runtimeSettings.furtherModes.textFilterModes[0] = TFM_SKIP;
DBR_UpdateRuntimeSettings(hBarcode, &runtimeSettings,sError,512);

// Replace "<Put your file path 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");
   
reader->GetRuntimeSettings(runtimeSettings);
// Turn off the text filter function. The enumeration includes TFM_GENERAL_CONTOUR,
// which is used to turn on the function, and TFM_AUTO.
runtimeSettings->furtherModes.textFilterModes[0] = TFM_SKIP;
reader->UpdateRuntimeSettings(runtimeSettings, sError, 512);

//Replace "Put the path of your file 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.textFilterModes[0] = EnumTextFilterMode.TFM_SKIP;
dbr.updateRuntimeSettings(rts);

// Initialize license prior to any decoding
//Replace "<Put your license key here>" with your own license
dbr.initLicense("<Put your license key here>");

//Replace "<Put the path of your file here>" with your own file path
TextResult[] result = dbr.decodeFile("<Put your file path here>","");

results matching ""

    No results matching ""