This project uses YOLOv8 (You Only Look Once) to detect and count cars in video streams. It tracks vehicles crossing user-defined Regions of Interest (ROIs) and overlays a live count on the video feed.
- ✅ Real-time car detection using YOLOv8
- 🎯 Custom Region of Interest (ROI) selection for precise tracking
- 📊 Car counting with a live overlay
- 🎥 Supports video file input (e.g., traffic footage)
- 💾 Modular and clean Python code structure for easy customization
Object_Detection_Yolo/
│
├── main.py # Main script to run detection and counting
├── utils/ # Utility functions (drawing, counting, etc.)
│ └── roi.py # Functions for handling ROI
├── Yolo-Weights/ # YOLOv8 weight files
│ └── yolov8l.pt # Pre-trained YOLOv8 weights
├── Videos/ # Sample video files for testing
│ └── traffic2.mp4 # Sample traffic video
├── .gitignore # Git ignore file to exclude unnecessary files
├── requirements.txt # List of Python dependencies
└── README.md # Project documentation
It's recommended to set up a virtual environment. Install all required dependencies from the requirements.txt file:
pip install -r requirements.txtRun the Script After installing the dependencies, run the Python script - "Car-Counter.py" to start the car detection and counting:
python Car-Counter.pySelect ROI If interactive ROI selection is enabled, you can define areas of interest for accurate car tracking.
Watch the Real-Time Detection The script will process the video and display the car count in real-time.
Python 3.10 or higher
OpenCV
YOLOv8 (Ultralytics)
NumPy
tqdm
You can install all dependencies using:
pip install ultralytics opencv-python tqdm numpyThe YOLOv8 model (saved as yolov8l.pt) is used for detecting cars. This pre-trained model is sourced from the Ultralytics YOLOv8 GitHub.
