There are two autofocus (AF) technologies currently used by camera manufacturers. Though it is not important to know exactly how they work, it is useful to know what their strengths and weaknesses are. The two technologies are known as phase detection and contrast detection. Phase detection is primarily use on DSLRs, but only when you look through the viewfinder. Contrast detection is used on mirrorless cameras and by DSLRs in Live View. (Just to confuse things slightly, some DSLR and mirrorless cameras have a form of phase detection built into their image sensors, but the split above is still broadly accurate.)
The sole job of a camera’s AF system is to calculate how the optics inside a lens should be arranged to ensure a sharp focus. The optics inside the lens are moved by motors either inside the lens or on some older lenses, notably Nikon F lenses, by motors inside the camera.
Phase detection
It may not look it but the reflex mirror inside a DSLR is partially translucent. This allows a small amount of light from the lens to be directed down to a phase detection AF module buried deep inside the camera.
Phase detection is very fast system. Modern phase detection AF essentially focuses instantaneously. And it can do this even in low light levels or when using lenses with relatively small maximum apertures. (The maximum aperture of a lens will have an effect on focusing speed and accuracy. A small maximum aperture will let less light through the lens. Ultimately all AF systems need light in order to calculate focus distance.)
There are not many downsides to phase detection AF but there are a few. One is that every component in the system – including the lens, reflex mirror and AF module – must be precisely aligned. Any misalignment, due to a slight manufacturing fault or subsequent damage to the camera, will create a focusing error. These errors result in either back focusing where the camera focuses behind where you intended (so that your subject is not sharp, but something in the background is), or front focusing where focusing is closer to the camera than intended. For most photography this may not be noticeable, but can be very evident when critical focusing is required (when focusing on a person’s eyes for example). Focusing errors like these can be corrected by using a camera’s lens calibration option. (Unfortunately, not every camera offers this option.)

Another drawback is that phase detection can be fooled by low contrast subjects. This results in ‘hunting’ where the AF system never settles. This can mean missed shots or, if the shutter does fire, shots that are out-of-focus. One cure is to focus on something else in the scene – that is at the same distance as your subject – and, with focus locked by a half-press on the shutter button, recompose to take the shot (referred to as focus-and-recompose elsewhere in this lesson). Another cure is to switch to manual focus (see below).
Contrast detection
Contrast detection is a less complex system than phase detection. There is no separate AF module. Instead it is the image sensor, often in conjunction with a camera’s image processor, that determines focus.

Contrast detection works by analysing image data from the sensor – looking for contrast between edges, moving the lens optics until the highest amount of contrast, and therefore sharpness, is achieved. One big advantage to this system is that it is very accurate and never needs adjusting. (It does not rely on the precise alignment of components the way the phase detection does.) The drawback is that this incremental adjusting of the optics until focus is achieved takes time, making contrast detection far slower than phase detection. Early mirrorless cameras where often painfully slow to focus, making them ill-suited to shooting subjects that moved. Fortunately, technology moves on and there is now less difference between the two systems than there once was.