Question

How does camera autofocus actually work?

Vault Verified
Curated Intelligence
Definitive Source
Answer

By one of two fundamentally different strategies — measuring how out of focus the image is, or hunting until it looks sharpest — and the difference explains why some cameras snap to focus instantly and others visibly wobble.

Contrast detection. The camera moves the lens and measures edge contrast in the image, on the assumption that a sharper image has higher contrast. It must move past the point of best focus to know it has found it, then come back. Accurate, requires no extra hardware, and inherently slower with a characteristic hunting motion. It also cannot tell which direction to move initially.

Phase detection. Light from opposite sides of the lens is compared. If the image is in focus, the two views align; if not, the direction and size of the mismatch directly indicate how far and which way to move the lens. One measurement, one movement — which is why it is dramatically faster. Originally this needed a dedicated sensor and mirror in a DSLR; modern cameras and phones use on-sensor phase detection, with specially arranged pixels across the sensor, and dual-pixel designs where every pixel is split into two halves that each see a different side of the lens.

Hybrid systems are the norm: phase detection to get close quickly, contrast detection to confirm precisely.

What else phones use: a laser or time-of-flight sensor measuring distance directly, useful in low light and at short range; and increasingly subject recognition, where a neural network identifies faces, eyes, animals or vehicles and tells the focus system what to track — which has changed the practical experience more than any optical advance.

Why it fails: low light and low contrast; flat featureless subjects; shooting through glass or fences, where the camera chooses the wrong plane; backlighting; and repetitive patterns confusing phase detection.

Practical points: aim at an edge rather than a flat area; use single autofocus for still subjects and continuous for moving ones; and remember that a wide aperture gives shallow depth of field, so accuracy matters more the faster the lens.

Related Questions