Qraft

The Hidden Secrets Inside Your Smartphone Camera

Your Camera Is Made of Light Sensors

A smartphone camera is essentially a chip packed with tens of millions of tiny light sensors called an image sensor. Light enters through the lens and hits each sensor, converting brightness into numbers. When reading black-and-white patterns, the camera focuses on contrast - white reflects more light (high numbers), black absorbs it (low numbers). The sharper the contrast, the more accurate the reading.

How Autofocus Works

Modern smartphones use phase-detection autofocus, calculating focus distance from how light hits the sensor - similar to how human eyes judge distance using binocular vision. Focus locks in about 0.03 seconds. The sweet spot for scanning is 10-30 cm from the pattern.

The Decoder Reads the Pattern's Meaning

After the camera captures the image, decoder software locates three large square markers (finder patterns) to determine position and angle. It then divides the pattern into a grid, classifying each cell as white (0) or black (1). This binary sequence is converted back into text or URLs in under a second.

Why Damaged Patterns Still Work

Error correction embeds backup data within the pattern. At the strongest level, up to 30% of the pattern can be damaged and still be readable. Stronger correction means a larger, more complex pattern - a tradeoff between resilience and size.

A device to read even in dark places

The reason a QR code can be read even in a dim room or at night is that the camera automatically adjusts the amount of light it takes in to match the surrounding brightness. In a scene with little light, it tries to take in more light, and in a scene that is too bright, it holds down the amount taken in. Even so, when light is insufficient, the image becomes dark, the light and dark of the pattern become hard to distinguish, and scanning tends to fail. At such times, raising the screen brightness, or moving a little toward a direction where light hits the code, improves it. Helping the camera's adjustment is the shortcut to scanning success.

Why it cannot read when too close or too far

Bringing a smartphone too close to a QR code can, on the contrary, make it unreadable. This is because there is a limit to the distance at which the camera can focus. Too close, and the focus does not match and the pattern blurs. Conversely, too far, and each individual cell is captured too small, and light and dark become indistinguishable. When you cannot scan well, the reason you adjust by bringing the smartphone closer or farther is that the camera is searching for the distance at which it can just focus. Finding a moderate distance leads to quick scanning.

Why 2D Codes Are Faster Than Barcodes

Barcodes store information in one dimension (horizontal lines), maxing out at about 20 characters. 2D patterns use both horizontal and vertical axes, storing up to 7,089 characters. Three finder patterns enable instant position detection from any angle, unlike barcodes that require precise laser alignment.