Skip to content

Mowlick/car-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚗 Car Counter using YOLOv8

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.

🔍 Features

  • 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

📁 Project Structure

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

🚀 How to Run

Install Dependencies

It's recommended to set up a virtual environment. Install all required dependencies from the requirements.txt file:

pip install -r requirements.txt

Run the Script After installing the dependencies, run the Python script - "Car-Counter.py" to start the car detection and counting:

python Car-Counter.py

Select 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.

📦 Requirements

Python 3.10 or higher

OpenCV

YOLOv8 (Ultralytics)

NumPy

tqdm

You can install all dependencies using:

pip install ultralytics opencv-python tqdm numpy

🧠 Model Used

The YOLOv8 model (saved as yolov8l.pt) is used for detecting cars. This pre-trained model is sourced from the Ultralytics YOLOv8 GitHub.

⚠️ Note: The .pt file and sample video are stored using Git LFS due to their large size.

📸 Sample Output

Real-time car detection and counting in action. Screenshot 2025-04-22 175930

🧑‍💻 Author

Mowlick

🔗 GitHub Profile

https://github.com/Mowlick

About

Car Counter using YOLOv8 is a real-time vehicle detection and counting system powered by Ultralytics’ YOLOv8. It processes video streams to identify and track cars as they cross user-defined Regions of Interest (ROI), providing an accurate live count overlay. Built with modular Python code and OpenCV, the project supports video inputs and customiza

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages