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.
| Version | 1.0.0 |
| Files | bench/corpus/files/ (PDF and PNG), bench/corpus/manifest.json (ground truth), bench/corpus/datapackage.json (sizes and SHA-256 of every file) |
| Licence | Data: CC0 1.0 (bench/corpus/LICENSE). Generator: MIT (bench/gen/, top-level LICENSE) |
| Built by | bench/gen/build.py, byte for byte on macOS and Linux (x86_64, arm64) from pinned, freely licensed inputs: Reproducing it |
| Size | 8.6 MB |
Contents
387 files (253 PDF, 134 PNG) from 338 items; every item has one code. manifest.json SHA-256 0c0a4213510a63094d0bdc3a9d4f000bb9a21af9128aac92b608c4469242a84b.
By category:
| category | items | files | PNG | |
|---|---|---|---|---|
| 2d-size | 14 | 20 | 14 | 6 |
| carton | 12 | 12 | 12 | 0 |
| checkdigit | 11 | 12 | 11 | 1 |
| colour | 35 | 41 | 35 | 6 |
| databar | 9 | 9 | 9 | 0 |
| defects | 70 | 91 | 21 | 70 |
| hri | 9 | 11 | 9 | 2 |
| placement | 6 | 6 | 6 | 0 |
| png | 36 | 36 | 0 | 36 |
| quiet | 34 | 38 | 34 | 4 |
| rotation | 2 | 4 | 2 | 2 |
| size | 52 | 52 | 52 | 0 |
| symbology | 23 | 26 | 23 | 3 |
| truncation | 25 | 29 | 25 | 4 |
By symbology (the format field):
| format | files | of them GS1 data |
|---|---|---|
| EAN13 | 160 | 0 |
| UPCA | 96 | 0 |
| Code128 | 30 | 27 |
| ITF14 | 26 | 0 |
| QRCode | 26 | 2 |
| EAN8 | 15 | 0 |
| UPCE | 13 | 0 |
| DataMatrix | 12 | 11 |
| DataBar | 5 | 5 |
| DataBarExpanded | 3 | 3 |
| DataBarLimited | 1 | 1 |
Expected verdict per rule, in files:
| rule | flag | ok | any |
|---|---|---|---|
| found | 387 | 0 | 0 |
| checkDigit | 12 | 375 | 0 |
| size | 34 | 336 | 17 |
| barHeight | 19 | 366 | 2 |
| quiet | 27 | 340 | 20 |
| colour | 24 | 349 | 14 |
| symbology | 14 | 365 | 8 |
| placement | 11 | 375 | 1 |
| hri | 9 | 378 | 0 |
Reference ISO/IEC 15416 grade (expect.grade): 125 files.
| grade | files |
|---|---|
| A | 49 |
| B | 18 |
| C | 22 |
| D | 6 |
| F | 30 |
PNG resolution:
| resolution | files |
|---|---|
| 300 dpi | 15 |
| 600 dpi | 37 |
| 1200 dpi | 70 |
| no resolution in the file | 12 |
What each category varies:
| category | what changes | rule it tests |
|---|---|---|
| size | EAN-13, UPC-A, EAN-8, UPC-E from 60% to 210% magnification; GS1-128 and ITF-14 X-dimension below and above their range | size |
| png | the 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-size | module size of GS1 DataMatrix, Digital Link QR and plain QR | size |
| databar | GS1 DataBar variants (omnidirectional, truncated, stacked, limited, expanded) and their X-dimension | found, size |
| truncation | EAN-13 and UPC-A bars from full height down to 30%; shortened ITF-14 and GS1-128 | barHeight |
| quiet | clear space from none to the full requirement, closed in by a box or by text; EAN-13, UPC-A, ITF-14, QR, GS1 DataMatrix | quiet |
| colour | bar and background colours in RGB and CMYK: red, orange, yellow, grey and reversed codes, coloured and dark panels | colour, grade |
| defects | 1200 dpi rasters with bar gain and loss, blur, spots, voids, low contrast, and combinations | found, grade |
| checkdigit | a wrong check digit in EAN/UPC, ITF-14, GS1-128, GS1 DataMatrix and Digital Link | checkDigit |
| hri | digits printed under the code that differ from the bars, or are missing; two that match | hri |
| symbology | GS1-128, ITF-14 (bearer bars, wide-to-narrow ratio), GS1 DataMatrix, GS1 QR and Digital Link data that breaks a rule | symbology |
| rotation | ladder orientation (90°) | found |
| placement, carton | a code near a trim line or on a folding carton's panels, folds and glue flap | placement, 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:
| field | type | meaning |
|---|---|---|
id | string | unique; also the stem of its file names |
category | string | one of the categories above |
desc | string | what was drawn, in words |
files | array | the files that show this item |
codes | array | the codes in each of those files; always exactly one |
File:
| field | type | meaning |
|---|---|---|
file | string | path relative to the corpus directory |
mime | string | application/pdf or image/png |
sized | boolean | whether the file states a print size (every PDF; a PNG with a resolution) |
dpi | number or null | PNG only: the resolution written in the file, null when none is |
Code:
| field | type | meaning |
|---|---|---|
format | string | EAN13, UPCA, EAN8, UPCE, ITF14, Code128, DataBar, DataBarExpanded, DataBarLimited, QRCode, DataMatrix |
text | string | the 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 |
gs1 | boolean | whether the symbol carries GS1 data (FNC1, or a DataBar) |
bbox | 4 numbers | [x0, y0, x1, y1] of the bars (no quiet zones, no digits) as fractions of the page, origin top left |
x_mm | number | the X-dimension drawn, in mm |
expect | object | the expected verdict per rule, below |
mag | number | EAN/UPC magnification (1.0 = 100%, X 0.33 mm) |
sized | boolean | png category: whether this file states its size |
bar_height_pct | number | truncation: bar height as a percentage of the height GS1 specifies at this size |
quiet_left, quiet_right | number | quiet: clear space drawn, in modules |
bar, space | 3 numbers | colour: sRGB of bars and background, 0 to 1 |
sc_red | number | colour: symbol contrast in the linearised red channel, 0 to 1 |
defect | object | defects: the defect parameters, below |
ref_grade | object | the reference grade's detail, below |
hri_printed | array | hri: the digit groups actually printed |
ratio | number | ITF-14 wide-to-narrow ratio |
clear_to_fold_mm | number | carton: 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. Forfoundit 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% isany(allowed, but below what many retailers ask), the restok. ITF-14 and GS1-128flagoutside 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 isok: there is no size to judge. - quiet: more than one module short of the symbology's requirement is
flag, less than one module short isany. - 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 isany. - 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
defectsfiles 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.
placementis 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
expectisflagcounts as caught if the tool reported that problem, missed otherwise; - a file whose
expectisokcounts as a false alarm if it did; anyis 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:
docker build -t barcode-corpus bench/gen && docker run --rm -v "$PWD":/repo:ro barcode-corpusbuilds 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 on | Python | files byte-identical | manifest.json |
|---|---|---|---|
| macOS 26.3 arm64 | 3.12.8 | 387 of 387 | byte-identical |
| macOS 26.3 arm64 | 3.15.2 | 387 of 387 | byte-identical |
| Linux x86_64 (Docker, emulated) | 3.13.18 | 387 of 387 | byte-identical |
| Linux arm64 (Docker) | 3.13.18 | 387 of 387 | byte-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-graderpackage.
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 bybench/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 aLiberationSans-Regular.ttftoo, 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.