barclean

Photograph a damaged barcode. Get back a clean one.

Rust core · QR · Aztec · DataMatrix · PDF417

Download APK

Android · arm64 · no Google account needed · source on GitHub

Folded, smudged, scuffed, badly printed — or with a logo pasted over the middle. barclean recovers the data, rebuilds the symbol that was actually there, and saves it as a PNG.

barclean recovering an occluded QR symbol

Knowing where damage is doubles what Reed–Solomon can fix

Reed–Solomon corrects errors — unknown position, unknown value — at half the rate it corrects erasures, damage whose position is known. A logo is damage whose position is, in principle, perfectly knowable. No shipping decoder exploits this, because they all binarize before detection: by the time anything knows where a module sits, the greyscale and colour that would have revealed the logo are gone, and the covered modules arrive as confident, wrong bits.

barclean carries the luminance and chroma all the way into the sampler. A partly-decoded symbol proves — algebraically, no heuristics — which of its codewords were wrong. QR's interleaving scatters a contiguous logo across every block, so surviving blocks report exactly which modules the occlusion covered. Declare those as erasures, retry at double the correction power, and blocks start coming back. Every rescued block sharpens the map and rescues the next one.

What it recovers

Measured at module level, not asserted — ECC-H with 30% of the symbol covered is a dead symbol to a plain decoder (4 of 11 blocks); barclean recovers all eleven:

ECCocclusionplain decodebarclean
M13–16%3/4 blocks4/4 — full recovery
Q19–25%2–7/8 blocks8/8 — full recovery
H26–30%4–9/11 blocks11/11 — full recovery
H31–32%2/11 blocks8/11 (partial)

Two properties are non-negotiable, tested at every ECC level and occlusion step: it never loses ground — the floor is always plain decoding's result — and clean symbols are untouched.

Restoration, not re-creation

The output is rebuilt from the corrected codewords, not by re-encoding the payload. Two encoders given identical text routinely emit different symbols; a "cleaned" code that scans to the right string but is structurally different is a re-creation that won't look like the code you photographed. So the tests compare module by module against the original. All four symbologies restore bit-exactly.

The app

Point it at a code. It freezes on a successful scan and shows what it did:

A logo's footprint shows up as a solid yellow-and-red patch, so "this was reconstructed" is something you can see rather than take on faith. Save writes a black-and-white PNG to Pictures/barclean with the quiet zone the symbology needs; there's a button per physical camera, and inverted and mirrored codes are handled automatically.

Get it

Download APK

Signed, arm64, installs directly — no store account. Source and build instructions at github.com/nickspiker/barclean.