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
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
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.
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.
We are going to evaluate 5 libraries and SDKs:
- Dynamsoft Barcode Reader (DBR, version: 8.8)
- Libdmtx (version: pylibdmtx 0.1.9)
- Google ML Kit
- Apple Vision Framework
- Zxing CPP (version: 1.2.0)
The runtime settings are optimized to decode only Data Matrix codes if needed (code snippets).
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.
Reading rate (detected codes number / total codes number) in percent:
Runtime per image (in milliseconds):
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.
As discussed in the paper which provides the public data set, adaptive thresholding achieves a better result. In DBR, we can use the
LOCAL_BLOCKmethod to do adaptive thresholding.
You can learn more about how to use it here.
We have to enable DPM mode if we need to decode DPM codes. Learn how to use it here.
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.
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.
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.
let format = MLKitBarcodeScanning.BarcodeFormat.dataMatrix let barcodeOptions = BarcodeScannerOptions(formats: format) barcodeScanner = BarcodeScanner.barcodeScanner(options: barcodeOptions)
let barcodeRequest = VNDetectBarcodesRequest() barcodeRequest.symbologies = [.dataMatrix]
tr = zxingcpp.read_barcode(Image.open(img_path),formats=zxingcpp.BarcodeFormat.DataMatrix)