How autofocus works: How cameras and lenses achieve precise focus
Whether capturing a fleeting expression, fast-moving wildlife, or cinematic video footage, autofocus systems are designed to keep subjects sharp, responsive, and accurate. But behind this ease is a complex interplay between the camera’s detection system and the lens’ built-in motors.
To understand how autofocus works, and why some systems work well in certain scenes while others don't, we have to look at how the camera determines where to focus, and how the lens actually executes that instruction. These two components work in tandem, and the effectiveness of one often depends on the accuracy of the other. Autofocus is not a single system, but a layered architecture of optical, electronic, and mechanical processes that vary from brand to brand and even from lens to lens.
Camera-Based Autofocus Systems
The first half of the autofocus process occurs inside the camera body. Here, the system "decides" where to focus by analyzing the scene and measuring sharpness through various detection strategies.
Contrast Detection Autofocus
Contrast detection is the most intuitive and mathematically simplest autofocus method. It is based on a familiar principle: the sharpest image is the one with the highest local contrast, just like when you squint your eyes to focus.
In digital cameras that use this method, the sensor evaluates contrast by measuring the difference in brightness between adjacent pixels. As focus changes, contrast gradually increases until it reaches a peak. At this point the camera stops focusing because it has determined that maximum sharpness has been achieved. This process is iterative and non-predictive, and the lens must move past the best focus position and back again to confirm that the sharpest contrast point has been found.
While highly accurate in static scenes, contrast detection falls short in speed. Since it doesn't know in advance the direction and distance the lens needs to move, "focus hunting" is common in low-light environments or when photographing low-contrast subjects. This can cause delays in action photography and missed focus moments. However, the accuracy of this method makes it valuable when photographing static subjects, studio work, or video scenes, where accuracy is more important than speed.
Phase Detection Autofocus
Phase detection autofocus turns focusing into a geometry problem. Unlike contrast detection, which evaluates sharpness after moving the lens, phase detection estimates the direction and amount of movement required before you start moving the lens. This pre-calculation makes phase detection much faster.
In SLR systems, phase detection usually involves a separate AF module located within the camera body, which uses mirrors and beam splitters to direct part of the incoming light to a dedicated sensor. In mirrorless systems, phase detection pixels are embedded directly into the image sensor. This allows the camera to capture the image and analyze the focus at the same time.
The system works by comparing two versions of an image projected from either side of the lens. When the two projections are in phase, the image is in focus. If they are out of phase, the system can instantly tell whether the lens needs to be moved closer or farther away, and approximately how much. This speed and directionality makes phase detection ideal for capturing fast-moving subjects and for continuous autofocus tracking.
However, in SLR architectures, phase detection is prone to calibration errors. Since the AF sensor and image sensor are physically separated, slight misalignments can occur, known as front or back focusing. Mirrorless systems with on-sensor phase detection have largely solved this problem, combining accuracy with speed.
Hybrid Autofocus
Recognizing the complementary strengths of contrast and phase detection, many manufacturers are now combining the two technologies into hybrid systems. In these systems, phase detection provides a fast, coarse focus estimate, while contrast detection refines the result for precise sharpness.
This synergy reduces focus hunting while maintaining precision, and has become the standard approach on most modern mirrorless cameras. Hybrid systems are especially effective in video AF, where smooth transitions and accurate tracking are critical. The fusion of these technologies also delivers better performance in a wider range of shooting scenarios, from high-speed sports to quiet interviews.
Dual Pixel Autofocus
Dual Pixel CMOS Autofocus (DPAF) is a unique (and proprietary) implementation of phase detection that relies entirely on the image sensor.
Because nearly every pixel is involved in both image creation and focus detection, DPAF achieves nearly 100% AF coverage and remarkably smooth subject tracking. The system is particularly valuable in video, where it is prized for its ability to follow complex subject movements without focus hunting or jumping.
AI-based autofocus and subject recognition
More and more modern autofocus systems are integrated with artificial intelligence. These systems can detect and prioritize specific subjects — faces, eyes, animals, vehicles, etc. — not only based on focus metrics, but also through pattern recognition and predictive learning. These algorithms analyze visual data and make context-aware decisions about which parts of the scene should remain in focus, even if the subject is partially obscured or moves unpredictably.
AI AF not only makes tracking more accurate, it’s also more intuitive. It allows photographers to focus on timing and composition, trusting that the camera will take care of the technical precision aspects.
Lens-based AF systems
While the camera decides where to focus, the lens is responsible for executing that decision. The AF motor within the lens physically moves internal elements to adjust the focal plane. These motors vary widely in performance, noise, and video compatibility.
Conclusion
Autofocus is no longer just a convenience, but a fundamental aspect of how photographers interact with their subjects. From the fast calculations of phase detection to the deliberate refinement of contrast detection, autofocus technology varies.
As camera systems evolve, autofocus continues to be an area of intense innovation.