Skip to content

How Autofocus Works

A bald eagle flying overhead with its wings spread wide against a plain grey sky
Photo: Bald Eagle Flying Over by Duncan Rawlinson. 200mm, f/7.1, 1/640, ISO 100. Shot at 200mm, f/7.1, 1/640 and ISO 100: dark wings against an even sky give the autofocus strong edges to measure, while the sky itself offers nothing to lock onto.

Autofocus (AF) is the system that moves your lens until the part of the scene you chose is sharp. It decides two things on every shot: how far away to focus, and when to stop adjusting. Knowing how it measures focus explains why it is quick on a bird against the sky, why it hunts on a white wall at dusk, and why a photo can be perfectly focused on the wrong thing.

What focusing physically does

Inside the lens, a group of glass elements slides forward or back. Each position puts the plane of sharp focus at one distance from the camera. Everything at that distance is as sharp as the lens can make it, and everything nearer or farther gets gradually softer. That plane is flat and parallel to the sensor, like a sheet of glass standing in the scene.

So autofocus never focuses on “the subject”. It focuses on a distance, measured at whatever spot the active AF point or box covers. If that spot is a leaf in front of the bird, the leaf’s distance wins. Almost every autofocus problem comes back to this: the camera measured the right thing badly, or measured the wrong thing well.

How much a small miss matters depends on depth of field, the zone around the focus plane that still looks sharp. With a 50mm lens at f/2 and a subject 3 m away, that zone runs from about 2.80 m to 3.23 m on a full frame camera, so a focus error of a few centimeters disappears. With a 35mm lens at f/1.4 and a subject 0.7 m away, the zone is only about 1.6 cm deep on each side, and a small miss leaves the eye soft and the ear sharp.

Want to see how thin the zone gets with your own lens and distance? The depth of field calculator lets you tap a figure to focus on it and watch the near and far limits move as you change the aperture.

Phase detection: measuring which way and how far

If you have ever used an old manual focus film camera, you may have seen a split circle in the middle of the viewfinder. When the lens is out of focus, a vertical line through that circle breaks into two offset halves. Turn the focus ring and the halves slide back into one line. Phase detection does the same thing electronically.

Light reaches the sensor from every part of the lens opening. Phase detection autofocus (often shortened to PDAF) compares two images: one formed by light passing through the left side of the lens, the other by light passing through the right side. When the lens is focused on the subject, both images land in the same place. When it is focused too close, they shift apart one way. When it is focused too far, they shift apart the other way. The direction of the shift tells the camera which way to drive the lens, and the size of the shift tells it roughly how far. That is why phase detection can move the lens straight to focus in one confident motion instead of searching for it.

Two places the phase sensor can live

In a DSLR, a partly transparent main mirror lets some light through to a small secondary mirror, which sends it down to a separate AF module in the base of the camera. That module has its own tiny lenses and strips of sensors for each AF point. It works well and tracks fast, but it is a separate part from the image sensor, so the two must be aligned precisely. A small mismatch means the camera can focus consistently a little in front of or behind where you aimed. The module also has to fit below the mirror, so its points usually cluster around the middle of the frame, which is one reason DSLR users got into the habit of focusing in the center and recomposing. The comparison of DSLR, mirrorless and point-and-shoot cameras shows where that mirror sits in the body.

In mirrorless cameras and most phones, the phase detection is built into the image sensor itself. Some pixels are partly masked, or each pixel is split into a left half and a right half under one microlens, so the sensor can compare the two views directly. Because focus is measured on the same surface that records the picture, the alignment problem of the separate module largely goes away, and AF points can cover nearly the whole frame. The page on how image sensors work explains the pixels and microlenses this is built from.

Why direction of detail matters

A phase sensor compares two images along one direction. A row of sensors that compares left and right views can only measure a shift in detail that changes from left to right, such as a vertical edge. Show it a perfectly horizontal line, like a horizon, a window blind or the edge of a table, and the two views look identical however far out of focus the lens is. There is nothing to measure.

That is the reason for cross-type AF points, which compare in two directions at once and can read lines of any orientation. If your camera hunts on a horizontal subject, tilt the camera slightly while it focuses, or move the point to a spot with a vertical edge at the same distance.

