Python Barcode Library Benchmark: ZXing-C++ vs PyZBar vs Dynamsoft on 8,000 Images

Need a license key to run the code in this tutorial?

Get a 30-day free trial license

This benchmark compares three Python barcode readers on the same 8,000 synthetic JPEGs: zxing-cpp 3.1.1, pyzbar 0.1.9 and Dynamsoft Barcode Reader 11.6.50.1028. Each reader ran with every symbology it supports enabled, one decode call per image, and one shared scoring rule. Dynamsoft Barcode Reader returned 6,701 exact images (83.76%), ZXing-C++ 3,852 (48.15%) and PyZBar 2,657 (33.21%). The three readers support different symbologies, and 6,197 of the 11,372 annotated symbols fall outside PyZBar’s format list.

The Dynamsoft synthetic barcode dataset holds 8,000 JPEGs, 11,372 annotated symbols across 24 symbologies and 200 background-only controls. Every image is loaded once with OpenCV and handed to each reader as the same ndarray, with one decode call per reader. The numbers come from the same raw records as the audited Python benchmark, which covers Dynamsoft and ZXing-C++ in more detail.

Python barcode library benchmark on 8,000 synthetic images

What you’ll build: a Python benchmark that loads a verified 8,000-image manifest, decodes every image with ZXing-C++ 3.1.1, PyZBar 0.1.9 and Dynamsoft Barcode Reader 11.6.50.1028, normalizes equivalent payloads, and reports exact-image accuracy, symbol recall, precision and decode time for each reader.

Key Takeaways

  • On the same 8,000 images, Dynamsoft Barcode Reader scored 83.76% exact images and 84.96% symbol recall, ZXing-C++ 48.15% and 49.38%, and PyZBar 33.21% and 34.99%.
  • PyZBar’s gap is mostly format coverage: the zbar build inside the wheel decodes 11 of the 24 symbologies, so 6,197 annotated symbols fall outside its reach.
  • On those 11 shared formats the race tightens: PyZBar 76.89% recall, ZXing-C++ 76.39% and Dynamsoft 94.26% over 5,175 symbols.
  • ZXing-C++ is the fastest reader at 14.12 ms mean (10.53 ms median), PyZBar follows at 17.96 ms, and Dynamsoft needs 51.88 ms per image.
  • All three readers returned nothing on the 200 background-only controls, so their precision figures — 98.88%, 98.93% and 95.60% — are not inflated by guessing.

Common Developer Questions

Which Python barcode library is the most accurate on these 8,000 images?

Dynamsoft Barcode Reader is the most accurate in this benchmark: 6,701 of 8,000 images decoded exactly (83.76%) against 3,852 (48.15%) for ZXing-C++ and 2,657 (33.21%) for PyZBar. An image counts as exact only when every annotated format and payload comes back with no extra prediction. Symbol-level recall follows the same order: 84.96% (9,662 / 11,372), 49.38% (5,616 / 11,372) and 34.99% (3,979 / 11,372).

Why does PyZBar read so few images?

PyZBar is a ctypes binding around libzbar, and the libzbar inside the Windows wheel is version 0.10.1, which decodes 11 symbologies: Codabar, Code 39, Code 93, Code 128, EAN-8, EAN-13, GS1-128, Interleaved 2 of 5, QR Code, UPC-A and UPC-E. The dataset contains 24, including Aztec, Data Matrix, DotCode, MaxiCode, Micro QR, PDF417 and four postal formats, so 6,197 of the 11,372 annotated symbols have no decoder at all. ZXing-C++ covers 16 symbologies (3,840 unsupported symbols) and Dynamsoft 23 (474 unsupported IATA 2 of 5 symbols).

Is PyZBar faster than ZXing-C++ in Python?

No. On this dataset ZXing-C++ averaged 14.12 ms per image (10.53 ms median, 43.57 ms at p95) and PyZBar 17.96 ms (11.32 ms median, 65.14 ms at p95). PyZBar is slower on average even though it searches for fewer symbologies. Dynamsoft Barcode Reader averaged 51.88 ms (26.06 ms median, 152.30 ms at p95) with every format enabled.

