Skip to content

Benchmark ​

Every number here comes from npm run bench on the corpus in the repo. CI runs it on every pull request and fails if any number changes without bench/expected.json and the README changing with it.

barcode-grader corpus ​

Synthetic barcode artwork with ground truth, for testing tools that check a barcode before it is printed: is it found, is its check digit right, is it the right size, are the bars tall enough, are the quiet zones clear, will the colours read in red light, does its data follow GS1's rules, and what ISO/IEC 15416 grade the drawing allows.

Version1.0.0
Filesbench/corpus/files/ (PDF and PNG), bench/corpus/manifest.json (ground truth), bench/corpus/datapackage.json (sizes and SHA-256 of every file)
LicenceData: CC0 1.0 (bench/corpus/LICENSE). Generator: MIT (bench/gen/, top-level LICENSE)
Built bybench/gen/build.py, byte for byte on macOS and Linux (x86_64, arm64) from pinned, freely licensed inputs: Reproducing it
Size8.6 MB

Contents ​

387 files (253 PDF, 134 PNG) from 338 items; every item has one code. manifest.json SHA-256 0c0a4213510a63094d0bdc3a9d4f000bb9a21af9128aac92b608c4469242a84b.

By category:

categoryitemsfilesPDFPNG
2d-size1420146
carton1212120
checkdigit1112111
colour3541356
databar9990
defects70912170
hri91192
placement6660
png3636036
quiet3438344
rotation2422
size5252520
symbology2326233
truncation2529254

By symbology (the format field):

formatfilesof them GS1 data
EAN131600
UPCA960
Code1283027
ITF14260
QRCode262
EAN8150
UPCE130
DataMatrix1211
DataBar55
DataBarExpanded33
DataBarLimited11

Expected verdict per rule, in files:

ruleflagokany
found38700
checkDigit123750
size3433617
barHeight193662
quiet2734020
colour2434914
symbology143658
placement113751
hri93780

Reference ISO/IEC 15416 grade (expect.grade): 125 files.

gradefiles
A49
B18
C22
D6
F30

PNG resolution:

resolutionfiles
300 dpi15
600 dpi37
1200 dpi70
no resolution in the file12

What each category varies:

categorywhat changesrule it tests
sizeEAN-13, UPC-A, EAN-8, UPC-E from 60% to 210% magnification; GS1-128 and ITF-14 X-dimension below and above their rangesize
pngthe same sizes as PNG at 300 and 600 dpi, and at 600 dpi with no resolution in the file (size cannot be known)size
2d-sizemodule size of GS1 DataMatrix, Digital Link QR and plain QRsize
databarGS1 DataBar variants (omnidirectional, truncated, stacked, limited, expanded) and their X-dimensionfound, size
truncationEAN-13 and UPC-A bars from full height down to 30%; shortened ITF-14 and GS1-128barHeight
quietclear space from none to the full requirement, closed in by a box or by text; EAN-13, UPC-A, ITF-14, QR, GS1 DataMatrixquiet
colourbar and background colours in RGB and CMYK: red, orange, yellow, grey and reversed codes, coloured and dark panelscolour, grade
defects1200 dpi rasters with bar gain and loss, blur, spots, voids, low contrast, and combinationsfound, grade
checkdigita wrong check digit in EAN/UPC, ITF-14, GS1-128, GS1 DataMatrix and Digital LinkcheckDigit
hridigits printed under the code that differ from the bars, or are missing; two that matchhri
symbologyGS1-128, ITF-14 (bearer bars, wide-to-narrow ratio), GS1 DataMatrix, GS1 QR and Digital Link data that breaks a rulesymbology
rotationladder orientation (90°)found
placement, cartona code near a trim line or on a folding carton's panels, folds and glue flapplacement, quiet

The manifest ​

manifest.json is { "generated": true, "items": [...] }. An item is one drawing of one code; it has one or more files (the same drawing as PDF and as PNG).

Item:

