This post shows an experiment with frontal face and eye detection with OpenCV. I was really impressed on how well the out-of-the-box algorithms performed.
Why face detection?
Detecting faces is a crucial step in developing face recognition applications. Before you can process and analyze faces you have to find and extract them first. This is obvious, but the task of detecting faces is by no means a trivial task.
To detect faces I needed faces to detect. Clear. To be on the safe side with copyrights I chose CC0 licensed photos from Unsplash. To have a lot of faces in one image I took a screenshot of the result page for “portrait faces”. Figure 1 shows the many faces of Unsplash. In figure 2 you can see how the software found the faces. It detected each of the 7 faces. Excellent job!
Figure 1. Faces to Detect.
Eye detection was a bit harder though. The small face in the bottom-left corner does not have its eyes detected at all. The profile face in the bottom-right also has some difficulties with placing the partially hidden eye.
In the future I would like to add some padding to the rectangles. In this way the chins and foreheads would fit the rectangle better and machine learning algorithms would get more context for their tasks.
After the detection I saved the faces to separate files. These files can later be used for face recognition or other applications.