This repository contains a Python script for detecting faces in images and videos using OpenCV's Haar cascades.
Before running the script, make sure you have the following dependencies installed:
- OpenCV (
cv2
) - Python 3.x
You can install OpenCV using pip:
pip install opencv-python
- Clone this repository:
git clone https://github.com/PensPencil/Haar_Cascades.git
- Change into the cloned directory:
cd Haar_Cascades
- Run the script:
python program.py
- Follow the prompts in the terminal to provide input:
-
For image input:
- Enter 'image' when asked for input type.
- Enter the path to the input image when prompted.
-
For video input:
- Enter 'video' when asked for input type.
- Enter 'camera' to use your live camera as the video source, or provide the path to a video file.
The script will detect faces in the provided image or video and display the output with rectangles drawn around the detected faces.
Note: Press 'q' to exit the video input mode.
Enter 'image' for image input or 'video' for video input: image
Enter the path to the input image: /path/to/your/image.jpg
Enter 'image' for image input or 'video' for video input: video
Enter 'camera' for live video, or video path: camera
or
Enter 'image' for image input or 'video' for video input: video
Enter 'camera' for live video, or video path: /path/to/your/video.mp4
The face detection algorithm in this script utilizes OpenCV's Haar cascades. The Haar cascades XML file used for face detection can be found in the repository.
This project is licensed under the MIT License. See the LICENSE file for more information.