Skip to content

basista21/face-detection

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
April 30, 2021 15:59
April 30, 2021 22:54
November 18, 2020 07:02
November 18, 2020 07:23

Face Detection

Face detection using Haar Cascades (frontal face and profile face) and Deep Neural Network (DNN) module in OpenCV.

Haar Cascade Classifiers

Haar Cascade files can be downloaded from the OpenCV repository.

Deep Neural Network

The file for the pre-trained Caffe model can be found here.

Usage

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.

Examples

Running python face-detect-haar.py dominic.jpg:

Image of Dominic with Face Detection Using Haar Cascades

Running python face-detect-dnn.py dominic.jpg:

Image of Dominic with Face Detection Using DNN

The DNN detector successfully detected the third face, but with only 30.02% confidence.

Comparison

Haar cascades vs DNN:

image

A false positive and a false negative for the haar face detector. DNN successfully detected the face.



image

A true positive and a false positive for each.