Do the three readers agree when all of them can read the format?

They are close on the two open-source readers and clearly apart from Dynamsoft. On the 11 symbologies all three support, over 5,175 annotated symbols, recall is 94.26% for Dynamsoft, 76.89% for PyZBar and 76.39% for ZXing-C++. Precision is 98.88%, 95.60% and 98.93%, and none of the three produced a prediction on the 200 background-only control images.

Which Reader Should You Use?

  Best fit Poor fit
Dynamsoft Barcode Reader 11.6.50.1028 Mixed symbologies, postal and industrial formats, damaged or low-contrast labels, dense multi-symbol frames, configurable templates and support Pipelines that must stay near 15 ms per image
ZXing-C++ 3.1.1 Apache-2.0 projects, inspectable source, captures limited to the 16 formats it implements, latency-sensitive scripts DotCode, MSI, Pharmacode, postal codes, or heavy rotation
PyZBar 0.1.9 A quick LGPL reader for shelf labels, QR codes and retail codes in low-distortion images Aztec, Data Matrix, PDF417, Micro QR, postal or industrial codes, or frames with several symbols

The numbers behind that table come from one measured pass, described in the four steps below.

What Are ZXing, ZBar, and Dynamsoft Barcode Reader?

ZXing-C++ is the C++ port of the Java ZXing library. The zxing-cpp wheel is a compiled binding, covers 16 of the dataset’s 24 symbologies, and ships the decoder source under Apache 2.0.

ZBar is a C library from 2009 with an emphasis on 1D retail codes and QR. pyzbar binds it through ctypes and uses whatever libzbar it finds: the DLL bundled in the wheel on Windows, the system package on Linux and macOS.

Dynamsoft Barcode Reader is the commercial reader inside Dynamsoft Capture Vision. The Python package dynamsoft-barcode-reader-bundle exposes LicenseManager.init_license() and CaptureVisionRouter.capture(), covers 23 of the 24 symbologies in this dataset, and requires a license key at runtime. The audited harness installs dynamsoft-capture-vision-bundle 3.6.5000, while the sample project installs dynamsoft-barcode-reader-bundle 11.6.5000. Both ship the same DBR engine, 11.6.50.1028.

  ZXing-C++ (Python) PyZBar Dynamsoft Barcode Reader
Install pip install zxing-cpp pip install pyzbar pip install dynamsoft-barcode-reader-bundle
License Apache 2.0 LGPL-2.1 Commercial, 30-day trial
Symbologies in this dataset 16 of 24 11 of 24 23 of 24
Exact images 48.15% 33.21% 83.76%
Symbol recall 49.38% 34.99% 84.96%
Mean decode time 14.12 ms 17.96 ms 51.88 ms

Prerequisites

  • Python 3.10 or later, plus zxing-cpp==3.1.1, pyzbar==0.1.9, dynamsoft-barcode-reader-bundle==11.6.5000, opencv-python and numpy.
  • The 8,000-image dataset. Clone Dynamsoft/datasets-from-dynamsoft and use synthetic-benchmark/dataset-by-format. The images and the manifest.jsonl ground truth sit in the same folder.
  • A Dynamsoft license key. Get a 30-day free trial license.
git clone https://github.com/Dynamsoft/datasets-from-dynamsoft.git
cd python-barcode-qrcode-sdk/examples/official/zxing_zbar
pip install -r requirements.txt

On Windows, PyZBar needs the Visual C++ 2013 runtime when the wheel’s libzbar-64.dll cannot find MSVCR120.dll. See Common Issues & Edge Cases for the fix.

Step 1: Load the Manifest Instead of Inventing Test Images

The dataset ships with manifest.jsonl, one JSON object per image. Each record holds the relative path, the capture scenario and severity, the effects applied, and the annotated symbols with their format, payload and final-image quadrilateral. Reading that file is the whole test-data pipeline.

