Qraft

Image Recognition

Image recognition automatically identifies patterns, objects, characters, and faces in digital images and video. Machine learning and deep learning raised its accuracy sharply, and it now underpins self-driving cars, medical imaging diagnosis, face authentication, and OCR.

QR code scanning (decoding) is a special case in which the shapes to be found are fixed by the standard, so the work begins with preprocessing. The colour image from the camera is reduced to a grayscale brightness map, and a threshold turns each pixel into black or white. Only then does the decoder search that binary image for the finder patterns - the three position-detection squares at the corners - and combine their geometry with the alignment patterns that larger versions carry to build the perspective transform that cancels the tilt and distortion of the shot. The module grid is then sampled point by point in the corrected coordinate system, the format and version information is read, Reed-Solomon error correction repairs damaged codewords, and the original data comes back out.

Modern smartphones run this pipeline in real time: recognition finishes the moment a QR code appears in the camera preview, with no shutter press. What does the work here is not the learning-based recognition of the first paragraph but classical image processing - thresholding combined with geometry. Because the target shape is fixed, a decoder can scan only every few rows of a frame and look closely only where the light and dark runs follow the 1:1:3:1:1 ratio typical of a finder pattern. And because a frame that fails simply gives way to the next one, the cost per frame stays low.