Skip to content

Latest commit

ย 

History

History
163 lines (120 loc) ยท 5.7 KB

File metadata and controls

163 lines (120 loc) ยท 5.7 KB

๐Ÿš—๐Ÿ’จ 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 )

  1. Run the Program: For webcam: python main.py For video file: python main.py path/to/your/video.mp4

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

Screenshot 2025-01-01 130247 Screenshot 2025-01-04 140741

๐Ÿ’ก 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 Project Lead and Creater.

๐Ÿ“ž Need Help? ๐Ÿ› Issues: GitHub Issues Page


๐ŸŒŸ Created with passion by [ABHISHEK SINGH] ๐ŸŒŸ