Face detection using Haar Cascades (frontal face and profile face) and Deep Neural Network (DNN) module in OpenCV.
Haar Cascade files can be downloaded from the OpenCV repository.
The file for the pre-trained Caffe model can be found here.
Usage (using haar cascades): python face-detect-haar.py [optional.jpg]
Usage (using dnn) : python face-detect-dnn.py [optional.jpg]
If only one command line argument is supplied (the program itself e.g. face-detect-haar.py), video stream from the webcam will be used as input. If there are exactly two command line arguments and an image is provided as the second command line argument, the image will be used as input.
Running python face-detect-haar.py dominic.jpg:
Running python face-detect-dnn.py dominic.jpg:
The DNN detector successfully detected the third face, but with only 30.02% confidence.
Haar cascades vs DNN:
A false positive and a false negative for the haar face detector. DNN successfully detected the face.
A true positive and a false positive for each.