Skip to content

The Python script uses the OpenCV library to detect faces in a video. It imports modules, loads a pre-trained classifier, and creates a video capture object. The script reads frames, converts them to grayscale, detects faces using the Haar Cascade classifier, draws rectangles, and outputs the processed frames.

Notifications You must be signed in to change notification settings

Satyanaryana-Merla/Detecting-faces-in-the-videos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This Python script uses the OpenCV library to perform real-time face detection and create an output video with rectangles drawn around detected faces. The script imports the OpenCV library, loads a pre-trained face detection classifier using the Haar Cascade classifier, opens a video capture object, retrieves video frame dimensions, defines the video codec (XVID), and creates a VideoWriter object to save processed frames as an output video.

The variable 'total_faces' is initialized to count the number of detected faces. The script enters a loop to process each frame of the video, reads a video frame, converts it to grayscale, and applies the Haar Cascade classifier to detect faces in the grayscale frame. For each detected face, a green rectangle is drawn around it using OpenCV's drawing functions.

The processed frame is then written to the output video. The processed frame is displayed in a window with the title 'Video'. The loop continues until the 'q' key is pressed, and the script releases video objects and closes OpenCV windows. The video capture object and VideoWriter object are released to free up system resources.

In summary, this script reads a video file, applies face detection to each frame, draws rectangles around detected faces, and saves the processed frames as a new video. The final output is an AVI video file with detected faces highlighted by green rectangles.

About

The Python script uses the OpenCV library to detect faces in a video. It imports modules, loads a pre-trained classifier, and creates a video capture object. The script reads frames, converts them to grayscale, detects faces using the Haar Cascade classifier, draws rectangles, and outputs the processed frames.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published