Skip to content

iampranav-ai/Face-Detect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 

Repository files navigation

Face Detection using OpenCV & Python

forthebadge made-with-python Open in Visual Studio Code Open Source Love svg1

First of all make sure you have OpenCV installed. You can install it using pip: pip install opencv-python.

Face detection using Haar cascades is a machine learning based approach where a cascade function is trained with a set of input data. OpenCV already contains many pre-trained classifiers for face, eyes, smiles, etc..

In this project I am using the face classifier. You can experiment with other classifiers as well.

You need to download the trained classifier XML file (haarcascade_frontalface_default.xml), which is available in OpenCV’s GitHub repository (https://github.com/opencv/opencv/tree/master/data/haarcascades). It is also available in this project. Save it to your working location.

A few things to note:

The detection works only on grayscale images. So it is important to convert the color image to grayscale. (line 12)

Faces contains a list of coordinates for the rectangular regions where faces were found. We use these coordinates to draw the rectangles in our image.

Similarly, we can detect faces in videos. As you know videos are basically made up of frames, which are still images. So we perform the face detection for each frame in a video.

Hope you found this useful.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages