Face Detection using Python and OpenCV with webcam
OpenCV is a Library which is used to carry out image processing using programming languages like python. This project utilizes OpenCV Library to make a Real-Time Face Detection using your webcam as a primary camera.
Following are the requirements for it:-
- Python 2.7
- Haar Cascade Frontal face classifiers
- This project uses LBPH (Local Binary Patterns Histograms) Algorithm to detect faces. It labels the pixels of an image by thresholding the neighborhood of each pixel and considers the result as a binary number.
- LBPH uses 4 parameters :
(i) Radius: the radius is used to build the circular local binary pattern and represents the radius around the
(ii) Neighbors : the number of sample points to build the circular local binary pattern.
(iii) Grid X : the number of cells in the horizontal direction.
(iv) Grid Y : the number of cells in the vertical direction.
- The model built is trained with the faces with tag given to them, and later on, the machine is given a test data and machine decides the correct label for it.
How to use :
- Create a directory in your pc and name it (say project)
- Create two python files named create_data.py and face_recognize.py, copy the first source code and second source code in it respectively.
- Copy haarcascade_frontalface_default.xml to the project directory, you can get it in opencv or from
- You are ready to now run the following codes.
Following code should be run after the model has been trained for the faces :
Note : Above programs will not run on online IDE.
Screenshots of the Program
It may look something different because I had integrated the above program on flask framework
Running of second program yields results similar to the below image :
Datasets Storage :
My Personal Notes arrow_drop_up
Please Login to comment...