import json
from pathlib import Path

from src.benchmark_framework import TestCase

DATASET = Path("D:/datasets-from-dynamsoft/synthetic-benchmark/dataset-by-format")

def load_cases(dataset_dir=DATASET, limit=0):
    cases = []
    with (Path(dataset_dir) / "manifest.jsonl").open(encoding="utf-8") as handle:
        for line in handle:
            sample = json.loads(line)
            truth = sample["ground_truth"]
            cases.append(TestCase(
                test_id=sample["sample_id"],
                image_path=str(Path(dataset_dir) / sample["relative_path"]),
                expected_barcodes=[item["text"] for item in truth],
                expected_formats=[item["format"] for item in truth],
                rotation_angle=0.0,
                barcode_count=len(truth),
                test_type=sample["scenario"],
                metadata={"scenario": sample["scenario"], "ground_truth": truth},
            ))
            if limit and len(cases) >= limit:
                break
    return cases
Dataset stage Count Role in the run
JPEG images 8,000 The denominator for every reader
Annotated symbols 11,372 Ground truth formats and payloads
Symbologies 24 13 linear, 4 postal, 7 2D
Background-only controls 200 An empty response is correct
Mixed-symbology images 153 Frames carrying several formats
Images with 2–16 symbols 1,328 Crowded scenes

python run_benchmark.py --limit 50 scores the first fifty images in seconds, which is enough to check that the manifest, the license and all three readers are wired correctly.

Step 2: Give Every Reader the Same Pixels

The benchmark loads each JPEG once and passes the same array to all three readers. Only the reader call is timed. Image loading is recorded separately and never enters the decode statistics.

ZXing-C++ receives the array with every format enabled and the same options the audited run uses:

import cv2, zxingcpp

image = cv2.imread(str(path), cv2.IMREAD_COLOR)
results = zxingcpp.read_barcodes(
    image,
    try_rotate=True,
    try_downscale=True,
    try_invert=True,
    text_mode=zxingcpp.TextMode.Plain,
    binarizer=zxingcpp.Binarizer.LocalAverage,
    ean_add_on_symbol=zxingcpp.EanAddOnSymbol.Read,
)
for item in results:
    print(item.format.name, item.text)

PyZBar gets one decode call and nothing else, because pyzbar exposes no binarizer, rotation, inversion or multi-symbol controls:

from pyzbar import pyzbar

image = cv2.imread(str(path), cv2.IMREAD_COLOR)
for symbol in pyzbar.decode(image):
    print(symbol.type, symbol.data.decode("utf-8"))

Dynamsoft Barcode Reader gets the preset widened to BF_ALL, one thread per task and no expected symbol count:

from dynamsoft_barcode_reader_bundle import (
    CaptureVisionRouter, EnumBarcodeFormat, EnumPresetTemplate, LicenseManager,
)

LicenseManager.init_license(license_key)
router = CaptureVisionRouter()
template = EnumPresetTemplate.PT_READ_BARCODES.value
_, _, settings = router.get_simplified_settings(template)
settings.barcode_settings.barcode_format_ids = EnumBarcodeFormat.BF_ALL
settings.barcode_settings.expected_barcodes_count = 0
settings.barcode_settings.max_threads_in_one_task = 1
router.update_settings(template, settings)

image = cv2.imread(str(path), cv2.IMREAD_COLOR)
captured = router.capture(image, template)
for item in captured.get_items():
    print(item.get_format_string(), item.get_text())

All three readers get exactly one decode call per image and the same ndarray, so the numbers describe the libraries rather than any preprocessing added around them.

Step 3: Run the Measured Pass

python run_benchmark.py   --dataset D:/datasets-from-dynamsoft/synthetic-benchmark/dataset-by-format

The runner decodes 8,000 images with three readers in one process, writes one record per image per reader to results/detailed_results.json, and then builds results/benchmark_report.html plus the charts in results/charts/. On a 16-thread desktop the full pass takes about 12 minutes, and Dynamsoft accounts for most of it.

