Here we will run a face detector comparison between OpenCV Haar Cascade, Xailient Dectum, Dlib, and MTCNN Face detectors on a low-powered, resource-constrained device.
The face detector is one of the most commonly used AI components today. Whether you are building a system to count the number of people in a room or a home security system that unlocks the door when you reach your front door, you need a face detector.
Given an image, a face detector locates the faces present in the image and gives the coordinates of each face present in the image.
There are tons of face detectors that are available, and honestly, it might be quite overwhelming for you to decide which one would be best for your project. There is no one right answer.
The choice of face detector depends on the requirements of your project such as the available resources and target inference speed.
In this post, I will do a comparison of the four cutting-edge face detectors that are available today: OpenCV Haar Cascade, Xailient, Dlib, and MTCNN. I will also give code for each of the face detectors so you can either repeat the comparison or use it as a kick-starter for your project.
Face Detector Comparison
For the comparison between OpenCV Haar Cascade, Xailient, Dlib, and MTCNN Face detectors, I used a Raspberry Pi 3B+, with Raspbian Buster as the operating system. Test videos used for these experiments were downloaded from Pexels.com.
Here’s a video of comparison results for the four face detectors.
Below are the scripts I used for running each of the face detectors.
OpenCV Haar Cascade
To set up, install the required Python libraries using pip command.
I used OpenCV version 4.1.0 for this experiment.
Here is the code for face detection using OpenCV Haar Cascade:
Dlib
To set up, install the required Python libraries using pip command.
I used OpenCV version 4.1.0 for this experiment.
Here is the code for face detection using Dlib:
Xailient
To set up, install the required Python libraries using pip command.
I used OpenCV version 4.1.0 for this experiment and installed the Xailient Face detector.
Here is the code for face detection using Xailient:
MTCNN
To set up, install the required Python libraries using pip command.
I used OpenCV version 4.1.0 for this experiment.
Here is the code for face detection using MTCNN:
Comparison Results
Here are the results from our face detector comparison, listing each in descending order of their performance (best is on the top of the list):
- Xailient Face Detector
- OpenCV Haar Cascade Face Detector
- Dlib Face Detector
- MTCNN Face Detector
Xailient Face Detector ran 16 times faster than OpenCV Haar Cascade Face Detector using only 1/4 of the resources with better qualitative accuracy.
Xailient Face Detector ran 80 times faster than Dlib Face Detector using the same amount of resources with similar qualitative accuracy.
Xailient Face Detector ran 80 times faster than MTCNN Face Detector using only 1/4 of the resources with similar qualitative accuracy.