Skip to content

How Does a Camera Autofocus?

Autofocus uses measurements from incoming light to choose and adjust a lens focus position. Contrast detection looks for strong image detail as focus changes; phase detection compares paired views of the light to infer the needed adjustment. Subject recognition helps choose what to focus on, while a motor moves the focusing elements. These are related but separate jobs.

Measurement, target selection and lens movement work together

Tap a face on a camera screen and the background may soften while the person becomes sharp. The action feels immediate, but several decisions happen between the tap and the finished image: select a target, estimate the focus error, move the lens and check the result.

Keeping those jobs separate makes autofocus easier to understand. It also explains why a camera can recognise the right eye yet still produce a blurred photograph, or find sharp focus on the wrong object.

Follow the mechanism

  1. The camera selects an image region or recognised subject.
  2. Its focusing system evaluates light from that region.
  3. A controller directs the lens mechanism toward a suitable focus position.
  4. The system checks or updates focus as the scene changes.

Focus is an optical adjustment before it is a software decision

Light from a point in the scene needs to form a sufficiently small image on the sensor for that detail to look sharp. Light passing through transparent optical materials is only the start; its path through the lens system must also be controlled. Adjusting focus changes the relationship between the lens system, subject distance and image plane.

In a camera lens, focusing commonly involves moving one or more optical elements or groups. The exact mechanism varies. Nikon’s AF technology overview describes autofocus as detecting the subject and adjusting the optical system, emphasising both measurement and lens control.

This is different from making an already blurred image look crisper with a digital sharpening filter. Autofocus acts on the optical arrangement during capture. Software processing may follow, but it cannot be treated as the same operation.

Sources: [1]

Contrast detection looks for a peak in image detail

An out-of-focus edge spreads over a wider area of the image. As focus improves, changes in brightness across suitable fine detail become more pronounced. Contrast-detection autofocus evaluates such image information while the focus position changes.

The basic method searches for a position associated with strong contrast in the chosen region. A single measurement may not say whether the lens should move nearer or farther, so the system may test a direction and compare the result.

Stanford’s teaching demonstration illustrates this search principle. It is a useful explanation of contrast detection, but its older camera examples should not be mistaken for a complete map of current camera designs. The measurement principle persists even when products combine it with other information.

Sources: [2]

Phase detection compares paired views

Phase-detection autofocus compares information formed from different portions of the incoming light. When the selected subject is out of focus, the paired information is displaced in a way that can indicate the direction and extent of the required adjustment.

Nikon’s overview describes the method in terms of splitting incoming light and assessing image misalignment. Canon’s Dual Pixel explanation gives a particular implementation: two light-sensitive parts of an imaging pixel supply separately analysed signals for focusing.

The paired signals are not two ordinary photographs shown to the user. They are measurement channels used by the focusing system. Nor does the method imply that every camera requires a separate reflex-mirror autofocus module; phase measurements can be made at the imaging sensor in suitable designs.

Sources: [1], [3]

Four jobs inside autofocus
Part or idea What it does Common misunderstanding
Target selection Chooses the region or subject that matters. Recognising an eye automatically moves glass into focus.
Focus measurement Estimates or evaluates the focus state. Every camera must send out a ranging beam.
Lens actuation Moves the focusing mechanism. The sensor becomes sharp merely by changing a label.
Tracking and checking Updates the decision as the scene changes. One correct measurement guarantees a sharp later exposure.

Hybrid systems combine methods rather than choosing a slogan

A camera can use more than one kind of focus information. Nikon’s description of its Z-series AF system identifies a hybrid arrangement combining phase and contrast detection. The use of one method does not automatically exclude all contribution from the other.

This makes simple rankings such as “phase is always better” misleading. The operating result depends on the sensor, lens, control algorithm, selected mode and scene. A method describes part of the mechanism, not a complete performance guarantee.

When comparing products, distinguish a general principle from a tested result. Knowing that a system uses phase detection tells you something about how it measures focus. It does not establish how it will track a specific subject with a particular lens in poor light.

Sources: [4]

Subject recognition chooses a target; focus control still has work to do

Face and eye detection help identify where focus should be placed. Nikon’s camera manual treats AF-area selection and face or eye detection as explicit controls. That choice feeds the focusing process rather than replacing it.

