Skip to content

About

A comprehensive real-time driver assistance system provides intelligent driving assistance and road sign alerts.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

29 Commits

Folders and files

Repository files navigation

πŸš— Advanced Driver Assistance System (ADAS)

A comprehensive real-time driver assistance system that combines YOLOv8 object detection with computer vision-based lane detection to provide intelligent driving assistance and safety alerts.

ADAS Preview

🎯 Project Overview

This ADAS system provides real-time monitoring and assistance for drivers by detecting:

  • Objects: Cars, pedestrians, traffic signs, and other vehicles
  • Lane Departure: Real-time lane detection and departure warnings
  • Proximity Alerts: Audio-visual warnings for objects too close to the vehicle
  • Safety Monitoring: Continuous assessment of driving environment

✨ Key Features

🎯 Object Detection & Classification

  • YOLOv8 Model: Trained on car camera photos dataset in Google Colab
  • Multi-class Detection: Cars, pedestrians, traffic signs, and more
  • Real-time Processing: 30+ FPS on standard hardware
  • Confidence-based Filtering: Adjustable detection thresholds

πŸ›£οΈ Lane Detection System

  • Computer Vision Pipeline: Canny edge detection + Hough transform
  • Region of Interest (ROI): Focused analysis on driving lanes
  • Lane Departure Warning: Visual indicators for lane boundaries
  • Adaptive Processing: Handles various road conditions and lighting

πŸ”Š Safety Alerts & Warnings

  • Proximity Detection: Audio alerts for objects too close to vehicle
  • Visual Overlays: Real-time bounding boxes and labels
  • Smart Thresholding: Distance-based warning system
  • Multi-threaded Audio: Non-blocking alert system

πŸ“Š Real-time Analytics

  • Object Counting: Live count of detected vehicles and signs
  • Performance Metrics: FPS monitoring and detection statistics
  • Visual Feedback: Color-coded detection results

πŸ› οΈ Tech Stack

Core Technologies

  • Python 3.8+: Primary programming language
  • OpenCV 4.x: Computer vision and image processing
  • Ultralytics YOLOv8: State-of-the-art object detection
  • NumPy: Numerical computing and array operations

Computer Vision

  • Canny Edge Detection: Lane boundary identification
  • Hough Transform: Line detection in images
  • Gaussian Blur: Noise reduction and smoothing
  • Region of Interest (ROI): Focused analysis areas

Audio & UI

  • playsound: Audio alert system
  • OpenCV GUI: Real-time video display
  • Threading: Non-blocking audio playback

Data Processing

  • Pandas: Data manipulation and analysis
  • Matplotlib: Visualization and plotting
  • Plotly: Interactive data visualization

🧠 Model Training

The YOLOv8 model was trained using Google Colab for its free GPU resources. The training process involved:

  • Dataset: Car camera photos with annotated objects (cars, pedestrians, traffic signs)
  • Environment: Google Colab with CUDA-enabled GPU
  • Framework: Ultralytics YOLOv8
  • Training Script: Available in model.ipynb

Challenges and Difficulties

Training the YOLOv8 model in Google Colab presented several challenges:

  • Session Timeouts: Colab's 12-hour session limit required careful checkpointing and resuming training
  • GPU Availability: Limited free GPU time necessitated efficient training schedules
  • Data Upload: Large datasets required uploading to Google Drive or using cloud storage
  • Memory Constraints: Balancing batch size with Colab's RAM limitations
  • Model Optimization: Tuning hyperparameters for real-time performance on edge devices
  • Integration: Ensuring the trained model integrates seamlessly with the lane detection and alert systems
  • Data Quality: Collecting and annotating diverse driving scenarios for robust detection

πŸ“ Project Structure

adas/
 β”œβ”€β”€ model.pt                 # Trained YOLOv8 model
β”œβ”€β”€ model.ipynb             # Model training notebook
β”œβ”€β”€ README.md               # Project documentation
β”œβ”€β”€ sounds/
β”‚   └── warning.mp3        # Audio alert file
└── testing/
    β”œβ”€β”€ frames.py          # Frame-by-frame processing
    β”œβ”€β”€ lane.py            # Lane detection algorithms
    └── webcam.py          # Real-time webcam processing

πŸš€ Quick Start

Prerequisites

# Install Python dependencies
pip install ultralytics opencv-python numpy pandas matplotlib plotly playsound

Running the System

Vice City AutoDrive crosswalks