Contrast detection: climbing to a peak

Contrast detection uses no special pixels at all. It reads the ordinary image and asks one question: how crisp are the edges? A sharp image has abrupt changes from dark to light. A blurred one has gentle, smeared changes. The camera moves the lens a step, measures the contrast in the AF area, moves again and measures again.

Think of walking up a hill in fog: you only know you reached the top when the next step goes down. To find the sharpest position it has to go a little past it, notice that contrast fell, and come back. On screen you see the image sharpen, soften slightly, then settle. That back and forth is the “hunting” people complain about, and it is why pure contrast detection is slow for moving subjects and shows a visible wobble in video.

Its strength is that it judges focus on the finished image, at exactly the spot you picked, with no separate module to drift out of alignment. For a still subject on a tripod, it is very precise. A focused page on contrast detection autofocus goes further into how it scores sharpness.

Hybrid autofocus and subject detection

Most current cameras combine the two. On-sensor phase detection does the heavy lifting: it says which way to go and how far, so the lens moves quickly and without hunting. Some systems then confirm or refine the final position with contrast, others finish on phase data alone. Either way you get speed and accuracy from one sensor.

Subject detection sits on top of that. The camera’s processor recognizes what is in the frame (faces, eyes, bodies, animals, birds, vehicles) and moves the AF area to follow it. Eye detection is the best known example and the reason portraits with fast lenses now come out sharp far more often. It changes where the camera measures, not how. Once it has picked a spot, phase or contrast measurement still sets the distance.

Detection can still miss. It may choose the nearer eye when you wanted the farther one, latch onto a reflection, lose a bird against busy branches, or put the box on the eyelashes and the lid while the iris sits just behind the focus plane. A box on the eye means the camera is trying for the eye. It is not proof the eye is sharp. Zoom in on the picture to know.

Shooting people with a fast lens? Eye detection AF covers how to choose which eye, when it helps most, and how it behaves with glasses and profiles.

Three separate choices: when, where and what

Camera menus mix several settings together under “focus”. They are easier to set once you see them as three independent questions.

  • When does the camera refocus? Setting: Focus mode. Usual choices: Single (AF-S, One Shot), continuous (AF-C, Servo), automatic switching (AF-A, AI Focus), manual.
  • Where in the frame does it look? Setting: AF area mode. Usual choices: Single point, small group or zone, wide or full frame area, tracking.
  • What is it looking for? Setting: Subject detection. Usual choices: Off, people, animals, birds, vehicles, or automatic.

Focus mode: when it refocuses

Single AF focuses once when you half press the shutter button and then holds that distance until you let go. Use it when the subject is not moving toward or away from you: landscapes, buildings, products, a posed portrait. The page on single-shot AF covers it in detail.

Continuous AF keeps measuring and adjusting for as long as you hold the button. It also predicts. Between the last measurement and the moment the shutter opens there is a short delay, and a subject running toward you keeps coming during it. The camera estimates the subject’s speed from its recent measurements and drives the lens to where the subject will be, not where it was. That prediction is why continuous AF can keep a charging dog sharp frame after frame. Continuous autofocus has the full story, including how the camera reacts when something crosses in front.

A pale yellow dog bounding through breaking surf with a tennis ball in its mouth
Photo: dog running out of the ocean with ball in mouth by Duncan Rawlinson. 400mm, f/10, 1/800, ISO 400. Shot at 400mm, f/10, 1/800 and ISO 400: a dog charging through the waves changes distance from a long lens with every stride, the case continuous AF and its prediction are built for.

Automatic switching starts in single mode and changes to continuous if it sees movement. It sounds convenient but sometimes guesses wrong, so most people who shoot moving subjects choose the mode themselves.

Focus priority and release priority

One more setting decides what happens when you press the shutter fully before focus is confirmed. With focus priority, the camera refuses to take the picture until it has locked. With release priority, it fires immediately, sharp or not. Many cameras default to focus priority in single AF and to release priority, or a balance between the two, in continuous AF, and both are usually changeable in the custom settings menu. If your camera ever “won’t take the picture”, focus priority is the usual reason.

