Skip to content

Rcode879/Haar-cascade-detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

Face and Body Detection using OpenCV

This Python script utilizes OpenCV to perform real-time detection of frontal faces, side faces, and full bodies using a webcam. The program captures video frames, processes them to detect various features, and displays the results with visual annotations.

Features

  • Real-time face and body detection: Detects frontal faces, side faces, and full bodies using Haar Cascade classifiers.
  • Visual annotations: Draws rectangles, lines, and text around detected faces and bodies.
  • Midpoint calculation: Computes and displays the midpoint of detected frontal faces.
  • Dynamic updates: Continuously processes the video stream and updates the display in real-time.

Installation

  1. Clone the repository:

    git clone https://github.com/Rcode879/Haar-cascade-detector.git
    cd Haar-cascade-detector
  2. Install the required libraries:

    Ensure you have Python installed (preferably Python 3.6 or higher) and install the required dependencies:

    pip install opencv-python

Usage

  1. Run the script:

    Execute the script to start the webcam and begin detecting faces and bodies:

    python detector.py
  2. Interact with the application:

    • The webcam feed will open in a window named frame.
    • The program will highlight detected faces and bodies with annotations.
    • To stop the program, press the q key.

How It Works

  • Capture Video: Initializes the video capture from the default webcam.
  • Set Resolution: Configures the capture to HD resolution (1280x720).
  • Load Haar Cascades: Loads pre-trained Haar Cascade classifiers for detecting frontal faces, side faces, and full bodies.
  • Process Each Frame:
    • Converts each frame to grayscale for efficient detection.
    • Uses the Haar Cascade classifiers to detect frontal faces, side faces, and bodies.
    • Draws rectangles, lines, and text annotations around the detected objects.
    • Displays the annotated frame in a window.
  • Exit on Key Press: Ends the loop and releases resources when the q key is pressed.

Dependencies

Acknowledgements

This project utilizes the OpenCV library for image processing and computer vision tasks. Haar Cascade classifiers are provided by OpenCV's pre-trained models.

About

A human recognition program that can detect human faces and bodies.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages