When you half-press the shutter button, the lens moves and, a moment later, your subject snaps into focus. Behind that simple action is a clever system that measures the scene and decides how far to move the lens. Modern cameras can even recognise faces, eyes, animals and cars on their own. Knowing how autofocus works helps you understand why it sometimes struggles, and how to help it succeed.
What is autofocus?
Autofocus, usually shortened to AF, is the camera system that measures the scene and moves the lens automatically until the chosen part of the picture is sharp. It saves time and is often faster and more accurate than focusing by hand, especially with moving subjects.
Autofocus has three parts that work together, and each has its own lesson in this course:
| Part | Question it answers | Lesson |
|---|---|---|
| How the camera measures focus | How does it know what is sharp? | This lesson |
| Where the camera focuses | Which part of the frame should be sharp? | selecting AF areas and focus points |
| When the camera focuses | Focus once, or keep focusing? | single-shot and continuous autofocus |
Two ways to measure focus
| Contrast detection | Phase detection | |
|---|---|---|
| How it works | Moves the lens back and forth to find where edges look most contrasty | Compares light from two sides of the lens to work out how far and in which direction to move |
| Speed | Slower; the lens may "hunt" back and forth | Fast; it knows the direction straight away |
| Strength | Very accurate on still subjects | Excellent for moving subjects |
| Where you find it | Older live view and compact cameras, often as part of hybrid systems | DSLR viewfinder AF and the sensors of most modern mirrorless cameras |
Contrast detection works like a person adjusting binoculars: turn a little, check if it got sharper, turn again. Phase detection is cleverer. By comparing two views of the subject, it can tell whether focus is in front of or behind the subject and by how much, so it moves the lens straight to the right place.
DSLR and mirrorless autofocus
In a DSLR, a separate autofocus sensor sits below the mirror, as you can imagine from how a digital camera works. It only works when you use the optical viewfinder. In live view, the mirror flips up and older DSLRs fall back to slower methods.
In mirrorless cameras, phase detection points are built into the image sensor itself. This lets the camera focus across almost the whole frame. Many cameras combine phase and contrast detection, which is called hybrid AF. Canon's version, called Dual Pixel CMOS AF, splits each pixel into two halves so most of the sensor can perform phase detection.
Subject detection
Many modern cameras can recognise what is in the frame and focus on it automatically. This is called subject detection. It uses software trained on huge numbers of images, a form of artificial intelligence, to find things like:
- People: faces, eyes, heads and bodies. Eye detection can keep the nearest eye sharp in a portrait.
- Animals: dogs, cats and other animals, often including their eyes.
- Birds: including birds in flight.
- Vehicles: cars, motorbikes, trains and aircraft on some cameras.
Remember:The exact list depends on your camera and its software version. Some cameras need you to choose the subject type in the menu; others detect it automatically. Check your camera's manual.
Subject detection is a huge help, but it is not mind-reading. In a group photo, it may choose a face you did not want. With busy backgrounds or unusual subjects, it may lock onto the wrong thing. You still need to know how to choose the focus area yourself, which is the next lesson.
When autofocus struggles
Autofocus needs light and detail to measure. It can struggle when:
| Situation | Why AF struggles | What helps |
|---|---|---|
| Very low light | Too little light to measure | Add light, use the AF-assist lamp, or focus manually |
| Plain surfaces (a white wall, clear sky) | No edges or contrast to measure | Focus on an edge at the same distance |
| Subject behind glass, fences or branches | AF may lock onto the nearer object | Use a small focus area, or manual focus |
| Very low contrast scenes (fog) | Edges are too soft | Find the strongest edge you can |
Many cameras have a small AF-assist lamp that shines on the subject in the dark to help focusing. It can be useful, but may be distracting at events. Manual focus, covered in manual focus and focus assistance, is the backup when autofocus cannot succeed.
Common mistakes
- Assuming the camera knows your subject: even with detection, check which face or eye it chose.
- Pointing at a plain area to focus: AF needs edges and contrast.
- Blaming the lens in the dark: low light makes every AF system slower.
- Forgetting the lens switch: many lenses have an AF/MF switch; if it is on MF, the camera will not autofocus.
How professionals use autofocus
Professionals trust modern autofocus, especially eye and subject detection, because it frees them to concentrate on timing and composition. But they always watch the focus box in the viewfinder to confirm it is on the right subject, and they know how to take control instantly when it is not. They also learn their own camera's habits in difficult light, so they are never surprised during an important moment.
Practical examples
A portrait with eye detection
- Situation
- You photograph a friend at f/1.8, and some photos have the ear sharp instead of the eye.
- What to do
- You turn on eye detection for people.
- Why it works
- At shallow depth of field, small focus errors matter; eye detection finds and follows the eye.
- Result
- The nearest eye is sharp in almost every frame.
A cat behind a window
- Situation
- You try to photograph a cat sitting behind a dirty window, and the camera focuses on the glass.
- What to do
- You move closer to the glass and use a small focus area on the cat's eye.
- Why it works
- The autofocus was choosing the nearest surface it could measure.
- Result
- The cat is sharp and the glass marks almost disappear.
Key points
- Autofocus measures the scene and moves the lens to make the chosen area sharp.
- Contrast detection hunts for maximum edge contrast; phase detection knows direction and distance.
- Mirrorless cameras build phase detection into the sensor; hybrid AF combines methods.
- Subject detection recognises faces, eyes, animals, birds and vehicles, but still needs checking.
- AF struggles in low light, on plain surfaces and through obstacles.
Frequently asked questions
How does camera autofocus work?
What is the difference between phase and contrast detection?
What is eye detection autofocus?
Why does my camera struggle to focus in the dark?
Conclusion
Autofocus measures sharpness with phase detection, contrast detection or both, and modern cameras can even recognise your subject. It is fast and accurate, but it still needs light, detail and your guidance. Next, you will learn how to tell the camera exactly where to focus with AF areas and focus points.
Finished reading? Track your progress through Focus and depth of field.