This repository contains a simple Python project for counting the number of cars in a video using object detection techniques. The project uses the OpenCV library for video processing and object detection. It utilizes background subtraction and contour analysis to detect and count vehicles passing through a specified line in the video.
- Python 3.10
- OpenCV (cv2) library
- NumPy
-
Ensure you have Python 3.7 installed. If not, you can download it from the official Python website.
-
Clone this repository to your local machine:
https://github.com/DYNAMICMORTAL/object-detection.git
-
Change into the project directory:
cd object-detection-car-counter
-
Install the required dependencies:
pip install -r requirements.txt
-
Place the video file containing the cars to be detected in the
testVideos
directory. -
Update the
carsVideo.mp4
file path in thecap = cv2.VideoCapture('testVideos/carsVideo.mp4')
line of thecar_counter.py
file with the correct file name. -
Run the car counter script:
python car_counter.py
The script will process the video, detect cars, and display the video with bounding boxes around the detected vehicles. The count of cars crossing the specified line will be shown on the video.
- Press
Enter
orReturn
to exit the video window.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions to this project are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.