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 Guides - Filter Out Unwanted Barcode Result

Dynamsoft Barcode Reader SDK is able to read multiple barcodes at once and return results of all the decoded barcodes. However, you may not want all the results. For example, you may need only the results of a specific barcode format, or you may need only the barcodes with a certain length (number of barcode data bytes). The SDK provides settings to help you filter out the barcode results by barcode formats, confidence, text length, rotation angle, regular expression and so on.

Filtering out the barcode results based on the barcode formats is shown in Barcode Format and Expected Barcode Counts.

Filtering out the barcode results based on confidence, text length or more optional conditions is shown in Decode Result.

Following part shows how to filter out the unwanted barcode results based on the barcode confidence and barcode text length as examples.

Filtering Using Barcode Confidence

The barcode confidence means the probability that the barcode result is recognized correctly. You can use minResultConfidence to filter out the results with low confidence.

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>");
    
//Obtain the barcode results with confidence above 35
reader->GetRuntimeSettings(runtimeSettings);
runtimeSettings->minResultConfidence = 35;    //It is recommended to set the confidence above 35
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;

Filtering Using Barcode Result Length

The barcode length is calculated in bytes. The length of the barcode text does not necessarily mean the actual length of the barcode bytes. You can use minBarcodeTextLength to filter out some invalid or unwanted results.

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");
    
//Decode the barcodes with its length longer than 10 bytes
reader->GetRuntimeSettings(runtimeSettings);
runtimeSettings->minBarcodeTextLength = 10;
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;

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

latest version

    • Latest version
    • Version 10.x
      • Version 10.2.0
      • Version 10.0.21
      • Version 10.0.20
      • Version 10.0.10
      • Version 10.0.0
    • Version 9.x
      • Version 9.6.42
      • Version 9.6.40
      • Version 9.6.33
      • Version 9.6.32
      • Version 9.6.31
      • Version 9.6.30
      • Version 9.6.20
      • Version 9.6.10
      • Version 9.6.0
      • Version 9.4.0
      • Version 9.2.0
      • Version 9.0.0
    • Version 8.x
      • Version 8.8.0
      • Version 8.6.0
      • Version 8.4.0
      • Version 8.2.0
      • Version 8.1.2
      • Version 8.1.0
      • Version 8.0.0
    • Version 7.x
      • Version 7.6.0
      • Version 7.5.0
    Change +