How to Benchmark Barcode Reading in C++ with ZXing-C++ and Dynamsoft Barcode Reader

A barcode reader that handles a clean retail label can still miss a rotated parcel tag, a blurred hang tag, or a frame holding sixteen different symbols. This benchmark runs ZXing-C++ and Dynamsoft Barcode Reader over 8,000 synthetic JPEGs from the Dynamsoft synthetic barcode corpus — 11,372 annotated symbols, 24 symbologies, 36 reusable background scenes, and 200 background-only controls — and keeps every raw decode record for independent review.

The corpus is generated from a seeded manifest instead of collected third-party photos, so each image carries its JPEG hash, seed, applied capture effects, and every symbol’s format, payload, and final-image quadrilateral. Both readers see the same RGB frame and are graded by one location-independent matcher that separates exact images, wrong reads, no reads, and incomplete images. On a single full pass, Dynamsoft Barcode Reader returned 6,714 exact images (83.93%) against 3,852 (48.15%) for ZXing-C++, while ZXing-C++ completed its average decode call in 8.60 ms against 39.11 ms.

ZXing-C++ and Dynamsoft Barcode Reader synthetic benchmark

What you’ll build: A reproducible C++ benchmark that builds ZXing-C++ alongside the harness, runs both barcode readers on one RGB frame, scores the synthetic manifest with one matcher, and exports raw JSONL plus a self-contained HTML report.

Key Takeaways

  • The corpus holds 8,000 JPEGs, 11,372 annotated symbols, 24 symbologies, and 36 background scenes. It includes 7,800 positive images with 1–16 symbols each, 153 mixed-symbology images, and 200 background-only controls.
  • ZXing-C++ and Dynamsoft Barcode Reader receive the same RGB888 pixel buffer for every image; image loading, result matching, JSON serialization, and report generation sit outside the decode clock.
  • Every row uses all 8,000 images as the denominator. A correct image needs a one-to-one match for every expected format and payload with no extra predictions; an empty response is correct on a control.
  • With ReadBarcodes_Default and BF_ALL, DBR produced 6,714 / 8,000 exact images (83.93%) and 9,672 / 11,372 matched symbols (85.05% recall). ZXing-C++ produced 3,852 exact images (48.15%) and 5,616 matched symbols (49.38% recall).
  • ZXing-C++ is substantially faster (8.60 ms mean versus 39.11 ms). Its 49.38% symbol recall is largely a coverage limit: 3,840 annotated symbols belong to formats the ZXing-C++ build does not support.

Common Developer Questions

How do I benchmark ZXing-C++ against Dynamsoft Barcode Reader fairly in C++?

Load each image once, pass the same immutable pixels to both SDKs, enable their supported formats without per-image hints, and measure only the decoder call. The project also uses one location-independent matching function for both result sets and publishes the manifest hash, the raw JSONL hash, and the decoder settings so a reviewer can reproduce the score.

Which barcode reader performed better on the synthetic corpus?

Dynamsoft Barcode Reader led on image accuracy and symbol coverage in this run: 6,714 of 8,000 exact images (83.93%) versus 3,852 (48.15%) for ZXing-C++, and 9,672 of 11,372 symbols (85.05% recall) versus 5,616 (49.38%). Restricted to the 16 symbologies both readers support, DBR reached 93.56% recall against 74.56%. Precision is close — 98.80% for DBR versus 98.93% for ZXing-C++ — so the difference is how many symbols each engine finds, not how often it is wrong when it reports one.

When should I choose Dynamsoft Barcode Reader instead of ZXing-C++ for a C++ project?

Choose Dynamsoft Barcode Reader when missed scans cost more than license cost, especially for postal codes, DotCode, MSI, Pharmacode, dense multi-symbol frames, or production workflows that need packaged templates and commercial support. Choose ZXing-C++ when you need an open-source baseline, inspectable source, a smaller decode budget, and inputs restricted to the 16 formats it supports.

Full Synthetic Benchmark Video

The video summarizes the corpus, the shared input method, and the measured results.

Prerequisites

Step 1: Build ZXing-C++ with the Benchmark

The harness records ZXing-C++ as a Git submodule, and CMake builds its core reader target alongside the benchmark.

set(ZXING_READERS ON CACHE BOOL "" FORCE)
set(ZXING_WRITERS OFF CACHE STRING "" FORCE)
set(ZXING_C_API OFF CACHE BOOL "" FORCE)
set(ZXING_EXAMPLES OFF CACHE BOOL "" FORCE)
set(ZXING_UNIT_TESTS OFF CACHE BOOL "" FORCE)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/zxing-cpp/CMakeLists.txt")
    message(FATAL_ERROR "ZXing-C++ submodule is missing. Run: git submodule update --init --recursive")
endif()
add_subdirectory(zxing-cpp EXCLUDE_FROM_ALL)

Initialize the submodule and build the executable.

git submodule update --init --recursive
cmake -S . -B build -G "Visual Studio 17 2022" -A x64
cmake --build build --config Release --target barcode_benchmark benchmark_tests
ctest --test-dir build -C Release --output-on-failure

