Below are the requirements for it:
- Python 2.7
- Haar Cascade Frontal Face Classifiers
Approach / algorithms used:
- This project uses the LBPH (Local Binary Pattern Histograms) algorithm for face detection. It labels the pixels of the image by setting a threshold around each pixel and treats the result as a binary number.
- LBPH uses 4 parameters:
(i) Radius: the radius is used to construct a circular local binary structure and represents the radius around
(ii) Neighbors: the number of sample points to construct a circular local binary pattern.
(iii) Grid X: number of cells in the horizontal direction.
(iv) Grid Y: number of cells in the vertical direction.
- The generated model is trained using the labeled faces and then the test data is given to the machine and the machine selects the correct label for it.
How to use:
- Create a directory on your computer and name it (say project)
- Create two Python files named create_data.py and face_recognize.py, copy the first source and second source respectively into it.
- Copy haarcascade_frontalface_default.xml to your project directory, you can get it in opencv or from
- You are now ready to run the following codes.
The following code should be run after training the model for faces:
Note. The above programs will not work in the online IDE.
Screenshots of the Programs
This may look different oh, because I have integrated the above program into the framework.
Running the second program gives results similar to the image below: