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 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
- Python | Smile detection using OpenCV
- Circle Detection using OpenCV | Python
- Saving Operated Video from a webcam using OpenCV
- White and black dot detection using OpenCV | Python
- Line detection in python with OpenCV | Houghline method
- Detection of a specific color(blue here) using OpenCV with Python
- OpenCV Python program for Vehicle detection in a Video frame
- Python Program to detect the edges of an image using OpenCV | Sobel edge detection method
- Image Processing in Java | Set 9 ( Face Detection )
- OpenCV C++ Program for coin detection
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.