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 Filter and Sort Barcode Results

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 text string. The SDK provides the following parameters to help you filter the barcode results by barcode format, confidence, etc and order the results by confidence, position or format.

Here is an example template containing all these parameters:

{
    "Version": "3.0",
    "ImageParameter": {
        "Name":"IP_FilterBarcode",
        "BarcodeFormatIds": [
            "BF_CODE_39"
        ],
        "BarcodeFormatIds_2": [
            "BF2_NULL"
        ],
        "TextResultOrderModes": [
            {
                "Mode": "TROM_POSITION"
            }
        ],
        "FormatSpecificationNameArray": [
            "FP_1"
        ]
    },
    "FormatSpecification": {
        "Name": " FP_1",
        "BarcodeAngleRangeArray": [
            {
                "MinValue": 80,
                "MaxValue": 100
            }
        ],
        "BarcodeWidthRangeArray": [
            {
                "MaxValue": 200,
                "MinValue": 100
            }
        ],
        "BarcodeHeightRangeArray": [
            {
                "MaxValue": 100,
                "MinValue": 50
            }
        ],
        "MinRatioOfBarcodeZoneWidthToHeight": 100,
        "BarcodeTextLengthRangeArray": [
            {
                "MaxValue": 20,
                "MinValue": 10
            }
        ],
        "BarcodeTextRegExPattern": "[0-9]{4}",
        "MinResultConfidence": 50,
        "ModuleSizeRangeArray": [
            {
                "MaxValue": 20,
                "MinValue": 10
            }
        ]
    }
}

These parameters can work both individually and in combination. Here we will show how to filter out QR Code results with confidence lower than 50 and then order the results by position.

  • JavaScript
  • C
  • C++
  • C#
  • Java
  • Android
  • Objective-C
  • Swift
  • Python
const scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
// Defines the template for the filtering & sorting
let jsonString = "{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP_FilterBarcode\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"TextResultOrderModes\":[{\"Mode\":\"TROM_POSITION\"}], \"FormatSpecificationNameArray\": [\"FP_1\"]},\"FormatSpecification\":{\"Name\":\"FP_1\", \"MinResultConfidence\":50}}";
// Configures the BarcodeScanner object with the settings.
await scanner.initRuntimeSettingsWithString(jsonString);
scanner.show();
int iRet = -1;
char errorBuf[512];
iRet = DBR_InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
if (iRet != DBR_OK)
{
    printf("%s\n", errorBuf);
}
void* barcodeReader = DBR_CreateInstance();
DBR_InitRuntimeSettingsWithString(barcodeReader, "{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP_FilterBarcode\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"TextResultOrderModes\":[{\"Mode\":\"TROM_POSITION\"}], \"FormatSpecificationNameArray\": [\"FP_1\"]},\"FormatSpecification\":{\"Name\":\"FP_1\", \"MinResultConfidence\":50}}", CM_OVERWRITE, errorBuf, 512);
DBR_DecodeFile(barcodeReader, "YOUR-IMAGE-FILE-WITH-QR-CODES", "IP_FilterBarcode"); // Start decoding
// Add further process
char errorBuf[512];
int iRet = -1;
iRet = dynamsoft::dbr::CBarcodeReader::InitLicense("YOUR-LICENSE-KEY", errorBuf, 512);
if (iRet != DBR_OK)
{
    cout << errorBuf << endl;
}
CBarcodeReader* reader = new CBarcodeReader();
reader->InitRuntimeSettingsWithString("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP_FilterBarcode\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"TextResultOrderModes\":[{\"Mode\":\"TROM_POSITION\"}], \"FormatSpecificationNameArray\": [\"FP_1\"]},\"FormatSpecification\":{\"Name\":\"FP_1\", \"MinResultConfidence\":50}}", CM_OVERWRITE, errorBuf, 512);
reader->DecodeFile("YOUR-IMAGE-FILE-WITH-QR-CODES", "IP_FilterBarcode"); // Start decoding
// Add further process
string errorMsg;
EnumErrorCode iRet = BarcodeReader.InitLicense("YOUR-LICENSE-KEY", out errorMsg);
if (iRet != EnumErrorCode.DBR_SUCCESS)
{
    Console.WriteLine(errorMsg);
}
BarcodeReader reader = new BarcodeReader();
reader.InitRuntimeSettingsWithString("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP_FilterBarcode\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"TextResultOrderModes\":[{\"Mode\":\"TROM_POSITION\"}], \"FormatSpecificationNameArray\": [\"FP_1\"]},\"FormatSpecification\":{\"Name\":\"FP_1\", \"MinResultConfidence\":50}}", EnumConflictMode.CM_OVERWRITE, out errorMsg);
TextResult[] result = reader.DecodeFile("YOUR-IMAGE-FILE-WITH-QR-CODES", "IP_FilterBarcode"); // Start decoding
// Add further process
BarcodeReader.initLicense("YOUR-LICENSE-KEY");
BarcodeReader reader = new BarcodeReader();
reader.initRuntimeSettingsWithString("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP_FilterBarcode\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"TextResultOrderModes\":[{\"Mode\":\"TROM_POSITION\"}], \"FormatSpecificationNameArray\": [\"FP_1\"]},\"FormatSpecification\":{\"Name\":\"FP_1\", \"MinResultConfidence\":50}}", EnumConflictMode.CM_OVERWRITE);
TextResult[] result = reader.decodeFile("YOUR-IMAGE-FILE-WITH-QR-CODES", "IP_FilterBarcode"); // Start decoding
// Add further process
BarcodeReader reader = new BarcodeReader();
reader.initRuntimeSettingsWithString("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP_FilterBarcode\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"TextResultOrderModes\":[{\"Mode\":\"TROM_POSITION\"}], \"FormatSpecificationNameArray\": [\"FP_1\"]},\"FormatSpecification\":{\"Name\":\"FP_1\", \"MinResultConfidence\":50}}", EnumConflictMode.CM_OVERWRITE);
// Start decoding
TextResult[] result = reader.decodeFile("YOUR-IMAGE-FILE-WITH-QR-CODES"); 
// Add further process
NSError* err = nil;
DynamsoftBarcodeReader* reader = [[DynamsoftBarcodeReader alloc] init];
[reader initRuntimeSettingsWithString:@"{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP_FilterBarcode\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"TextResultOrderModes\":[{\"Mode\":\"TROM_POSITION\"}], \"FormatSpecificationNameArray\": [\"FP_1\"]},\"FormatSpecification\":{\"Name\":\"FP_1\", \"MinResultConfidence\":50}}" conflictMode:EnumConflictModeOverwrite error:&err];
// Start decoding
NSArray<iTextResult*>* result = [reader decodeFileWithName:@"YOUR-IMAGE-FILE-WITH-QR-CODES" error:&err]; 
// Add further process
let reader = DynamsoftBarcodeReader.init()
try? reader.initRuntimeSettingsWithString("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP_FilterBarcode\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"TextResultOrderModes\":[{\"Mode\":\"TROM_POSITION\"}], \"FormatSpecificationNameArray\": [\"FP_1\"]},\"FormatSpecification\":{\"Name\":\"FP_1\", \"MinResultConfidence\":50}}", conflictMode:EnumConflictMode.overwrite)
// Start decoding
let result = try? reader.decodeFileWithName("YOUR-IMAGE-FILE-WITH-QR-CODES")
// Add further process
error = BarcodeReader.init_license("YOUR-LICENSE-KEY")
if error[0] != EnumErrorCode.DBR_OK:
    print(error[1])
dbr = BarcodeReader()
dbr.init_runtime_settings_with_string('{"Version":"3.0", "ImageParameter":{"Name":"IP_FilterBarcode", "BarcodeFormatIds":["BF_QR_CODE"], "TextResultOrderModes":[{"Mode":"TROM_POSITION"}], "FormatSpecificationNameArray": ["FP_1"]},"FormatSpecification":{"Name":"FP_1", "MinResultConfidence":50}}')
text_results = dbr.decode_file("YOUR-IMAGE-FILE-WITH-QR-CODES")
# Add further process

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

latest version

    • Latest version
    • Version 9.x
      • 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 +
    © 2003–2023 Dynamsoft. All rights reserved.
    Privacy Statement / Site Map / Home / Purchase / Support