Barcode and QR Detection
Barcode and QR detection finds the finder squares and stripe zones in a photo and reads them as strings, even when the label sits tilted in poor light.
Why Does This Exist?
Packages, tickets, and lab vials carry identity as printed codes. Typing them invites errors and stops lines. Phone cameras meet wrinkled plastic under glare, not flat scanner beds.
Barcode and QR detection exists to close that gap. Input is a photo that may hold codes anywhere. Output is boxes plus decoded strings with confidence. The box skill is object detection; the text cousin is text detection. The line home is industrial vision.
Use it when identity is printed as stripes or squares. Use RFID or OCR when codes are absent or human readable text is the source of truth.
Think of It Like This
Finding a book by its corner marks
You spot a book spine by three corner stickers, check the shelf gap around it, then straighten it before reading the title. No stickers, no read.
Finder squares are the stickers. The quiet zone is the shelf gap. Perspective fix is straightening the book. The analogy stops at damage: a torn sticker still lets you guess the book, while a torn finder often kills the decode until a second frame arrives.
How It Actually Works
Detect first, decode second. A 1D barcode needs a stripe zone with quiet margins; a QR needs three finder squares in an L shape plus timing patterns. Contract is image in, quads plus strings out. Warp each quad to a square with a homography, sample modules against the timing grid, then error correct: QR codes survive up to about percent damage at the highest level because redundancy is printed in. A version 1 code with module quiet zone decodes only when all three finders score above threshold.
Worked example
A parcel photo holds a QR tilted degrees with one glare spot over modules. Detection finds three finder squares at confidences , , and . The quad warps to pixels, giving pixels per module. Sampling reads the timing row cleanly, and error correction rebuilds the glared modules. Output string matches the manifest exactly with character errors. Without the warp, the same sampling misreads modules.
Watch Out For
Glare and blur that pass detection but kill decode
Detection fires on a shiny code while the modules underneath wash out. The symptom is high box confidence with empty strings. Fix it with polarizing light, exposure bracketing, and by rejecting decodes below a module contrast floor instead of guessing.
Tiny codes below the module sampling limit
A QR that spans pixels gives under pixels per module for a wide code. Sampling aliases edges. The symptom is flickering strings across frames. Fix it by moving closer, zooming, or specifying larger print; no decoder rescues sub Nyquist modules.
The Quick Version
- Detection finds stripes or finder squares; decoding reads modules as strings.
- Contract is photo in, quads plus strings out, with quiet zone enforced.
- The fixture warps a degree tilt to pixels per module for a clean read.
- Error correction rebuilds damaged modules when finders are solid.
- Light and print size decide success before any model runs.