The Basic Structure of a QR Code
A QR code is a 2D matrix of black and white squares arranged on a square grid. The three large squares in three corners are 'finder patterns' that allow scanners to locate the code and determine its orientation regardless of the angle. The smaller squares distributed throughout contain the actual data plus error correction information.
How Data Is Encoded
QR codes encode data in a binary format where the arrangement of dark and light squares represents bits. Four encoding modes optimize for different content types: numeric (digits only), alphanumeric (letters, digits, symbols), byte (arbitrary binary data), and kanji (Japanese characters).
Error Correction Magic
QR codes use Reed-Solomon error correction — the same algorithm used in CDs and satellite communications. This allows a QR code to be partially damaged, obscured, or covered with a logo and still scan successfully. Error correction comes in four levels: L (7%), M (15%), Q (25%), and H (30%).
Camera Scanning Process
A smartphone camera captures a frame containing the QR code. Image processing algorithms locate the three finder patterns, determine orientation, and warp the image to compensate for perspective distortion. The result is sampled on a grid to read each module as black or white, then Reed-Solomon decoding corrects any errors.
QR codes pack impressive engineering into a simple printed square. Finder patterns, multiple encoding modes, and Reed-Solomon error correction make them remarkably robust and fast to scan from any angle.