On this page
When you tap your phone screen to take a picture, the camera instantly snaps the subject into sharp relief. Behind the glass, a microscopic voice-coil motor is physically moving a lens back and forth over a few millimetres.
To understand when to stop moving that lens, the camera's processor relies on the physics of light and a couple of algorithms called contrast detection and phase detection.
How does contrast detection autofocus work?
Contrast detection relies on a simple rule: an image is sharpest when the difference in brightness between adjacent pixels is at its maximum.
If a face is out of focus, its edges blur into the background, and the transition from light to dark is gradual. When the lens is perfectly positioned, the edge becomes a sharp jump from light to dark. Because it is a closed-loop system, contrast detection checks the results of its own actions continuously. It reads a frame, moves the lens a fraction of a millimetre, reads another frame, and subtracts the pixel values to see if the contrast went up or down. If the contrast drops, it knows it went the wrong way. Contrast detection does not provide any directional information, so the camera must "hunt" back and forth, passing the point of maximum sharpness and then reversing to lock onto it.
This method is highly accurate because it reads the final image directly from the sensor. However, the hunting process makes it slow, and it struggles in low light where contrast is naturally low. You might have noticed your phone's camera breathing—pulsing in and out of focus—when trying to shoot in the dark. That is the contrast detection algorithm hunting for an edge that isn't there.
What is phase detection autofocus?
To speed things up, modern phones use Phase Detection Autofocus (PDAF), a technology originally built for professional DSLR cameras.
Phase detection works like human binocular vision. The camera sensor has pairs of specialized light-sensing pixels placed side by side. Light from the right side of the lens falls on the left pixel, and light from the left side falls on the right pixel.
The camera compares these two slightly different views. If the subject is out of focus, the two light patterns will be out of phase. By measuring the gap between the two patterns, the camera can instantly calculate exactly how far and in which direction the lens needs to move. Professional phase detection systems often aim for an accuracy within 1/3 of the depth of field, and some use cross-type sensors oriented at 90° to one another for even greater precision.
Because the phone knows exactly where to move the lens, phase detection is nearly instantaneous. Many modern phones use a hybrid system: phase detection jumps the lens to the approximate distance, and contrast detection makes the final microscopic adjustment.
How does this connect to Class 10 and 12 physics?
The mechanism inside your phone is a direct application of the optics you study in school.
When you solve a problem about why a lens's object and real image are at least 4f apart, or when you practice tracing a ray through a glass slab, you are calculating the exact paths that phone engineers have to manage. In a phone camera, the object distance (u) is the distance to your subject, and the image distance (v) is the gap between the lens and the silicon sensor.
In a traditional camera, you might zoom by changing the focal length (f), but a phone's main lens has a fixed focal length. The only variable the phone can change is the image distance (v). As the object distance (u) goes from infinity (a distant mountain) down to just a few centimetres (a macro shot of a flower), the lens must physically move further away from the sensor to keep the image sharp. Because u changes every time you point the camera at something new, the motor must constantly adjust v to satisfy the lens formula 1/f = 1/v - 1/u.
Why learn physics through interactive models?
Reading about optics is one thing; seeing the rays move when you drag a lens is another. Traditional textbook diagrams are static, which makes it hard to picture how changing one variable—like the focal length or the object distance—affects the rest of the system.
Active learning requires you to engage with the material rather than passively taking it in. A 2011 study on university physics teaching found that students in active-learning classes scored 74% on tests, compared to 41% for students in traditional lectures.
This is where the Fermi Simulation Lab helps. It provides interactive simulations for the ideas that are easier to see than to read, allowing you to manipulate lenses, mirrors, and rays to see the physics happen in real time. If you need a refresher on the math behind the optics, the Concept Library contains every concept in physics, chemistry, biology, mathematics and computing, each with its own lesson and its place in the map.
By connecting the devices in your pocket to the equations in your textbook, physics stops being a list of formulas and becomes the language that explains the world around you.



