What are the Best Data Matrix Reading SDKs?

Looking for the best Data Matrix SDKs for your application, you’ve come to the right place. Let’s learn about what is Data Matrix and do a benchmark to find out which SDK is the best.

Data Matrix is a type of two-dimensional code. It is often used to mark small items like electronic components, due to the code’s ability to encode fifty characters in a symbol that is readable at 2 or 3 mm2 and the fact that the code can be read with only a 20% contrast ratio. 1

Circuit

Data Matrix is the preferred code in Direct part marking (DPM). DPM is a process to permanently mark parts with product information including serial numbers, part numbers, date codes, and barcodes.2

Surface

Data Matrix codes are usually read by camera and special software. Reading Data Matrix codes is a challenging task. In this article, we are going to run a benchmark based on an image data set to find out the best Data Matrix reading SDKs.

The Dataset

There are many studies about decoding Data Matrix and a recent study provides a public data set to test the performance of reading Data Matrix codes.

The data set has 57 valid images with 112 Data Matrix codes. The images are put into three categories: synthetic, Internet and industrial.

Images in categories

Evaluated Libraries

We are going to evaluate 5 libraries and SDKs:

  1. Dynamsoft Barcode Reader (DBR, version: 8.8)
  2. Libdmtx (version: pylibdmtx 0.1.9)
  3. Google ML Kit
  4. Apple Vision Framework
  5. Zxing CPP (version: 1.2.0)

The runtime settings are optimized to decode only Data Matrix codes if needed (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 percent:

Engine Reading Rate
DBR 100
libdmtx 86.61
ML Kit 71.43
Apple Vision 40.18
ZxingCPP 18.75

Reading rate Chart

Speed

Runtime per image (in milliseconds):

Engine Result
DBR 229.14
libdmtx 3599.68
ML Kit 35.56
Apple Vision 181.30
ZxingCPP 7.40

Times per Image Chart

We can see that the Dynamsoft Barcode Reader can decode all the Data Matrix codes while other SDKs cannot. It also has a good balance of reading rate and runtime. The libdmtx has a good reading rate but it spends too much time decoding. The ZxingCPP is very quick but it lacks accuracy.

Optimize the Performance of Dynamsoft Barcode Reader

Dynamsoft Barcode Reader provides rich parameters that users can customize and optimize for different usage scenarios for the best scanning performance.3

There are some parameters related to decoding Data Matrix.

  1. BinarizationModes

    As discussed in the paper which provides the public data set, adaptive thresholding achieves a better result. In DBR, we can use the LOCAL_BLOCK method to do adaptive thresholding.

    You can learn more about how to use it here.

  2. DPMCodeReadingModes

    We have to enable DPM mode if we need to decode DPM codes. Learn how to use it here.

  3. DeformationResistingModes

    If Data Matrix codes are malformed, it is difficult to read them. We can enable deformation resisting in such cases. Learn how to use it here.

    Malformed Data Matrix

  4. ImagePreprocessingModes

    DBR has some image preprocessing algorithms built-in.

    For example, the following image has a low resolution and noise. We can smooth the image to decode all the codes.

    Low-resolution image

    Learn how to use it here.

Code Snippets for Setting the Barcode Format to Data Matrix

Here are the code snippets to specify the Data Matrix barcode format.

DBR:

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

Link of template.json

ML Kit:

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

Apple Vision:

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

Zxing CPP:

tr = zxingcpp.read_barcode(Image.open(img_path),formats=zxingcpp.BarcodeFormat.DataMatrix)

References