https://github.com/ravnop/vehicle-speed-and-type-detection-using-yolov8
This system uses artificial intelligence to detect vehicles in video streams, track their movement, and calculate their speeds in real-time. It can: ๐ Identify different types of vehicles (cars, trucks, buses, motorcycles) ๐๏ธ Measure vehicle speeds accurately ๐ฆ Detect and log speed limit violations ๐ Display real-time results on screen
https://github.com/ravnop/vehicle-speed-and-type-detection-using-yolov8
python pythonproject speech-recognition yolov8
Last synced: 6 months ago
JSON representation
This system uses artificial intelligence to detect vehicles in video streams, track their movement, and calculate their speeds in real-time. It can: ๐ Identify different types of vehicles (cars, trucks, buses, motorcycles) ๐๏ธ Measure vehicle speeds accurately ๐ฆ Detect and log speed limit violations ๐ Display real-time results on screen
- Host: GitHub
- URL: https://github.com/ravnop/vehicle-speed-and-type-detection-using-yolov8
- Owner: RavnOP
- License: mit
- Created: 2025-01-04T08:17:11.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-01-05T19:19:05.000Z (11 months ago)
- Last Synced: 2025-04-02T12:19:50.877Z (9 months ago)
- Topics: python, pythonproject, speech-recognition, yolov8
- Language: Python
- Homepage:
- Size: 11.3 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐๐จ Vehicle Speed Detection System
๐ฅ Real-time Traffic Monitoring and Speed Enforcement
# ๐ What It Does
This system uses artificial intelligence to detect vehicles in video streams,
track their movement, and calculate their speeds in real-time. It can:
๐ Identify different types of vehicles (cars, trucks, buses, motorcycles)
๐๏ธ Measure vehicle speeds accurately
๐ฆ Detect and log speed limit violations
๐ Display real-time results on screen
# ๐งฉ System Components
Our Vehicle Speed Detection System is composed of several interconnected components,
each playing a crucial role in the overall functionality.
Here's a detailed breakdown of each component:
1. ๐ฌ Main Application (`main.py`)
๐ Serves as the entry point for the entire system
๐ญ Handles command-line arguments for video source selection
๐ Initializes and kicks off the video processing pipeline
2. ๐๏ธ Video Processor (`video_processor.py`)
๐ง Acts as the central brain of the system
๐ Coordinates interactions between all other components
๐ฅ๏ธ Manages the main processing loop for each video frame
๐๏ธ Implements performance optimizations like selective frame processing
3. ๐ Vehicle Detector (`detector.py`)
๐๏ธ Utilizes YOLOv8 AI model for real-time object detection
๐ Identifies and locates vehicles in each processed frame
๐ท๏ธ Classifies detected objects into vehicle categories (e.g., car, truck, bus, motorcycle)
๐ฏ Applies confidence thresholding to minimize false positives
4. ๐ผ๏ธ Visualizer (`visualizer.py`)
๐จ Draws bounding boxes around detected vehicles on the video frame
๐ Overlays vehicle information (type, speed) on the video
๐ฆ Color-codes speed displays based on speed limit compliance
๐ฅ๏ธ Manages the on-screen display of processing statistics (e.g., FPS counter)
5. ๐ Data Logger (`data_logger.py`)
๐ Records speed limit violations in real-time
๐
Timestamps each violation entry
๐ Saves violation data to an Excel file for later analysis
๐ Ensures data integrity with proper file handling and error management
6. ๐น Video Capture (`video_capture.py`)
๐ฅ Handles video input from various sources (webcam, video files)
๐งต Implements multi-threading for efficient frame capture
๐ ๏ธ Provides fallback options and error handling for different video backends
7. โฑ๏ธ Speed Tracker (`speed_tracker.py`)
๐ Maintains position history for each detected vehicle
๐งฎ Calculates vehicle speeds based on position changes over time
๐ข Implements algorithms to smooth speed calculations and reduce fluctuations
8. ๐งฎ Speed Calculator (`speed_calculator.py`)
๐ Converts pixel movements to real-world speed measurements
๐งช Applies statistical methods to filter out anomalies in speed data
๐๏ธ Adapts calculations based on camera perspective and positioning
9. ๐ Calibration (`calibration.py`)
๐ Handles camera calibration parameters
๐บ๏ธ Translates pixel coordinates to real-world distances
๐ง Provides functions to adjust for camera angle and positioning
10. โ๏ธ Configuration (`config.py`)
๐๏ธ Centralizes all system-wide settings and parameters
๐ฅ Defines speed limits for different vehicle types
๐๏ธ Allows easy tuning of detection and tracking parameters
๐๏ธ Stores mappings for vehicle classes and their corresponding indices
# ๐ ๏ธ How It Works
1. Video Input: Uses your webcam or a video file
2. Vehicle Detection: Spots vehicles using YOLOv8 AI
3. Tracking: Follows each vehicle across video frames
4. Speed Calculation: Estimates speed based on vehicle movement
5. Visualization: Shows results on screen with bounding boxes and speed info
6. Logging: Records speed violations in an Excel file
# ๐ Requirements
Python 3.8 or newer
OpenCV
NumPy
Ultralytics YOLOv8
openpyxl
SciPy
# ๐โโก๏ธ๐โโก๏ธ๐โโก๏ธBefore Run the Program ๐โโก๏ธ๐โโก๏ธ๐โโก๏ธ:
Install the required packages:
( pip install opencv-python numpy ultralytics openpyxl scipy ) ๐๐OR๐๐ ( pip install -r requirements.txt )
3. Run the Program:
For webcam: `python main.py`
For video file: `python main.py path/to/your/video.mp4`
4. Controls:
Press 'q' to quit
Press 's' to save a screenshot
# โ๏ธ Customization
Edit `config.py` to change:
๐ฏ Detection sensitivity
๐ Speed calculation settings
๐ Speed limits for different vehicles
# ๐ What You'll See
- Live video with:
- Boxes around detected vehicles
- Vehicle types (car, truck, etc.)
- Calculated speeds
- Frames per second (FPS) count
- `speed_violations.xlsx` file with logged violations
# ScreeShot......


# ๐ก Tips for Best Results
๐ Calibrate the camera settings in `config.py` for your setup
๐ฅ Use high-quality video input for better accuracy
๐ป A computer with a good GPU will run the system faster
# ๐ฎ Future Plans
- Night-time detection improvements
- License plate recognition
- Web interface for remote monitoring
- Integration with traffic management systems
# ๐ค Want to Contribute?
We welcome your ideas and code contributions! Here's how:
1. Fork the repository
2. Create your feature branch
3. Commit your changes
4. Push to your branch
5. Open a Pull Request
๐ License
This project is a Open Source Project.
๐ฅ Team
[ABHISHEK SINGH](https://github.com/BeingLazyCoder) Project Lead and Creater.
๐ Need Help?
๐ Issues: [GitHub Issues Page](https://github.com/BeingLazyCoder/Vehicle-Speed-and-Type-Detection-Using-YoloV8/issues)
---
# ๐ Created with passion by [ABHISHEK SINGH] ๐