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 5 libraries and SDKs:

  1. Dynamsoft Barcode Reader (DBR iOS, version: 8.8)
  2. Commercial SDK A (version: 6.10.0)
  3. Google ML Kit
  4. Apple Vision Framework
  5. ZXing Objective-C (version: 3.6.4)

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 an iOS simulator. The host has an Intel i5-10400 CPU and 16GB memory.

Evaluation Results

Reading rate

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

Engine Result
DBR 92.05%
ML Kit 63.64%
Commercial SDK A 52.27%
Apple Vision 48.86%
ZXingObjC 27.27%

Reading rate Chart

Speed

Runtime per image (in milliseconds):

Engine Result
DBR 466.29 ms
ML Kit 126.44 ms
Commercial SDK A 1380.24 ms
Apple Vision 349.85 ms
ZXingObjC 302.18 ms

Times per Image Chart

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

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:

let settings = try? barcodeReader.getRuntimeSettings()
settings!.barcodeFormatIds = EnumBarcodeFormat.PDF417.rawValue
var error:NSError? = NSError()
barcodeReader.update(settings!, error: &error)

Commercial SDK A:

let settings = BarcodeTrackingSettings()
settings.set(symbology: .pdf417, enabled: true)

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 Objective-C:

var reader: ZXPDF417Reader = ZXPDF417Reader()
let hints:ZXDecodeHints = ZXDecodeHints.hints() as! ZXDecodeHints
hints.tryHarder = true
let results = try? reader.decodeMultiple(bitmap, hints: hints)

References