Reading damaged barcodes on phones
Read 90%+ of damaged barcodes correctly on its damaged test set, where a commercial scanning SDK read 70%, with models trained on 10M+ synthetic images.
- Computer vision
- Samsung R&D Institute India
- Jul 2022 – Aug 2024
- Built
- 2 min read
1 of 8Make the data
Every training image starts as a random string that follows its format's rules, drawn as a real barcode.
Knox Capture lets a phone do an enterprise barcode scanner's job. On industrial sites the codes are blurred, partly covered, seen at an angle or shining under lights, and a scanner that reads the wrong number is worse than one that reads nothing. I built the part that reads damaged codes on the phone, and knows when to give up.
Problem
Industrial barcodes arrive blurred, partly covered, at an angle or under glare. A plain decoder either fails or returns a wrong code, and a wrong code is the costly failure.
Approach
- Data first. A synthetic-data engine writes random strings that follow each format's rules and draws them as barcodes. Then it damages them on purpose: blur, lines, spots, glare, reflections, tears and scratches, each drawn from a probability model. Perspective, curvature and lighting make each one a camera view, blended onto photos of real objects. 10M+ images in all.
- Labels that stay true. The hardest part: every transform also moves the labels, the bounding box and the barcode's outer and inner rectangles. Algebra and trigonometry set how far a code can turn, move or zoom before a label leaves the picture.
- A chain of small models. YOLO finds the barcode, Mask R-CNN cuts it out, a U-Net trained pixel to pixel restores the damaged bars, a classifier names the format among 10+ 1D formats, then an open-source decoder reads it.
- Knowing when to stop. Every read carries a confidence score. A wrong read costs far more than no read, so a code beyond recovery is refused instead of guessed.
- On the phone. Android, the hardware-accelerated camera and TensorFlow Lite, mostly on a Galaxy S21 FE: each model under 1 MB, under 100 ms per scan for an undamaged code and up to 350 ms for a damaged one.
Results
On the damaged synthetic test set, 90%+ of codes were read correctly, where a commercial scanning SDK read 70%. Real photos were checked too, by hand, on a smaller set. Refusing hopeless codes cut wrong reads.
More in computer vision
- Recognising many faces at once on edge devicesMar 2023 – Aug 2024
A multi-face recognition engine at 99.2% accuracy and 30+ FPS on edge devices, with face search cut from 1,200 ms to 87 ms. · Samsung R&D Institute India · Shipped
- Generative inpainting on a phone's NPU and DSPSep 2024 – Jan 2025
Redesigned a generative inpainting feature, object removal and image completion, so its models fit NPU and DSP latency budgets for the Snapdragon Summit demo. · Qualcomm · Demo
- Telling attention from distraction, with emotion recognitionSep 2023 – Nov 2023
Detects whether a person at a screen is attentive or distracted, at 87% accuracy; checks across frames cut false alarms by 40%. · Samsung R&D Institute India · Shipped
- An AI exam-proctoring platform (Satyapan)Jul 2023 – Oct 2023
An anti-cheat exam platform used for 2,000+ employees across 100+ tests, with 60% less administrative overhead. · Samsung R&D Institute India · Shipped