The feedback signals follow the same logic. In single AF, a green box, a steady dot in the viewfinder or a beep means focus locked at that distance. A red or blinking indicator means it could not. In continuous AF, many cameras give no beep at all because focus never finishes; the moving boxes are the only sign it is working.

AF area: where it looks

A single point measures only what sits under it. It is the most predictable choice, and the right one whenever there is clutter between you and the subject. A zone or group gives a larger target and usually favors the nearest thing inside it, which suits a runner or a bird in open sky. Wide area lets the camera pick. With subject detection on, that often works well. Without it, the camera usually picks whatever is nearest or has the most contrast, which may not be what you care about. For a field guide to placing points, see how to choose focus points.

A dark patterned snake's head sharp in the middle distance, framed by large blurred leaves in the foreground
Photo: Snake in the Bush by Duncan Rawlinson. 200mm, f/5, 1/250, ISO 500. Shot at 200mm, f/5 and 1/250: the snake is sharp while the nearer leaves are soft, the kind of frame where a wide area mode tends to grab the leaves and a single point placed on the head does not.

Tracking settings and the focus limiter

Many cameras let you set how quickly continuous AF gives up on a subject when something passes in front of it, often called tracking sensitivity or lock-on. A slow setting holds focus on the athlete while the referee crosses the frame. A fast setting jumps to a new subject quickly, useful when you want to switch between players. Long lenses often have a focus limiter switch that stops the lens from searching its whole range. If your subject will always be beyond 10 m, limiting the range cuts the time lost when focus is briefly lost and the lens starts to hunt.

Where autofocus struggles, and why

Every failure on this list comes from the same root. Autofocus needs a clear signal from detail at one distance, under the active point. Take away the light, the detail or the single distance, and it guesses.

  • Low light. Fewer photons means a noisier signal for both methods. Cameras publish a low light rating in EV, such as “down to -3 EV”. At ISO 100, EV 0 is a scene that needs 1 second at f/1, and each step lower is half as much light, so -3 EV is eight times darker than that, around a landscape under a full moon. The rating is measured with a particular fast lens, often f/1.2 to f/2, so a slower lens gets less light to work with and gives up sooner.
  • Low contrast. A clear sky, a white wall, fog, a smooth painted door. Both methods need edges, and there are none. Aim at an edge at the same distance, such as a door frame or a window latch. Fixing common autofocus problems goes through each symptom in turn.
  • Lines in the wrong direction. As above, a point that compares in one direction cannot read lines running parallel to it. Tilt the camera or use a cross-type point.
  • Several distances under one point. Branches in front of a bird, a fence in front of a zoo animal, a crowd behind a face. The point sees detail at two distances and may pick the nearer, stronger one. Use the smallest point you have, or switch to manual focus.
  • Small apertures. Phase detection needs light from opposite edges of the lens opening. With a slow lens plus a teleconverter, the maximum aperture can fall to f/8 or f/11. Many cameras lose some or all of their AF points at that point, and the rest work more slowly.
  • Bright light behind the subject. Strong backlight and flare wash out contrast at the edges the camera is trying to read.
A ruby-throated hummingbird perched on a bare twig, small in a frame of out-of-focus leaves
Photo: Ruby-throated hummingbird by Duncan Rawlinson. 400mm, f/5.6, 1/180, ISO 3200. Shot at 400mm, f/5.6, 1/180 and ISO 3200: the light here works out to about EV 7.5 at ISO 100, far above any AF limit, so the challenge was a tiny subject surrounded by leaves at other distances, not darkness.

The hummingbird above shows that clutter is often the bigger problem than light. Shade dark enough to need ISO 3200 at 1/180 and f/5.6 still works out to about EV 7.5 at ISO 100, more than a thousand times brighter than a -3 EV rating. What makes a frame like this hard is a subject smaller than most AF zones, with leaves near and far around it.

When the point keeps choosing the wrong distance, focusing by hand is the fallback. Try it in the camera simulator: switch to Manual focus, turn on Peaking and put focus exactly on the subject at f/2 or wider.

Want the other challenges? The full camera simulator has all 21, across eight scenes.

Focus and recompose: what the numbers say