Run .venv\Scripts\python.exe testing\webcam.py --screen --autodrive, select the game view, focus Vice City and press Ctrl+Alt+G to arm. The preview outlines detected zebra crossings. A detected pedestrian on a crossing or in the driving path triggers a brief S brake pulse and releases throttle and steering. AutoDrive waits for 0.8 seconds of clear observations before selecting a path again. Ctrl+Alt+X disarms it. AutoDrive pulses W for 120 ms every 400 ms to cruise slowly. A persistent, near-uniform view triggers reverse until a traversable road ribbon reappears. The screen-based planner has no vehicle-speed telemetry.

Standalone crosswalk simulation

Run python testing/crosswalk.py from the project root with Python 3.8+. It runs a pedestrian crossing, an empty crossing, and a crossing with a parked van obscuring the approaching pedestrian. Add --animate for a terminal replay.

python testing/crosswalk.py --scenario van --speed 8 --delay 0.2 --animate
python testing/crosswalk.py --scenario van --speed 12 --delay 1

Speed is in metres per second and sensor delay is in seconds, rounded up to the next 50 ms simulation tick. The event log gives time, speed, and the car's front position relative to the near edge of the crossing (negative is upstream). The controller receives delayed synthetic visibility observations. It aims to stop two metres before the crossing and accelerates again after observing clearance. The simulation checks occupancy and collisions against the actual pedestrian position. A failed run exits with code 1. This experiment models a single straight lane with fixed braking and runs independently of YOLO and the browser game's keyboard controls.

Browser game screen capture

  1. Open the game in your browser and position it on your primary monitor.
  2. Run run-browser-game.bat from the project folder, or run .venv\Scripts\python.exe testing\webcam.py --screen from the project root.
  3. Drag a rectangle around the game in the selection window, then press Enter or Space. Press Esc to cancel.
  4. Keep the game visible at the same position and play as usual. Detections appear in a separate OpenCV window; keep that window outside the selected game area. Click the detection window and press q to stop. Select the area again after moving or resizing the game.

This captures screen pixels, so another window covering the game will also be captured. The model was trained on real driving images, so game graphics and third-person views may require tuning and can reduce accuracy. Warnings are based on bounding-box size, not measured distance.

The detector defaults to at most 60 frames per second and a 320-pixel inference size to reduce resource use. To adjust them, launch from the project root, for example:

.venv\Scripts\python.exe testing\webcam.py --screen --fps 3 --imgsz 416

Lower values generally use fewer resources, but can miss fast-moving or small objects. Actual frame rate can be lower than the limit if processing takes longer.

Experimental Vice City autonomous mode (Windows)

This is an experimental game controller, not for real vehicles. It assumes a front-facing in-car view and the game's WASD controls (W accelerates, S brakes/reverses, A/D steer). It cannot read speed, detect every obstacle, or navigate intersections; the real-road-trained object model may miss game objects. Test in a clear area at low speed and be ready to take over. S can reverse the car when it is already stopped.

  1. Open the browser game on the primary screen, choose the in-car view, and leave it visible. Run from the project root:

    .venv\Scripts\python.exe testing\webcam.py --screen --autodrive
  2. Select the game rectangle and press Enter. Keep the preview outside that rectangle. Click the game to focus it, then press Ctrl+Alt+G to arm. The preview displays the controller state and a perspective ribbon. The ribbon spans about 32% of the image at the bumper and tapers to about 7% ahead. It shows the proposed path in green, or the forward corridor in red when yielding. On unmarked pavement the car can drive straight. Edges, surface changes and detected traffic influence which curve it follows. When every sampled path is blocked it releases the throttle. A close obstacle directly ahead triggers a short brake input. Release Ctrl and Alt after arming before the car can move.

  3. Press Ctrl+Alt+X globally to immediately disarm and release the keys. Ctrl+Alt+G re-arms only while the selected game window has focus. Losing focus or an inference timeout also disarms and releases keys. Click the preview and press q, close it, or use Ctrl+C to exit. Stop before moving/resizing or covering the capture area; select it again after restarting. The watchdog depends on the Python process and Windows; a forcibly killed process or system failure cannot guarantee key release. If needed, press and release W, A, S and D manually to clear them.

The controller uses screen-space heuristics rather than measured distances; shadows, HUD elements, unusual roads, and false detections can cause bad steering or braking. It has not been calibrated to a particular game installation.

1. Real-time Webcam Processing

cd testing
python webcam.py

2. Frame-by-frame Analysis

cd testing
python frames.py

πŸ”§ Configuration

