Face Detection

Learn how to detect faces using OpenCV in Python.

Face detection with OpenCV

OpenCV uses machine learning algorithms to search for faces within a picture. For something as complicated as a face, there isn’t one simple test that will tell us if it found a face or not. Instead, there are thousands of small patterns and features that must be matched. The algorithms break the task of identifying the face into thousands of smaller, bite-sized tasks that are easy to solve. These tasks are also called classifiers.

For something like a face, we might have 6,000 or more classifiers, all of which must match for a face to be detected. But therein lies the problem, for face detection, the algorithm starts at the top left of a picture and moves down across small blocks of data. It looks at each block, constantly asking, “is this a face?” Since there are 6,000 or more tests per block, at any time there might be millions of calculations running. This would grind any computer to a halt.

Get hands-on with 1200+ tech skills courses.