fieldtypemeaning
idstringunique; also the stem of its file names
categorystringone of the categories above
descstringwhat was drawn, in words
filesarraythe files that show this item
codesarraythe codes in each of those files; always exactly one

File:

fieldtypemeaning
filestringpath relative to the corpus directory
mimestringapplication/pdf or image/png
sizedbooleanwhether the file states a print size (every PDF; a PNG with a resolution)
dpinumber or nullPNG only: the resolution written in the file, null when none is

Code:

fieldtypemeaning
formatstringEAN13, UPCA, EAN8, UPCE, ITF14, Code128, DataBar, DataBarExpanded, DataBarLimited, QRCode, DataMatrix
textstringthe encoded data. GS1 element strings appear with or without brackets round the Application Identifiers, depending on the item; compare them with brackets and separators removed
gs1booleanwhether the symbol carries GS1 data (FNC1, or a DataBar)
bbox4 numbers[x0, y0, x1, y1] of the bars (no quiet zones, no digits) as fractions of the page, origin top left
x_mmnumberthe X-dimension drawn, in mm
expectobjectthe expected verdict per rule, below
magnumberEAN/UPC magnification (1.0 = 100%, X 0.33 mm)
sizedbooleanpng category: whether this file states its size
bar_height_pctnumbertruncation: bar height as a percentage of the height GS1 specifies at this size
quiet_left, quiet_rightnumberquiet: clear space drawn, in modules
bar, space3 numberscolour: sRGB of bars and background, 0 to 1
sc_rednumbercolour: symbol contrast in the linearised red channel, 0 to 1
defectobjectdefects: the defect parameters, below
ref_gradeobjectthe reference grade's detail, below
hri_printedarrayhri: the digit groups actually printed
rationumberITF-14 wide-to-narrow ratio
clear_to_fold_mmnumbercarton: distance from the code to the nearest fold

expect has one entry per rule: found, checkDigit, size, barHeight, quiet, colour, symbology, placement, hri, and for some linear codes grade.

  • "flag": a checker should report a problem. For found it means the code is there and should be found, which is every code.
  • "ok": it should not.
  • "any": borderline; either answer is accepted and the file is left out of that rule's score.
  • grade: a letter A, B, C, D or F, or null where the file is not graded.

How the ground truth is set ​

Every label is derived from the parameters the generator drew with, not from reading the result back (bench/gen/build.py):

  • size: EAN/UPC magnification below 79.5% or above 200.5% is flag, 79.5% to 90.5% is any (allowed, but below what many retailers ask), the rest ok. ITF-14 and GS1-128 flag outside X 0.495 to 1.016 mm, GS1 DataMatrix and GS1 QR outside 0.396 to 0.990 mm, DataBar outside 0.264 to 0.660 mm, each with 0.003 mm of tolerance. A PNG with no resolution is ok: there is no size to judge.
  • quiet: more than one module short of the symbology's requirement is flag, less than one module short is any.
  • colour: from the linearised red channel of the bar and background colours. Bars lighter than the background, contrast under 0.40, or bars reflecting more than half of what the background does are flag; contrast from 0.40 to 0.55 is any.
  • barHeight, checkDigit, hri, symbology, placement: set by the item that breaks them.

The reference grade ​

bench/gen/grade.py grades linear symbols to ISO/IEC 15416 and was written separately from the package it tests. It is given what a verifier does not have, the true geometry (where the bars are, X, and the element widths the symbol should have), and measures the rest:

  • reflectance is the linearised red channel of a 1200 dpi raster of the artwork (a 660 nm light source); for the defects files that raster is the file;
  • ten scan profiles spaced over the middle 80% of the bar height, each through a circular aperture of 0.150 mm for EAN/UPC and 0.250 mm for GS1-128;
  • per profile: Rmin, Rmax, symbol contrast, global threshold, minimum edge contrast, modulation, defects (ERNmax / SC), decode against the known element pattern including the quiet zones, and decodability from edge-to-similar-edge measurements (with the bar-width check for EAN/UPC 1/7 and 2/8);
  • a profile's grade is its lowest parameter grade; the symbol's is the mean of the ten, as a letter (A from 3.5, B from 2.5, C from 1.5, D from 0.5).

ref_grade keeps the mean of each parameter over the ten profiles, decoded_scans, the worst letter per parameter (worst) and why profiles failed (fails). Graded files are EAN-13 in colour and EAN-13, UPC-A and GS1-128 in defects. EAN-8, UPC-E, ITF-14, DataBar and the 2D symbols have no reference grade.

The defects model, applied to a black-on-white raster at 1200 dpi: gain widens (or, negative, narrows) every bar by that fraction of X; spots and voids are levels 1 to 3 of small discs of ink in the spaces or missing ink in the bars (0.25 to 0.5 X in radius), at seeded positions; rb and rs are the reflectance of ink and paper; blur is a Gaussian of that many X.

Limits ​

  • Synthetic only. No file is a scan or a photograph, and none is real packaging artwork: one code on a plain page, or on a simple carton outline.
  • One code per file, so it says nothing about finding several codes on a page, or about false detections in type, logos and patterns.
  • Print effects are simulated: uniform bar gain, Gaussian blur, round spots and voids, two flat reflectances. No halftone screens, substrate texture, ink spread that varies along a bar, registration, curvature or creasing.
  • The reference grade is of the artwork, not of a print. It is one independent implementation of ISO/IEC 15416 and has not been checked against a calibrated verifier (ISO/IEC 15426-1) or a conformance test card.
  • No ISO/IEC 15415 reference grade for the 2D symbols.
  • Retail and general-distribution sizes only; no healthcare, direct-part-marking or small-item size ranges.
  • Human-readable digits are drawn in one typeface. PDFs name Helvetica without embedding it, so each renderer substitutes its own; PNGs carry Liberation Sans 2.1.5, which has Helvetica's widths and its own shapes.
  • Digital Link and Application Identifier coverage is a handful of cases, not a conformance suite.
  • placement is in the manifest, but judging it needs the dieline, and the package in this repository does not score it.

Scoring another tool ​

For each file, run the tool and reduce what it says to: where it found a code, and for each rule whether it reported a problem. Then, per rule:

  • a file whose expect is flag counts as caught if the tool reported that problem, missed otherwise;
  • a file whose expect is ok counts as a false alarm if it did;
  • any is not counted;
  • for grade, compare letters: exact, within one, or further.

A code counts as found when a result's box overlaps bbox by more than 15% of the smaller of the two. For decoders, bench/compare/lib/match.mjs adds the comparison of the data (leading zeros of UPC-A as EAN-13, UPC-E expansion, GS1 brackets and separators).

bench/run.mjs does this for barcode-grader, classifying its sentences with the patterns in bench/rules.json; bench/compare/run.mjs does the found-and-read part for open-source decoders. Report the corpus version with any number.

Reproducing it ​

Anyone can rebuild the corpus and get the committed files byte for byte. In a container, from the repository root:

sh
docker build -t barcode-corpus bench/gen && docker run --rm -v "$PWD":/repo:ro barcode-corpus

builds it on Linux and compares it with the committed copy (node bench/compare/dataset.mjs --check); exit status 0 means all 387 files and manifest.json are identical. bench/gen/README.md has the same in a Python virtual environment.

Every input is pinned and freely licensed: the generator (MIT), Liberation Sans Regular 2.1.5 for the digits (SIL OFL 1.1, bundled in bench/gen/fonts/), Pillow 12.3.0, numpy 2.5.5 and scipy 1.18.1 (bench/gen/requirements.txt, binary wheels on every platform below), bwip-js 4.11.4, and in the container python:3.13.18-slim-bookworm and node:24.22.3-bookworm-slim by digest.

