How to Select One Barcode from Many

In many barcode scanning situations, we only need to select one barcode while there are many other barcodes around it. How to avoid scanning unwanted barcodes and only get the barcode result we want? In this article, we are going to talk about ways to select one barcode from many. A web barcode scanner demo using Dynamsoft Camera Enhancer and Dynamsoft Barcode Reader has been built for illustration.

Ways to Select One Barcode from Many

Here are four ways to select one barcode from many.

Set a Scan Region

If there are many barcodes in the camera view, we can set a scan region so that users can easily aim at the desired barcode.

We can use Dynamsoft Camera Enhancer’s setScanRegion to do this:


After setting a scan region, the scanner will show a view finder and it will crop the video frame before sending it to Dynamsoft Barcode Reader to read barcodes.

scan region

Specify Barcode Formats

If the barcode has a special barcode format which is different from other barcodes, we can specify the desired barcode format so that Dynamsoft Barcode Reader will only try to read codes in this barcode format.

We can update Dynamsoft Barcode Reader’s runtime settings to do this.

var settings = await barcodeReader.getRuntimeSettings();
settings.barcodeFormatIds = selectedBarcodeFormat;
await barcodeReader.updateRuntimeSettings(settings);

Use Regular Expression

Dynamsoft Barcode Reader can read multiple barcodes and QR codes in one frame scan.

We can use regular expression to find out which barcode scan to use.

For example, if we need to scan an EAN13 code, we can use the following regular expression:


A screenshot of the scanner using regular expression with unwanted barcodes marked in red and the desired barcode marked in green.

highlighted barcodes

Let Users Select which Barcode to Use

If the above methods does not meet a specific situation, we can let the users select which barcode to use.

A screenshot of the interface where users can tap the desired the barcode to select.

select a barcode

Source Code

You can find the source code of the demo in the following repo: