Pipeline
Decoded payload
Codewords by block (data + EC; hover a byte — red were repaired)
How the decoder works
- Binarize — adaptive threshold over an integral image turns the frame into dark/light pixels.
- Finder patterns — scanlines hunt the 1:1:3:1:1 ratio, cross-checked vertically; the best three candidates become the TL/TR/BL landmarks.
- Geometry — module size is measured along the lines between finder centers (rotation-proof), the version inferred, the alignment pattern locked, and a projective transform fitted.
- Sampling — every module is sampled through the transform (5-probe majority vote).
- Format info — both 15-bit BCH copies are read and matched against all 32 valid codes → EC level + mask id.
- Codeword mapping — the mask is XORed off and bits are read in the zigzag order, grouping every 8 data modules into one codeword (the outlined units) and de-interleaving them into blocks.
- Reed–Solomon — each block runs syndrome → Berlekamp–Massey → Chien → Forney; repaired codewords glow red.
- Payload — the corrected bitstream parses into numeric / alphanumeric / byte / kanji segments.
Versions 1–10, all EC levels, rotated and mirrored codes supported. Everything is decoded locally — no library, no network.