Focus and recompose means aiming the center point at the subject, locking focus, then turning the camera to frame the shot. It is often called a mistake. The geometry says it depends.

When you turn the camera by an angle, the focus plane turns with it. The subject was at distance d along the old line of sight. Along the new one it sits at d times the cosine of the angle, so the focus plane now lies behind the subject by d × (1 − cos θ). Whether that matters depends on how much depth of field you have in front of the plane. The table uses a full frame sensor, a 0.03 mm circle of confusion and a subject placed off center on the long side of the frame.

Lens and apertureDistanceSubject placedTurnFocus lands behind bySharp zone in frontResult
50mm at f/23 mon a thirds line (6 mm off center)6.8°2.1 cm19.8 cmNo visible change
85mm at f/1.41.5 mon a thirds line (6 mm off center)4.0°0.4 cm1.2 cmStill sharp, a third of the margin used
35mm at f/1.40.7 mnear the edge (15 mm off center)23.2°5.7 cm1.6 cmMissed: the eye is soft

The pattern: the error grows with a wider lens (bigger angle for the same placement), a closer subject and a placement nearer the edge, while a wider aperture shrinks the margin that would hide it. With a short telephoto, moderate distances and a subject on a thirds line, recomposing is fine. With a wide or normal lens, wide open, close up, and the subject near the edge, move the AF point onto the subject instead of turning the camera. Your own movement adds to this, since leaning back 2.5 cm after locking focus at 0.7 m already uses up more than the 1.6 cm sharp zone in front of the plane.

Was it focus? Reading a blurry photo

Not every soft picture is an autofocus failure. Before changing focus settings, zoom in to 100 percent and ask one question: what is the sharpest thing in the frame?

  • Something else is crisp: the background, the fence, the tip of the nose: Likely cause: Focus landed at the wrong distance. What fixes it: A smaller AF point placed on the subject, subject detection, or continuous AF if it was moving.
  • Nothing is crisp, and every edge is doubled or smeared in the same direction: Likely cause: Camera shake. What fixes it: A faster shutter speed, stabilization, a steadier grip or a tripod.
  • The background is crisp but the moving subject is streaked along its path: Likely cause: Motion blur from the subject. What fixes it: A faster shutter speed; focus was fine.
  • A thin slice of the subject is crisp (eyelashes, the near ear) but the rest drifts off: Likely cause: Depth of field too thin for the subject. What fixes it: Stop down a little or step back; focus was close.
  • Everything is evenly soft with no sharp slice anywhere: Likely cause: Missed focus with no detail in the plane, a dirty lens, or haze. What fixes it: Clean the front element, check focus on a high contrast edge, then retest.

This one test settles most arguments about whether a lens or camera “can’t focus”. If some part of the frame is sharp, the system focused, just not where you wanted. Look at the snake photo above: the leaves in front are soft and the snake’s head is sharp. That is focus at the right distance with shallow depth of field, not a fault.

Is your photo soft even when focus looks right? How to take sharp photos works through shutter speed, stabilization and technique together.

Back button focus

By default the shutter button does two jobs: half press to focus, full press to take the picture. Back button focus moves autofocus to a separate button on the back of the camera and removes it from the shutter. With continuous AF set, hold the back button and the camera focuses and tracks. Let go and focus stays where it was. You get both behaviors from one setting, with no menu change between a perched bird and one taking off.

Ready to try it? Back button focus shows how to set it up and the habits that make it work.

Front focus, back focus and calibration

If a camera consistently focuses a little in front of or behind where you aimed, with the same lens, at the same distance, every time, that is front focus or back focus. On DSLRs with a separate AF module it is a known issue, because the module and the image sensor are separate parts. Many DSLRs offer per lens fine tuning: you shoot a target at an angle, see where the sharpest point lands, and enter a correction.

On-sensor phase detection makes this far less likely, because focus is measured where the picture is made. It does not remove every cause. Some lenses shift focus slightly as they stop down, and lens samples vary. If you suspect a problem, test on a tripod with a flat, detailed target before blaming the camera. The page on how to test a lens describes a clean method.