Useful flags while iterating:

  • --limit 50 — score only the first fifty images.
  • --scenario clean rotation — restrict the run to specific manifest scenarios.
  • --libraries zxing_cpp pyzbar — skip the commercial reader.
  • --no-charts — skip chart rendering.

Timing covers the reader call and the input conversion it needs. Matching, JSON serialization and reporting happen after the clock stops, so a slow disk does not change the decode numbers.

Step 4: Score What Each Reader Actually Returned

Comparing raw strings undercounts every reader, because the same code arrives in different shapes. ZXing-C++ returns UPC-A as a zero-prefixed 13-digit EAN-13, zbar returns UPC-E as its expanded UPC-A, and GS1-128 may or may not carry (01) and (10) application identifiers. The project normalizes each payload before matching:

LEADING_GS1 = re.compile(r"^(?:\]C1|\x1d|\{GS\}|\{FNC1\})+")
AI_WRAPPERS = re.compile(r"\((01|10)\)")

def payload_key(text, barcode_format=""):
    value = AI_WRAPPERS.sub(r"\1", LEADING_GS1.sub("", text.strip()))
    fmt = barcode_format.upper().replace("_", "").replace("-", "")
    if fmt in {"UPCA", "EAN13"} and value.isdigit() and len(value) == 13 and value[0] == "0":
        value = value[1:]
    if fmt == "UPCE" and value.isdigit() and len(value) == 8:
        value = expand_upce(value)
    return value

With that in place, naming conventions stop mattering. Codabar start and stop characters, Code 39 asterisks and UPC-A/EAN-13 zero prefixes no longer decide the score. Only wrong payloads, missing symbols and extra predictions do.

Results: Three Readers, One Dataset

Image accuracy, symbol recall and mean decode time for the three Python readers

Reader Exact images Image accuracy Symbol recall Precision Wrong-read images No read Incomplete Mean Median P95
Dynamsoft Barcode Reader 11.6.50.1028 6,701 / 8,000 83.76% 84.96% 98.88% 103 827 369 51.88 ms 26.06 ms 152.30 ms
ZXing-C++ 3.1.1 3,852 / 8,000 48.15% 49.38% 98.93% 56 3,828 264 14.12 ms 10.53 ms 43.57 ms
PyZBar 0.1.9 (zbar 0.10.1) 2,657 / 8,000 33.21% 34.99% 95.60% 123 4,987 233 17.96 ms 11.32 ms 65.14 ms

The gap between the first and second row is 2,849 images, and between the second and third it is 1,195. Those two numbers have different causes. ZXing-C++ and PyZBar both miss symbols they can theoretically read, but PyZBar also has no decoder for seven of the 2D and postal formats in the dataset.

The sample project prints slightly higher success counts — 6,736, 3,891 and 2,754 — because its counter stops at “every annotated payload was found” and ignores extra predictions. Adding the precision rule moves 35 Dynamsoft images, 39 ZXing-C++ images and 97 PyZBar images from success to wrong read, which is exactly the 6,701 / 3,852 / 2,657 above.

Scenario by scenario, the ordering never changes, but the distance does:

Exact-image rate by capture scenario

Scenario Dynamsoft ZXing-C++ PyZBar
Clean labels 90.98% 56.59% 40.49%
Perspective 77.10% 52.74% 33.71%
Partial occlusion 75.93% 52.18% 39.74%
Combined effects 70.97% 31.18% 15.67%
Rotation 82.93% 31.06% 20.49%
Blur 81.44% 43.84% 29.12%

Rotation is the sharpest split. Zbar and ZXing-C++ both lose most exact images once the symbol is tilted, while Dynamsoft still returns 82.93%. Frames with four annotated symbols are exact for 31.6% of images with Dynamsoft, 15.8% with ZXing-C++ and 5.3% with PyZBar.

Where the Gap Comes From: Coverage, Then Reading

Symbol recall on the 11 shared symbologies

Sorting the misses by cause is the most useful part of the run:

Reader Supported symbols Unsupported symbols Recall on its supported list Recall on the 11 shared formats
Dynamsoft Barcode Reader 10,898 474 88.66% 94.26%
ZXing-C++ 7,532 3,840 74.56% 76.39%
PyZBar 5,175 6,197 76.89% 76.89%

Two conclusions follow. First, coverage explains most of PyZBar’s headline number: it cannot read 54% of the annotated symbols, and no tuning changes that. Second, on the formats all three implement, the two open-source readers land within half a point of each other (76.89% against 76.39%), while Dynamsoft is 17 points ahead — which is where rotation, low contrast and multi-symbol handling show up.

Precision tells the other side of the story. Dynamsoft and ZXing-C++ return 109 and 61 unmatched predictions across the 8,000 images. PyZBar returns 183, largely because zbar emits partial Interleaved 2 of 5 reads: a wide ITF label can come back as two or three overlapping substrings, and every one of them counts as an extra prediction. None of the three readers guessed on a control image.

Inspect a Failing Image

When a reader returns nothing on an image that should hold a code, decode that one file before touching the harness. simple.py runs all three readers on a single image, prints what each returned, and opens a window per library with the found symbols outlined:

python simple.py -i image.jpg

ZXing-C++ barcode detection in Python

PyZBar barcode detection in Python

Dynamsoft Barcode Reader barcode detection in Python

Point simple.py -d at the dataset folder instead of a file and it walks the manifest, writing benchmark.xlsx with one row per image and an OK n/m or MISS n/m cell for each reader. That sheet answers the first question of any failure: was the symbol not found, or was it found with a payload the matcher did not normalize?

Common Issues & Edge Cases

  • import pyzbar fails with Could not find module 'libzbar-64.dll'. The wheel’s DLL imports MSVCR120.dll from the Visual C++ 2013 runtime. Install the Visual C++ 2013 redistributable or copy MSVCR120.dll next to libzbar-64.dll in site-packages/pyzbar/.
  • PyZBar reads more codes on Linux than on Windows. The Windows wheel bundles zbar 0.10.1. A Linux or macOS install links the distribution’s libzbar, which is a newer build and covers more symbologies. Report the version you tested, because the numbers move with it.
  • zbar prints pdf417.c assertion warnings on stderr. The bundled build carries an unfinished PDF417 decoder that never returns a symbol but complains while scanning. The warnings are harmless. Redirect stderr if they clutter a log.
  • UPC-E results arrive as EAN-13. zbar expands UPC-E to the 12-digit UPC-A and reports it as a 13-digit EAN-13. Normalize before matching, or every UPC-E frame counts as a failure.
  • Dynamsoft stops with a license error. Pass a valid key to LicenseManager.init_license(). A missing or expired key fails at initialize() and every image counts as a no-read with zero decode time.
  • The manifest is missing. --dataset must point at dataset-by-format, not at the repository root. The runner needs manifest.jsonl beside the images/ folder.

Conclusion

The same 8,000 images separate the three readers cleanly: Dynamsoft Barcode Reader at 83.76% exact images, ZXing-C++ at 48.15% and PyZBar at 33.21%, with mean decode times of 51.88 ms, 14.12 ms and 17.96 ms. Format coverage explains most of the spread, but not all of it — even on the 11 symbologies all three implement, Dynamsoft reads 94.26% of symbols against roughly 76% for the two open-source readers.

If you need one number to decide, pick format coverage first and accuracy second. A reader that cannot parse DotCode, PDF417 or postal codes is not a candidate for a warehouse or mailroom pipeline no matter how fast it runs, and a 14 ms decode is worth little when 3,828 of 8,000 images come back empty. For retail codes and QR in controlled images, zxing-cpp remains the sensible open-source baseline.

Source Code

Get the complete sample project source code on GitHub

The same manifest also drives the runnable Python example, which is the version wired into the four steps above.

Want to run this code in your own project?

Get a 30-day free trial license