Multiple Barcodes Reading Benchmark and Comparison

A barcode is an optical, machine-readable, representation of data. There are different types of barcodes which are used in different contexts. EAN or UPC codes are printed on most items in stores. Code128 codes are used extensively in the shipping and packaging industries. QR codes have greater storage capacity and thus more versatile. You can learn more about the types of barcodes here.

We often need to use multiple barcodes in different types to mark documents, packages, etc. For example, the following phone packaging has Code128, QR code, UPCA and Interleaved 25 codes.

multiple barcodes

Multiple barcodes used in these cases pose a big challenge for barcode scanners. Laser-based barcode scanners cannot scan multiple barcodes in one scan. Camera-based barcode scanners require a sophisticated image processing algorithm. There are many barcode reading libraries based on image processing but few of them can read multiple barcodes.

In this article, we are going to run a benchmark based on an image data set to test different barcode reading libraries. The final result shows that Dynamsoft Barcode Reader is the most capable library for reading multiple barcodes.

Getting started with Dynamsoft Barcode Reader

The Dataset

There are several studies about reading barcodes. A recent study uses semantic segmentation to detect barcodes and provides a public dataset.

The dataset has 921 real images and 30,000+ synthetic images. It contains a large number of different barcode types (Code39, Code128, EAN13, DataMatrix, Aztec, QR, PDF417, Aztec, and many more). We are going to run the benchmark based on the real images which have more than 2 barcodes. The final multiple barcodes subset has 95 images with 257 barcodes on packages, books, scanned documents, etc.

Example images:

ISBN

documents

low light

Evaluated Libraries

We are going to evaluate 3 libraries and SDKs:

  1. Dynamsoft Barcode Reader (version: 9.6.20)
  2. zbar.wasm (version: 0.9.12)
  3. zxing-js (version: 0.20.0)

Evaluation Metrics

  • Reading rate: correctly detected barcodes / total barcodes
  • Average time: total time elapsed / total files

How to infer that a barcode is correctly detected? We check if there is a ground truth barcode which overlaps with the detected barcode using IoU (intersection over union) and if the barcode text is correct.

Evaluation Results

Reading rate

Reading rate in percentage:

Engine Result
Dynamsoft 96.5%
ZBar 62.65%
ZXing 6.61%

Average Time Chart

Speed

Runtime per image (in milliseconds):

Engine Result
Dynamsoft 1171.34 ms
ZBar 740.63 ms
ZXing 217.73 ms

Average Time Chart

We can see that the Dynamsoft Barcode Reader has the highest reading rate though it needs to spend more time decoding each image. As of the date of the benchmark, ZXing-js can only recognize one barcode from an image so its reading rate is pretty low.

Dynamsoft Barcode Reader supports more barcode formats and has a better ability to locate and recognize difficult-to-read barcodes like blurred barcodes, damaged barcodes, barcodes in low light, etc. These are the reasons why it has a better reading rate.

You can check out this page to see the benchmark results and images in detail.

Optimize the Performance of Dynamsoft Barcode Reader

Dynamsoft Barcode Reader provides rich parameters to customize the image processing process. In the benchmark, we use the following JSON template to customize its settings:

{
  "ImageParameter": {
    "BarcodeFormatIds": [
      "BF_CODE_11",
      "BF_CODE_39",
      "BF_CODE_93",
      "BF_CODE_128",
      "BF_CODABAR",
      "BF_ITF",
      "BF_EAN_13",
      "BF_EAN_8",
      "BF_UPC_A",
      "BF_UPC_E",
      "BF_INDUSTRIAL_25",
      "BF_MSI_CODE",
      "BF_GS1_DATABAR",
      "BF_GS1_COMPOSITE",
      "BF_PATCHCODE",
      "BF_PDF417",
      "BF_QR_CODE",
      "BF_DATAMATRIX",
      "BF_AZTEC",
      "BF_MAXICODE",
      "BF_MICRO_QR",
      "BF_MICRO_PDF417"
    ],
    "BarcodeFormatIds_2": [
      "BF2_NULL"
    ],
    "ImagePreprocessingModes": [
      {
        "LibraryFileName": "",
        "LibraryParameters": "",
        "Mode": "IPM_GENERAL"
      },
      {
        "LibraryFileName": "",
        "LibraryParameters": "",
        "Mode": "IPM_GRAY_EQUALIZE",
        "Sensitivity": 5
      },
      {
        "LibraryFileName": "",
        "LibraryParameters": "",
        "Mode": "IPM_GRAY_SMOOTH",
        "SmoothBlockSizeX": 3,
        "SmoothBlockSizeY": 3
      }
    ],
    "ExpectedBarcodesCount": 999,
    "Name": "Settings"
  },
  "Version": "3.0"
}

The template specifies which barcode formats to read, the image preprocessing and the expected barcodes count.

If the number of barcodes found does not meet the expected one, Dynamsoft Barcode Reader will try all the image processing combinations so it may spend more time decoding. If you want to improve the speed, we can set the count to 0 so that it will stop if one image processing combination can find all the desired barcodes.

After setting the expected barcodes count, the reading rate drops a bit to 93.39% while the average time decreases to 326 ms.

You can learn more about the parameters by checking out the docs.

Live Bulk Barcode Scanning

We can use Dynamsoft Barcode Reader to read multiple barcodes from camera frames. You can check out the online demo to have a try.

Source Code