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 :
- Opencv Python program for Face Detection
- OpenCV - Facial Landmarks and Face Detection using dlib and OpenCV
- OpenCV C++ Program for Face Detection
- Real-Time Edge Detection using OpenCV in Python | Canny edge detection method
- Python | Corner Detection with Shi-Tomasi Corner Detection Method using OpenCV
- Python | Corner detection with Harris Corner Detection method using OpenCV
- Saving Operated Video from a webcam using OpenCV
- Gun Detection using Python-OpenCV
- Pedestrian Detection using OpenCV-Python
- Python | Smile detection using OpenCV
- Circle Detection using OpenCV | Python
- White and black dot detection using OpenCV | Python
- Detection of a specific color(blue here) using OpenCV with Python
- Line detection in python with OpenCV | Houghline method
- Multiple Color Detection in Real-Time using Python-OpenCV
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.