What are the Best PDF417 Reading SDKs?

PDF417 is a stacked linear barcode format used in a variety of applications such as transport, identification cards, and inventory management.1

We can find it on a boarding pass, driver’s license, patient wristband, etc.

PDF417 on a US driver’s license:

driver's license

A PDF417 has five parts: start pattern, left row indicator, data codewords, right row indicator and stop pattern.

pdf417 example

PDF417 can be read with a laser scanner as well as a camera. Reading a PDF417 code in the real world is not an easy job.

In this article, we are going to run a benchmark based on an image data set to find out the best SDKs for reading PDF417.

The Dataset

There are several studies about reading PDF417. 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 (Code128, EAN13, DataMatrix, Aztec, QR, PDF417, and many more). We are going to run the benchmark based on the real images which have readable PDF417 codes. The final PDF417 subset has 78 images with 88 PDF417 codes on bottles, boarding passes and scanned documents.

pdf417 example

Evaluated Libraries

We are going to evaluate 4 libraries and SDKs:

  1. Dynamsoft Barcode Reader (DBR, version: 9.6.20)
  2. Google ML Kit (version: 3.2.0)
  3. Apple Vision Framework (version: iOS 15.0)
  4. ZXingCPP (version: 2.0.0)

The runtime settings are set to decode PDF417 codes only (code snippets).

Evaluation Metrics

The test tool and evaluation metrics are the same as in the QR code benchmark article.

The test is run on a PC device with an Intel i5-10400 CPU and 16GB memory.

Evaluation Results

Reading rate

Reading rate (detected codes number / total codes number) in percentage:

Engine Result
Dynamsoft 95.45%
ML Kit 61.36%
ZXingCPP 52.27%
Apple Vision 30.68%

Reading rate Chart

Speed

Runtime per image (in milliseconds):

Engine Result
Dynamsoft 586.64 ms
ML Kit 304.22 ms
ZXingCPP 127.56 ms
Apple Vision 693.96 ms

Times per Image Chart

We can see that the Dynamsoft Barcode Reader has the highest reading rate and its speed is fairly good.

You can find the detailed results on this page.

Optimize the Performance of Dynamsoft Barcode Reader

Dynamsoft Barcode Reader is powerful in that it provides rich parameters that users can customize and optimize for different usage scenarios for the best scanning performance.2 For example, for the dataset above, the reading rate can be increased by adjusting the parameters of its runtime settings.

There are some parameters we can use so that DBR can read the failed images.

  1. ImagePreprocessingModes

    Some images have a lot of noise. We can use IPM_GRAY_SMOOTH to reduce noise. This is similar to median blur in OpenCV.

    Example:

    noise example

    Here is the JSON template to use this mode:

     "ImagePreprocessingModes": [
       {
         "LibraryFileName": "",
         "LibraryParameters": "",
         "Mode": "IPM_GRAY_SMOOTH",
         "SmoothBlockSizeX": 10,
         "SmoothBlockSizeY": 10
       }
     ]
    

    Learn more about image preprocessing here.

  2. Scan Region

    Some images have low contrast and it is difficult to locate the barcodes. We can set up a scan region so that DBR can locate the barcodes in an interactive scenario. Here, we use DBR JS for convenience.

    scan region example

    Learn more about how to set up a scan region here.

Code Snippets Used for the Testing

Here are the code snippets to specify the PDF417 barcode format.

DBR:

self.dbr.init_runtime_settings_with_file("template.json")

Link to the template

ML Kit:

let format = MLKitBarcodeScanning.BarcodeFormat.PDF417
let barcodeOptions = BarcodeScannerOptions(formats: format)
barcodeScanner = BarcodeScanner.barcodeScanner(options: barcodeOptions)

Apple Vision:

let barcodeRequest = VNDetectBarcodesRequest()
barcodeRequest.symbologies = [.pdf417]

Zxing CPP:

tr = zxingcpp.read_barcodes(Image.open(img_path),formats=zxingcpp.BarcodeFormat.PDF417)

Download Dynamsoft Barcode Reader

References