← Articles

DataMatrix and barcode reader libraries compared: dmr and unir vs zxing-cpp, libdmtx, ZBar and OpenCV

Which library should read DataMatrix codes and barcodes in your software — zxing-cpp, libdmtx, ZBar, OpenCV or the libscanner libraries? Below are two open comparisons: every frame, every expected string, every library's answer for every frame and the benchmark programs are on GitHub, so any number can be checked. Where competitors do better, we say so.

DataMatrix: 1,368 “conveyor” frames

Synthetic frames from a camera above a conveyor: small modules, any rotation, blur, tilt, damage, curved and crumpled labels. One condition changes at a time; all libraries get the same grayscale buffer, one core, out-of-the-box settings. Dataset and programs: datamatrix-benchmark.

LibraryRead of 1,368False readsMedian per frame
dmr 1.0.7 (libscanner)1,126 (82.3%)05.7 ms
zxing-cpp 3.1.1955 (69.8%)01.9 ms
libdmtx 0.7.8892 (65.2%)012.1 ms
ZXing (Java) 3.5.443 (3.1%)00.8 ms

The overall share depends on the chosen conditions, so the limits matter more — the worst value at which a library still reads at least 90% of frames:

Conditiondmrzxing-cpplibdmtx
Module size, pixels1.42.02.5
Rotation (at 2.5 px/module)anyup to 20°up to 30°
Motion blur, pixels645
Print contrast0.050.120.12
Print growth−55 … +70%±30%±30%
Data area damage10%5%5%
Label curved on a cylinder180°150°60°
Noise σ, levels303010

Frames read by some competitor but not by dmr: 12; frames read only by dmr: 126.

Barcodes: 6,899 symbols from third-party datasets

EAN-13/8, UPC-A/E and Code 128 on public image datasets with third-party ground truth (Artelab, DEAL KAIST, SmartEngines, Open Food Facts, Wikimedia Commons). Dataset lists and programs: barcode-1d-benchmark.

ReaderRead of 6,899False reads on 988 images without a code
unir 1.2.7 (libscanner)4,974 (72.1%)0
ZBar (pyzbar 0.1.9)3,882 (56.3%)0
zxing-cpp 3.1.13,724 (54.0%)0
OpenCV 4.10 + super-resolution model2,919 (42.3%)7

The gap is largest on photos taken without autofocus: unir reads 93%, zxing-cpp and ZBar 15–16%.

Where competitors do better

  • Speed on clean frames. zxing-cpp reads DataMatrix 3× faster than dmr (1.9 ms vs 5.7 ms median); on barcodes everyone reads, it also beats unir at the 90th percentile.
  • Heavy noise. At noise σ = 60 libdmtx read 6 frames of 12, dmr 3.
  • Price and license. zxing-cpp (Apache 2.0) and libdmtx (BSD) are free and open source; the libscanner libraries are commercial, with a one-month trial.
  • Symbologies. zxing-cpp reads PDF417, Aztec and a dozen more formats; unir reads DataMatrix, QR, Code 128, GS1-128 and EAN/UPC.

Why Dynamsoft, Scandit and Cognex are not here

The licenses of most commercial SDKs forbid publishing benchmark results without the vendor's consent. The frames, expected strings and programs are open: any licensee of a commercial SDK can run it on them.

What to choose

  • Clean images, free open-source code required — zxing-cpp. For GS1 marking codes take the string with the GS separator from bytes (see reading DataMatrix in Python).
  • A camera on a line: small, blurred, rotated or curved codes, zero false reads — dmr for DataMatrix, unir if the frame also has barcodes.
  • Barcodes from phone photos without autofocus — unir.

Try it

Check your own image in the online decoder, which runs the same unir. The libraries: dmr and unir; the first month on a machine is free and needs no network.

Chestny ZNAK is a trademark of CRPT LLC (ООО «Оператор-ЦРПТ»); GS1 is a trademark of GS1 AISBL. The product is not affiliated with or certified by their owners.