This project demonstrates real-time car detection in a video using OpenCV and a pre-trained Haar Cascade classifier.
The script car_detection.py
reads a video file (cars.mp4
) frame-by-frame, detects cars using a Haar Cascade classifier (cars.xml
), and draws bounding boxes around them. It provides a simple example of object detection using computer vision techniques.
- Real-time car detection in a video stream.
- Efficient use of OpenCV library for video processing.
- Simple user interface with intuitive exit functionality (
press 'z' to exit
).
- Python 3.x
- OpenCV (
opencv-python
package) cars.mp4
(or replace with your own video file)cars.xml
(Haar Cascade classifier for car detection)
- Clone the repository:
git clone https://github.com/flameAutomation/Car-Detection-OpenCV.git
cd Car-Detection-OpenCV
- Install dependencies:
pip install opencv-python
- Run the Script:
python car_detection.py
- Ensure
cars.mp4
andcars.xml
are in the same directory ascar_detection.py
. - The video will open in a new window showing detected cars with bounding boxes.
- Press
z
on your keyboard to exit the video display.
cars.mp4
- Example video used for car detection.cars.xml
- Pre-trained Haar Cascade classifier for car detection.