Common mistakes and misconceptions about autofocus

  • “The camera focuses on the subject.” It focuses on a distance under the active point or box. Put the point on the subject, or let detection do it, and check.
  • “Every blurry photo is a focus problem.” Shake and motion blur look different. Find the sharpest thing in the frame first.
  • “A green box on the eye means the eye is sharp.” It means the camera aimed there. At f/1.4 the lashes can be sharp and the iris soft.
  • “Single AF is the safe choice.” For anything moving toward or away from you, single AF locks a distance the subject has already left. Continuous AF is the safe choice for movement.
  • “Wide area AF is easier.” Without subject detection it hands the decision to the camera, which usually picks the nearest or highest contrast thing.
  • “Focus and recompose always ruins focus” or “never matters”. The table above shows both are wrong. It depends on lens, distance, placement and aperture.
  • “Mirrorless cameras never need focus correction.” They avoid the module alignment problem, not every lens behavior. Test before assuming.
  • Fighting AF where manual focus is better. Stars, close-up insects, shooting through glass and scenes with no contrast often go faster when you focus by hand with peaking and magnification.

Try this: a ten minute autofocus test

You need your camera or phone, a window or doorway, and something you can put in front of a subject, like a houseplant.

  1. Put the plant about a meter in front of you and a picture, poster or book cover a few meters behind it. Set the widest aperture you have.
  2. Set wide area AF with subject detection off. Half press and take a frame. Note what the camera chose.
  3. Switch to a single small point. Place it on the poster, through a gap in the leaves, and take a frame.
  4. Now aim the single point at a horizontal edge with no vertical detail, such as the top of a door or the edge of a shelf, and see whether it locks. Tilt the camera about 30 degrees and try again.
  5. Last, with continuous AF on, have someone walk slowly toward you from across the room while you shoot a short burst. Repeat with single AF.

How to judge it. Open every frame at 100 percent and find the sharpest thing in each. In step 2 the leaves are usually sharp; in step 3 the poster should be. If step 4 locked only after tilting, you found the line direction limit of that point. In step 5, continuous AF should keep the walker’s face sharp through the burst, while single AF leaves later frames focused behind them. If any frame has nothing sharp at all, it was shake, not focus.

Want to stop relying on autofocus for some shots? Zone focusing shows how to preset a distance and shoot without waiting for the lens.

Want to check you can tell phase detection from contrast detection, and pick the right mode for a moving subject? Try the autofocus systems quiz.

Autofocus questions

Why does my autofocus hunt back and forth?

It cannot find enough detail at one distance under the active point, usually because of low light, a smooth surface, or a line running the wrong way for that point. Move the point to a clear edge at the same distance, add light, or switch to manual focus. A smeared front element can also cut contrast enough to cause hunting.

Is phase detection more accurate than contrast detection?

Phase detection is faster and better at tracking because it knows the direction and the amount to move. Contrast detection’s advantage was always that it measured on the image sensor itself. Once phase detection moved onto the image sensor too, that advantage mostly disappeared, so a modern hybrid system is both fast and precise.

Does the aperture I set change how autofocus works?

On a DSLR, the lens stays wide open while focusing and only stops down when the picture is taken, so your chosen aperture does not affect the AF reading. Some mirrorless cameras focus at or near the shooting aperture in certain modes, which can slow focus in dim light. The lens’s maximum aperture always matters, since it limits how much light reaches the AF system.

Should I leave eye detection on all the time?

For people and animals, mostly yes. Turn it off when you want focus somewhere other than a face, such as a hand, a product or a landscape with a person in it, because detection will keep pulling focus back to the face. In a crowd, it may also pick a face you did not mean.

How is autofocus different in video?

Video needs smooth focus changes, not fast ones, because a sudden jump looks jarring. Cameras slow and soften focus movement in video modes and usually let you set the transition speed and how readily focus moves to a new subject. Contrast-only systems tend to show a visible wobble as they check the peak, which is why on-sensor phase detection made video autofocus far smoother.

Why do some lenses focus faster than others?

The focus motor and the weight of the moving glass matter most. A lens that moves a small, light group with a modern motor focuses faster and quieter than one that moves a heavy group or relies on an older drive. A wider maximum aperture also gives the AF system more light, which helps most in dim scenes.