An experiment with OpenCV 3.x face detection and recognition. Note that you
will need to install the corresponding
opencv_contrib modules for the face
recognizer to work.
Make sure you have
opencv_contrib installed already. Then clone
and setup the environment for
git clone https://github.com/kitsook/face cd face virtualenv venv . venv/bin/activate pip install -r requirements.txt
detect.py contains sample on running face detection on webcam attached to the
level_face function tries to rotate the image so that the
face detected is level (based on the eye positions).
Face recognizer training
train.py trains the OpenCV face recognizer by extracting faces from images
provided under a given folder. Images for each individual should be
organized in corresponding sub-folders with the folder name used by face
recognizer as the labels. e.g.:
Note that each image can contain multiple faces of the same person.
recognize.py puts everything together. It demonstrates on training the face
recognizer and feeding webcam images to recognize faces found.
Note that in order to speed up the process, the training result should run once and saved. Subsequent running of the program can load the result instead of training the recognizer again.