Creative Technology Explained

How Does Autofocus Actually Work?

Andre Infante 07-07-2015

Autofocus is a feature of modern cameras that’s easy to take for granted. But have you ever stopped to ask yourself how it works? Focusing a manual lens can be a painstaking and frustrating process, especially for amateurs — so how does your smartphone do it so easily?


It turns out that that there are actually several technologies that are used to achieve an autofocus effect. Let’s start by explaining what focus is, and then how the computer in your phone can manipulate it to get a sharp image.

How Focus Works

The lens in your smartphone camera 6 Reasons Your Smartphone Is the Best Camera You Own It might not be a digital SLR, but your smartphone is punching well above its weight when it comes to photography. The next time you go out, leave your old point and shoot at home. Read More serves the same purpose as the lens in your eye: to take the light that hits it and project it onto a sensor so that an image can be recorded.

The exact curvature of the lens dictates how far away the sensor has to be to produce a clear image. If you’ve ever used a magnifying glass to burn wood on a sunny day, you know that it must be held at exactly the right distance to focus the light.

The same happens with cameras: if the distance is wrong, the image is out of focus and therefore blurry. This distance is known as the lens’s “depth of focus”.

To complicate matters, the angle at which light hits a lens changes its depth of focus. A flatter lens focuses parallel light rays from a far-off source but blurs the angled light coming from peripheral objects. A more curved lens would do the opposite.


The video below goes into a detailed explanation of how lenses work, if you’re interested:

You can see this effect yourself by holding up two thumbs, one near your face and the other at arm’s length. If you shut one eye, you’ll find that you can shift your focus between the thumbs. When the far one is clear, the near one becomes blurry, and vice-versa.

In the case of your eye, the change in focus is done by using tiny muscles to physically alter the shape of the lens. Over-working these muscles tires them, which is why you get eyestrain from looking at close-up objects for too long.

In cameras, which use rigid plastic or glass lenses, the whole lens is mounted on a motor, which can change its distance from the sensor to achieve the desired focus. Objects that are at the correct focal distance will be sharp while objects that are too near or too far will be blurry.


The question is, how does the camera know the right distance for its lens?

Methods of Active Autofocus


The simplest method of autofocus is to use a mechanical system that finds the distance to the subject of the image, then uses that to dictate the focus.

The earliest patent, filed by Polaroid in 1986, used sonar. It pulsed the target with ultrasound and used the echo to determine distance. This works, but can fall afoul when shooting through clear-but-solid surfaceslike glass. If you try to take a picture out a window, the autofocus feature will detect the echo from the glass and focus on that, leaving the image beyond it a blur.


More modern systems use light, specifically infrared light. They produce a pulse of IR light and either measure the amount that is reflected back or the time it takes for the light to return, then use this information to determine distance. If you look at your phone’s camera and see two small diodes next to it, this is probably how your phone computes focus.

This approach is simple and tends to work reasonably well, but it has drawbacks. Some surfaces absorb infrared light, which can lead to an inaccurate distance reading. Beyond that, any IR source (such as an open flame or a bright incandescent light) can overwhelm the returning light and render the autofocus inoperable. Try to avoid these scenarios if you want to get good photos with an active autofocus camera.

So, what’s the alternative?

Methods of Passive Autofocus

Passive autofocus can be a good deal more expensive to implement, so you tend to see it primarily on SLR cameras (both digital and analog). Passive autofocus works by performing a mathematical analysis on the raw image data itself to determine whether or not it is in focus.



The most common form of passive autofocus is “contrast detection”, which samples one or more strips of pixels from the center of the image and measures the pixel-to-pixel contrast, adjusting the lens to try to find the configuration that maximizes this contrast.

This works because blurry image regions inherently have less contrast, and since this method isn’t confused by IR light sources or material surfaces, it’s a more robust than active autofocus. In one sense, this is the most accurate way to judge focus because it is directly measuring the sharpness of the image.

In fact, it is so effective that it can even focus through a lens that changes the focal properties of the camera — a scenario in which every other approach fails. On the downside, contrast detection can take a while to find a good focus (because it has to test many possibilities) and it can have trouble in scenes that lack high-contrast (like in low light photography An Illuminating Guide to Low Light Photography If photography is about capturing light, how do you take photos when light is scarce? Read More ).


A different approach to passive autofocus is called “phase detection”, which uses two microlenses to capture samples of incoming light and project them onto two sensors. By analyzing the difference between these images, the camera can very accurately determine how parallel the light rays entering the camera are and use this information to achieve the correct focus.

This is a very fast way to determine optical focus but is expensive due to the need for additional lenses, mirrors, and sensors, so you’ll see it more in high-end rather than entry-level DSLR cameras The Best Entry-Level DSLRs For New Photographers If you want to take your photography skills to the next level, or you know someone else who does, then there's no better way than to enter the world of DSLR cameras. Read More . Not only that, but it can be less accurate than contrast detection, especially for complicated subjects that have components at several depths.

More recently, we’ve begun to see “hybrid” passive autofocus systems crop up, which use phase detection to jump to a good focus, then use contrast detection to make small refinements for best possible focus. In a lot of ways these cameras offer the best of both worlds (speed and accuracy) but they are currently very expensive. Hopefully, costs will come down over the next several years.

Autofocus and You

These are the four main approaches to autofocus in common use today. In the future we may see “light field cameras Lytro Light Field Camera: Snap Happy Or Photo Gimmick? Described by an employee as "the first major change in photography since photography was invented", the Lytro light-field camera is certainly a revolutionary device. The camera shakes things up by replacing much of the heavy... Read More ” become more popular, which capture images at every possible focus and choose the best one. Until then, we have to work around the limitations of the available technology.

So how do you get good pictures 5 Ways to Avoid Blur with a Smartphone Camera I think it's safe to assume most people take their smartphone cameras for granted, despite the leaps and bounds made in pocketable picture-taking technology. Unfortunately a lot of the time our smartphones produce overly blurry... Read More out of an autofocus camera?

  • The most important thing is to hold the camera steady and make sure the focus has totally converged. That goes double if you’re using a contrast or range-based autofocus system that may need a few seconds to find the right focus.
  • You also need to make sure that your subject is at the proper autofocus point, usually the center of the viewfinder but not always. This is something that pretty much all autofocus systems depend on.
  • Finally you need to be aware of the technology you’re using and make sure your scene is a good match for it. Don’t try to directly focus on a bright IR light source using an active system. If you’re using a contrast-based system, avoid taking photos that are a single color (like a blank wall) and avoid taking photos at night.

Aside from that, you pretty much don’t have to think about it. In a way, that’s sort of the point.

Are you a photographer? Have any tips to share for dealing with autofocus? What’s your favorite camera? Let me know in the comments!

Image credits: “Samsung Galaxy S5“, “SLR“, “DSLR“, by Wikimedia

Related topics: Camera Lens, DSLR, Photography, Smartphone Photography.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Ivan Ivanov
    August 25, 2017 at 1:39 pm

    You can install chrome extension "7 Times Faster". It speed up your internet in 2 times.

  2. YS
    August 26, 2016 at 7:40 pm

    Most smartphones consist of a stack of 5-7 lenses in a 'lens stack'. In order to autofocus, is the entire stack moved, or only some lenses within the stack?

    • Roger
      January 21, 2019 at 12:01 am

      Good question. Why is all this stuff kept so secret? I think some iPhones use MEMS devices (3 @ 120 degrees around one lens) to move one lens toward and away from the sensor to change the effective focal length and f-stop. But as far as I know the effective focal length and f-stop are not stored in the image Metadata. Why not I don't know. Maybe because there is no sensor to determine the physical lens displacement?

  3. Anonymous
    July 10, 2015 at 5:35 am

    Great, easy to read, clear article.