Imagine two people standing at different distances. The system might focus accurately on the nearer person while you intended the farther one. The optical operation can succeed even though the target-selection decision does not match your intention.

Conversely, a box around the intended eye indicates that the system has selected or recognised it. It does not remove the need for adequate focus measurement, lens response and a suitable exposure. A user-interface marker is evidence of a camera decision, not a guarantee about every pixel in the resulting photograph.

Sources: [5]

Why autofocus sometimes hunts

A plain wall offers little variation for a focus system to analyse. Repeated patterns, obstructions, very small subjects and weak lighting can also make the useful measurement ambiguous or difficult. Nikon’s focusing guidance lists several situations in which autofocus may struggle.

The visible back-and-forth search is often called hunting. It can be the system trying different lens positions without settling confidently on the intended detail. That behaviour does not identify one universal hardware fault.

A useful diagnostic distinction is whether the selected region contains usable detail and whether it contains the intended subject. A richly textured fence in front of an animal gives the camera plenty to focus on, but it may be the wrong thing. Better target selection and better measurement conditions address different problems.

Sources: [5], [6]

Tracking must account for time as well as distance

For a moving subject, a correct focus estimate can become outdated. The system has to measure, communicate with the lens and move its mechanism while the subject continues to travel. Continuous focusing therefore involves repeated control, not just one initial lock.

Nikon’s AF technology account describes the importance of calculation speed and lens communication in a particular tracking implementation. Those are system-level features. They explain why focusing performance is about timing as well as optical measurement.

As a teaching example, suppose a subject moves half a metre during the interval between a measurement and an exposure. Even an accurate initial distance describes where it was, not where it is at capture. The example uses an invented displacement to make the timing problem clear; it is not a camera performance specification.

Sources: [1]

Focus and motion blur can fail independently

Imagine a perfectly focused camera photographing a moving subject during a long exposure. Its image can smear across the sensor while the shutter is open. That blur is a time-of-exposure problem, even if the lens focus position was correct.

Now imagine a stationary subject photographed with focus set behind it. A very short exposure prevents movement blur but does not repair the focus error. These thought experiments separate two causes that can look similar in a small preview.

When reviewing a photograph, ask where any sharp detail lies and whether the blur has a directional smear. Neither clue is infallible, but the questions are more useful than attributing every soft image to autofocus. Optical focus, target choice and movement during exposure all deserve separate attention.

Questions readers ask

Does autofocus always measure distance with a laser?

No. Many systems evaluate light coming through the imaging lens using contrast or phase information. Active ranging is a different approach used in some devices.

Why does tapping the screen change focus?

The tap commonly selects a region or subject for the camera to prioritise. The focusing system then measures and adjusts for that target according to the selected mode.

Is eye detection the same as phase detection?

No. Eye detection helps choose what to focus on. Phase detection is a way to obtain focus information from light.

Can a camera focus on the wrong object accurately?

Yes. The lens can be correctly adjusted for a target you did not intend, such as a foreground obstruction.

Will autofocus prevent all blur?

No. Subject motion, camera movement and other capture conditions can produce blur even when the optical focus is suitable.

Sharpness comes from a coordinated control loop

Autofocus connects a selected subject with an optical adjustment. It measures light, directs a mechanism and keeps checking as conditions change. Contrast, phase information and recognition each contribute different parts of that process.

The next time a focus box appears, read it as one stage of a control loop. The important result is the captured image, produced after the camera has turned its decision into physical lens movement.

Continue exploring

Sources and further reading

  1. Nikon — AF System technology overview
  2. Stanford CS178 — Autofocus: contrast detection
  3. Canon — Intro to Dual Pixel Autofocus
  4. Nikon Support — Nikon Z-series hybrid autofocus system
  5. Nikon Z 7/Z 6 Online Manual — Focus
  6. Nikon Support — Why autofocus requires contrast
Accuracy and updates

Last updated November 6, 2026.

Report a correction →
ABOUT THE EDITORIAL TEAM

Barnakle Editorial Team

Barnakle Editorial Team is the collective byline used for Barnakle’s editorial articles. The contributor profile explains the team identity and links to the publication’s editorial policies.

More from the editorial team →
THE CURIOUS LIST

Discover something remarkable.

Ideas from nature, science, history and beyond—delivered regularly.

Join the Curious List →