https://github.com/pronzzz/face-detection
Face Detection using Haar Cascades In this project, we used OpenCV's Haar Cascade classifier to detect faces in images. We converted images to grayscale, applied the Haar Cascade, and drew green rectangles around detected faces. We also created a generalized function for face detection and tested it on a new image.
https://github.com/pronzzz/face-detection
face-detection haar-cascade opencv
Last synced: 2 months ago
JSON representation
Face Detection using Haar Cascades In this project, we used OpenCV's Haar Cascade classifier to detect faces in images. We converted images to grayscale, applied the Haar Cascade, and drew green rectangles around detected faces. We also created a generalized function for face detection and tested it on a new image.
- Host: GitHub
- URL: https://github.com/pronzzz/face-detection
- Owner: pronzzz
- License: mit
- Created: 2024-02-11T12:46:56.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-11T12:59:15.000Z (over 2 years ago)
- Last Synced: 2025-04-13T18:18:18.553Z (about 1 year ago)
- Topics: face-detection, haar-cascade, opencv
- Language: Jupyter Notebook
- Homepage:
- Size: 3.31 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Haar Cascade Face Detection 📸 👀
---
## Overview 🔎
This project demonstrates Haar Cascade face detection in Python using OpenCV. Haar Cascade is a machine learning object detection algorithm used to identify faces in images. It's widely employed in real-time face detection applications like security systems and facial recognition software.
## Steps Involved 👣
1. **Importing Necessary Libraries**: We begin by importing essential libraries like NumPy, OpenCV, and Matplotlib for image manipulation and visualization.
2. **Loading the Test Image**: Next, we load the image we want to detect faces in.
3. **Converting to Grayscale**: Since OpenCV's face detector works with grayscale images, we convert the loaded image to grayscale.
4. **Haar Cascade Files**: We load the pre-trained Haar Cascade classifier for frontal face detection from OpenCV's data repository.
5. **Face Detection**: Using the loaded classifier, we detect faces in the grayscale image and store the coordinates of detected faces.
6. **Drawing Rectangles Around Detected Faces**: We draw green rectangles around the detected faces using OpenCV's rectangle function.
7. **Displaying the Result**: Finally, we display the original image with the detected faces highlighted by rectangles.
8. **Generalizing with a Function**: To make the face detection process more reusable, we create a `detect_faces()` function that takes an image and a cascade classifier as inputs and returns the image with detected faces highlighted.
9. **Applying the Function to a New Image**: We test the `detect_faces()` function on a different image to demonstrate its versatility.
10. **Saving the Result**: We save the final image with detected faces for further use or analysis.
## Usage 💻
To use this project:
1. Clone the repository.
2. Install the required libraries using `pip install -r requirements.txt`.
3. Place the test images in the `data` folder.
4. Run `python main.py` to execute the face detection algorithm.
## Conclusion 🏁
This project showcases how to use Haar Cascade for face detection in Python with OpenCV. It provides a solid foundation for exploring more advanced face detection techniques and building fascinating applications like face recognition and real-time surveillance systems.