Model Parameters

  • Confidence Threshold: conf=0.5 (adjustable)
  • Detection Classes: Cars, pedestrians, traffic signs
  • Processing Speed: Real-time (30+ FPS)

Lane Detection Settings

  • ROI Coordinates: Focused on lower 60% of frame
  • Edge Detection: Canny thresholds (180, 240)
  • Line Detection: Hough transform parameters optimized

Alert System

  • Proximity Threshold: 800 pixels (adjustable)
  • Audio Frequency: 1-second cooldown between alerts
  • Visual Warnings: Color-coded alert system

πŸ“Š Performance Metrics

Detection Accuracy

  • Object Detection: 95%+ accuracy on test dataset
  • Lane Detection: Robust across various road conditions
  • Real-time Processing: 30+ FPS on standard hardware

System Requirements

  • CPU: Intel i5 or equivalent
  • RAM: 8GB minimum, 16GB recommended
  • GPU: Optional (CUDA support for faster inference)
  • Storage: 2GB for model and dependencies

🎯 Use Cases

πŸš— Automotive Applications

  • Dashcam Integration: Real-time monitoring systems
  • Fleet Management: Commercial vehicle safety
  • Driver Training: Educational and training platforms
  • Research & Development: ADAS algorithm development

🏭 Industrial Applications

  • Warehouse Safety: Forklift and pedestrian detection
  • Construction Sites: Heavy machinery safety
  • Security Systems: Perimeter monitoring
  • Quality Control: Manufacturing process monitoring

πŸ”¬ Technical Implementation

Object Detection Pipeline

  1. Frame Capture: Real-time video input
  2. Preprocessing: Resize and normalize
  3. YOLOv8 Inference: Object detection and classification
  4. Post-processing: Confidence filtering and NMS
  5. Visualization: Bounding boxes and labels

Lane Detection Algorithm

  1. Grayscale Conversion: Color to intensity mapping
  2. Gaussian Blur: Noise reduction
  3. Canny Edge Detection: Boundary identification
  4. ROI Masking: Focus on driving lanes
  5. Hough Transform: Line detection
  6. Slope Analysis: Lane classification (left/right)
  7. Visual Overlay: Lane marking display

Safety Alert System

  1. Proximity Calculation: Distance-based analysis
  2. Threshold Checking: Configurable alert triggers
  3. Multi-threaded Audio: Non-blocking alerts
  4. Visual Feedback: On-screen warnings

🀝 Contributing

We welcome contributions! Please see our contributing guidelines for:

  • Bug reports and feature requests
  • Code improvements and optimizations
  • Documentation enhancements
  • Performance optimizations

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Ultralytics: YOLOv8 implementation
  • OpenCV: Computer vision library
  • Kaggle Dataset: Car camera photos for training
  • Research Community: Computer vision and ADAS research

πŸ“ž Support

For questions, issues, or contributions:

  • Create an issue on GitHub
  • Contact the development team
  • Check documentation for common solutions

Built with ❀️ for safer roads and smarter driving

Testing GTA Vice City with the rotating minimap

On Windows, open the game on the primary screen, switch to a forward-facing in-car view and run this command from the repository root.

.venv\Scripts\python.exe testing\webcam.py --screen --autodrive --map

Select the visible game rectangle and press Enter. Inside that still image, select a tight square around the entire circular radar and press Enter again. The radar can face any direction. Keep both preview windows outside the captured area. Click the game and press Ctrl+Alt+G, then release the modifiers to drive. Ctrl+Alt+X disarms globally. If you move or resize the game, restart and select the two rectangles again.

The map preview matches radar landmarks against the reference image and searches for bright or dark road markings across rotations and zoom levels. After a road match it searches near the last position first. The blue dot marks a recent fix. If the preview reports similar locations, move toward a distinctive junction. If it reports too little detail, check that the selection tightly encloses the radar.

If your edition uses different map artwork, pass a cropped screenshot of its full map with --map-image "C:\path\to\game-map.png". This works in either testing/webcam.py --screen or testing/navigation.py. The image becomes both the search reference and the displayed map. Click the map to mark a destination. Driving follows the selected road ribbon and reacts to detected obstacles independently of the marker. Destination routing is still experimental work for the future.

For a map-only session run python testing/navigation.py in the project environment. For detection and localization without sending game keys, use python testing/webcam.py --screen --map.

About

A comprehensive real-time driver assistance system provides intelligent driving assistance and road sign alerts.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Contributors

Languages