built onPythonfiles byte-identicalmanifest.json
macOS 26.3 arm643.12.8387 of 387byte-identical
macOS 26.3 arm643.15.2387 of 387byte-identical
Linux x86_64 (Docker, emulated)3.13.18387 of 387byte-identical
Linux arm64 (Docker)3.13.18387 of 387byte-identical

The bytes do not depend on the platform's zlib (PNGs are deflated by the generator's own encoder, PDF content streams are not compressed), on Pillow's text layout engine (text is laid out from the font's advance widths) or on its maths library (8-bit sRGB comes from exact thresholds). They do depend on the pinned versions: another Pillow brings another FreeType, which can change the anti-aliased edges of the digits, and other numpy or scipy builds may change blurred and noisy pixels in the last bit. bench/gen/README.md has the detail.

Versions ​

The version is in datapackage.json, with the SHA-256 of every file; the manifest's hash above identifies a build.

1.0.0 is the first public version: the build described here, the first that rebuilds byte for byte on any platform. Earlier builds existed only in the repository's history; they drew the digits with Apple's system Helvetica, encoded some real products' GTINs, and are not versions of the dataset. Scores measured on them are not comparable with 1.0.0.

  • Patch: documentation or descriptor changes; no file and no label changes.
  • Minor: items added; every existing file and label unchanged, so old scores still hold on the old subset.
  • Major: any existing file, label or reference grade changes. Scores across major versions are not comparable.

Citing ​

Agentic Flow LLC. barcode-grader corpus, version 1.0.0: synthetic barcode artwork with GS1 rule ground truth and reference ISO/IEC 15416 grades. 2026. Distributed with the barcode-grader package.

CC0 does not require this; it is how to make a result traceable to the files it was measured on.

Provenance and rights ​

  • Every file is written by bench/gen/build.py. Bars and modules are rectangles computed by bench/gen/symbols.py, or from module patterns encoded by bwip-js (MIT); nothing is copied from existing artwork.
  • No fonts are embedded in the corpus. PDFs refer to the standard Helvetica by name; PNGs contain digits rasterised from Liberation Sans Regular 2.1.5 (pixels, not font software). The font file is in bench/gen/fonts/, unmodified, under the SIL Open Font License 1.1 (bench/gen/fonts/LICENSE), with Liberation's reserved font name kept. (pdf.js ships a LiberationSans-Regular.ttf too, but that file is version 1.07.4, whose own licence string is the older Liberation Fonts licence, not the OFL; the generator does not use it.)
  • The only text besides digits, Application Identifiers and batch codes is "Net wt 500 g" on three quiet-zone files; the only named colour is a spot called "Dieline" on the twelve carton files. There are no logos, brand names or product names.
  • No encoded number belongs to a product. GTIN-13s, the GTIN-14s and the SSCC are built on GS1 Company Prefix 9501101, which the GS1 General Specifications use for their examples (9501101530003 and its GTIN-14 and SSCC forms are GS1's own example numbers; the others are further numbers on the same prefix). GTIN-12s (UPC-A) are on 0614141, the U.P.C. Company Prefix GS1 US uses in its examples, and GTIN-8s on GS1-8 Prefix 950 (GS1 Global Office). These are documented example prefixes, not a range GS1 guarantees will never be assigned: GS1's only number range reserved for demonstrations, prefix 952, is one a checker must flag on a pack (barcode-grader does), and so are restricted-circulation, coupon and unissued prefixes and GS1's published sample numbers. None of the numbers used is any of those, so the grader raises no finding about the number itself. UPC-E cannot be built on those prefixes (it needs number system 0 or 1 and a company prefix that zero-suppresses), so its three numbers (0 123456 5, 0 654321 7 and 1 234563 9 in their UPC-E form) are digit sequences, not documented examples. Builds before 1.0.0 encoded real products' GTINs (for example 3017620422003 and 7622210449283); none remains. The web addresses are on example.com and id.gs1.org.

MIT licensed. It predicts from the artwork; it is not a verifier.