Step 2: Give Both Readers the Same Pixels

The benchmark loads every image once into a shared three-channel RGB buffer. The buffer remains unchanged while both decoder adapters read it, so the comparison does not depend on separate image-loading paths.

ZXing-C++ receives an ImageView over that buffer.

const ZXing::ImageView view(image.rgb.data(), image.width, image.height,
                            ZXing::ImageFormat::RGB, image.stride);
const auto begin = std::chrono::steady_clock::now();
const auto barcodes = ZXing::ReadBarcodes(view, options_);
run.decode_time = std::chrono::steady_clock::now() - begin;

Dynamsoft Barcode Reader receives a CImageData object over the same bytes.

CImageData input(static_cast<int>(image.rgb.size()), image.rgb.data(), image.width, image.height,
                 image.stride, IPF_RGB_888);
const auto begin = std::chrono::steady_clock::now();
CCapturedResult* captured = router_->Capture(&input, template_name_.c_str());
run.decode_time = std::chrono::steady_clock::now() - begin;

Step 3: Verify the Synthetic Corpus Manifest

The corpus ships as one directory per symbology plus mixed-symbology images and background-only controls. Its manifest records the JPEG hash, seed, applied effects, and each symbol’s format, payload, and quadrilateral. Seeded layouts compose BWIPP-generated labels over reusable scenes of packaging, paper, fabric, and work surfaces, then apply isolated and combined capture effects: perspective, rotation, defocus and motion blur, low resolution and contrast, noise, JPEG compression, partial occlusion, uneven illumination, and glare.

python -m pip install -r requirements.txt
npm ci
python generate_by_format.py --output .runs/grouped-base
python expand_corpus.py --base .runs/grouped-base --output .runs/generated-8000
python validate.py --dataset .runs/generated-8000 --expected-images 8000
python review_images.py --dataset .runs/generated-8000
Corpus stage Count How it relates to the run
JPEG images 8,000 The denominator for each decoder, including controls
Annotated symbols 11,372 Ground truth formats and payloads
Symbologies 24 Linear, postal, and 2D families
Background scenes 36 Reusable packaging, paper, fabric, and work surfaces
Background-only controls 200 An empty response is a correct image
Mixed-symbology images 153 Frames carrying several different formats
Positive images 7,800 Images with 1–16 annotated symbols
Decoder records 16,000 8,000 images × 2 decoders × 1 measured pass

The generator bounds projected shape distortion, preserves QR and Micro QR finder patterns, and caps synthetic occlusion at 22% of a symbol. Blur and downsampling account for module size, the quality screen measures expected dark-to-light transitions from the encoder mask, and perceptual hashes plus color thumbnails screen for near-duplicates. The reported results describe this published corpus rather than arbitrary production captures.

Step 4: Run and Validate the Complete Dataset

The benchmark writes one resumable result record per image and decoder. results.jsonl is the append-only raw stream, which makes long runs easier to resume and validate one line at a time. The project also writes a complete JSON package and a summary for consumers that expect a single file.

build/Release/barcode_benchmark.exe run `
  --images "D:/datasets-from-dynamsoft/synthetic-benchmark/dataset-by-format/images" `
  --manifest "D:/datasets-from-dynamsoft/synthetic-benchmark/dataset-by-format/manifest.jsonl" `
  --output results/full `
  --dbr-template ReadBarcodes_Default `
  --zxing-config configs/zxing_all_supported.json `
  --license-key-file "../../license-key.txt" `
  --repetitions 1

The validator checks record keys, image counts, ground truth consistency, repetitions, summary totals, and explicit decoder errors.

python tools/validate_results.py `
  --results results/full/results.jsonl `
  --summary results/full/summary.json `
  --expected-images 8000 `
  --expected-ground-truth 11372 `
  --expected-repetitions 1

Step 5: Inspect Accuracy and Decode Time

Each decoder made one timed pass over all 8,000 images. The measured machine ran Ubuntu 24.04.5 LTS under WSL2 on an Intel Core i5-13400F with 16 logical processors, GCC 13.3.0, one decoder process, and 24 warm-up calls per SDK. Reader order was shuffled per image with a fixed seed.

Image accuracy and symbol recall answer different questions. Image accuracy measures whole images where every expected symbol matched and no extra prediction appeared; symbol recall measures how many of the 11,372 annotated symbols were found.

Image accuracy = exact images / 8,000 images
Symbol recall = matched ground truth symbols / 11,372 annotated symbols
Precision = matched symbols / (matched symbols + unmatched predictions)
Decoder Exact images Image accuracy Symbol recall Precision Wrong-read images No read Incomplete Mean Median P95
Dynamsoft Barcode Reader 11.6.50.29329 6,714 / 8,000 83.93% 85.05% 98.80% 107 820 359 39.11 ms 22.99 ms 114.04 ms
ZXing-C++ 3.1.1 3,852 / 8,000 48.15% 49.38% 98.93% 56 3,829 263 8.60 ms 6.11 ms 27.19 ms

Failures are split into wrong-read images (at least one unmatched prediction), no-read images (expected symbols and zero matches), and incomplete images (some matches, no unmatched predictions). An SDK error counts as no read. DBR recorded one false positive on a background-only control; ZXing-C++ recorded none. The 9,819 symbols read by at least one of the two readers leave 1,079 supported symbols unread by both.

DBR produced 2,862 more exact images and 4,056 more matched symbols in this run, a 35.78 percentage point lead in image accuracy. On the 16 symbologies both engines support, the gap narrows to 93.56% versus 74.56% recall, which shows how much of the raw difference comes from format coverage: 3,840 annotated symbols belong to formats ZXing-C++ cannot read, including postal codes, DotCode, MSI, and single-track Pharmacode. ZXing-C++ keeps the latency advantage — 8.60 ms mean versus 39.11 ms — and slightly higher precision, so the result is a coverage-versus-speed trade-off on this corpus, not a universal ranking.

Difficulty is visible in the scenario breakdown. DBR scored 91.71% exact images on clean labels, 78.06% under perspective, 76.58% under partial occlusion, and 71.27% on combined effects. ZXing-C++ scored 56.59%, 52.74%, 52.18%, and 31.34% on the same groups. Frames with four symbols were the hardest for both readers: 34.2% exact for DBR and 15.8% for ZXing-C++.

The matcher normalizes UPC-A against its zero-prefixed EAN-13 equivalent, expands UPC-E, folds CODE_39 extensions and ITF14 into their base formats, strips GS1-128 / CODE_128 ]C1, {GS}, and {FNC1} markers, strips Codabar start/stop characters, and removes postal check characters when they validate. Each unmatched prediction counts against precision, and barcode location is not part of the score.

Dynamsoft, the developer of Dynamsoft Barcode Reader, built and published this benchmark. The corpus, its generator, the manifest hashes, decoder settings, raw records, and the HTML report are all public, so the accuracy and timing figures can be recomputed line by line.

The static report lists every no-read and incomplete filename by reader, links to the original JPEG, shows the annotations and returned values, and reports per-symbol recall, precision, format coverage, multi-code results, and false positives on the controls.

python report.py --run results/native --output review

Common Issues & Edge Cases

  • The ZXing-C++ directory is empty: Run git submodule update --init --recursive before configuring CMake.
  • DBR fails during initialization: Provide a valid license and confirm that CMake copied the DBR templates, models, and runtime libraries next to the executable.
  • A control image returns a barcode: The 200 background-only images have no annotations, so any prediction is an unmatched false positive and lowers precision. Check the report’s control list.
  • A run stops before completion: Run the same command again. Existing sample, decoder, and repetition keys are skipped.

When to Choose Dynamsoft Barcode Reader or ZXing-C++

  Best fit Poor fit
Dynamsoft Barcode Reader 11.6.50.29329 Recall-sensitive pipelines, postal and industrial symbologies, dense multi-symbol frames, damaged or blurred labels, configurable templates and vendor support Workloads where the decode budget must stay under 10 ms per image
ZXing-C++ 3.1.1 Open-source baselines, inspectable source, controlled inputs limited to its 16 supported formats, latency-sensitive capture loops Frames containing DotCode, MSI, Pharmacode, or postal codes it cannot decode

Choose Dynamsoft Barcode Reader when your C++ workflow is recall-sensitive and the business cost of a missed scan is high. This benchmark shows DBR returning 2,862 more exact images on the corpus, which makes it the stronger fit for damaged labels, dense scenes, and production pipelines that need packaged runtime assets and support.

Choose ZXing-C++ when you need an open-source engine that is easy to inspect, embed, and ship without license cost. Its 98.93% precision and 8.60 ms mean decode time in this run show that it remains valuable as a transparent baseline, a research harness, or a good-enough decoder for controlled inputs where lower coverage is acceptable.

Conclusion

The Python and JavaScript companions score the identical 8,000-image synthetic manifest through their own runtime bindings, so the three articles isolate the language/runtime path rather than the corpus.

This project produces an auditable comparison of ZXing-C++ and Dynamsoft Barcode Reader from 8,000 seeded synthetic images. The shared pixel pipeline, verified manifest, raw records, decoder settings, and generated report make the measured accuracy and decode time reproducible.

Reproducibility

The manifest, the raw records, and the report are all published, so the accuracy and precision figures above can be recomputed line by line rather than taken on trust.

  • Manifest. dataset-by-format/manifest.jsonl holds 8,000 image records with SHA-256 identity, seed, effects, and per-symbol ground truth; inventory.json records the manifest hash and corpus counts.
  • Raw records. results/native/results.jsonl holds one record per image per decoder; run.json records the raw results SHA-256, decoder versions, and environment.
  • Validation. validate.py --expected-images 8000 and the scorer fail the run when record keys, counts, ground-truth consistency, or repetitions disagree.
  • Environment. The report pins the OS, compiler, processor, SDK versions, warm-up count, and order seed used for this run.
  • Source. Complete benchmark project on GitHub.

Re-running both decoders and diffing your results.jsonl against the published one turns any disagreement into a difference in pixels, configuration, or build — not in interpretation.