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: 9.6.20)
  2. Libdmtx (version: pylibdmtx 0.1.10)
  3. Google ML Kit (version: 2.3.0)
  4. Apple Vision Framework (version: iOS 15.0)
  5. Zxing CPP (version: 2.0.0)

The runtime settings are optimized to decode only Data Matrix codes if needed (code snippets).

Evaluation Metrics

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

The test tool and evaluation metrics are the same as in the QR code benchmark article. We use reading rate for comparison. 

The reading rate is the number of correct results divided by the number of all barcodes. A precision of 100% means that all the barcodes were recognized successfully, although there might be wrong values mixed in with the results. For example, if a barcode is mistakenly recognized as two separate ones, this behavior would not lower the reading rate.

Reading rate = correct results / all barcodes

Evaluation Results

Reading rate

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

Engine Reading Rate
Dynamsoft 100%
LibDMTX 86.61%
ML Kit 71.43%
Apple Vision 42.86%
ZxingCPP 17.86%

Reading rate Chart

Speed

Runtime per image (in milliseconds):

Engine Result
Dynamsoft 473.56
LibDMTX 3579.77
ML Kit 57.25
Apple Vision 191.02
ZxingCPP 14.89

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.

You can find the detailed results on this page.

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, noise and uneven background. 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 to the template

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_barcodes(Image.open(img_path),formats=zxingcpp.BarcodeFormat.DataMatrix)

Download Dynamsoft Barcode Reader

References