A python demo code for face detection and recognition in images using OpenCV3
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
face-recog.py
haarcascade_frontalface_default.xml
test.txt
train.txt

README.md

Face detection and recognition using OpenCV

A python demo code for face detection and recognition in images using OpenCV3 by Shizuo KAJI

Licence

MIT Licence

Requirements

  • python 3.6

Install Anaconda if you do not have python 3 on your system.

  • OpenCV 3.3 -- macOS: use homebrew (e.g., brew install opencv) -- Windows: download the binary package (e.g. opencv_python‑3.3.0‑cp36‑cp36m‑win_amd64.whl) from here and install with pip install opencv_python‑3.3.0‑cp36‑cp36m‑win_amd64.whl

Example

Let's try with the famous AT&T dataset. Download the dataset from http://www.cl.cam.ac.uk/research/dtg/attarchive/facedatabase.html and extract.

python face-recog.py -h gives a brief description of command line arguments

python face-recog.py train.txt test.txt -a fisher -R att_faces reads training images from train.txt and outputs prediction for images in test.txt using the Fisherface algorithm. Each line of train.txt consists of two entries separated by a tab; the relative path to an image file from the directory specified by -R (att_faces in this example), and the label indicating who is in the picture.

python face-recog.py train.txt test.txt -a eigen -R att_faces —cropped cropped outputs prediction using Eigenface and saves cropped and resized face images to the directory specified by --cropped (in this example, cropped). The output directory must exist in advance.

python face-recog.py train.txt test.txt -a eigen -R att_faces --gui -n 4 shows a window with 4 sliders with which you can tweak the weights of PCA vectors to generate faces.