Loading repository dataโฆ
Loading repository dataโฆ
ashwinsiva007 / repository
๐ค AI-powered dual-camera road safety system โ real-time detection of driver drowsiness, lane risks & obstacles with SOS alerts | Python ยท OpenCV
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
๐ A real-time, dual-camera Advanced Driver Assistance System (ADAS) that detects road hazards, monitors vehicle proximity, recognizes speed limits, and delivers instant voice + audio alerts โ all running locally on a standard webcam.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ AI-POWERED DASHCAM โ
โโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ driverview.py โ roadview.py โ
โ (Driver Camera) โ (Road / Front Camera) โ
โ USB Webcam [1] โ Laptop Camera [0] โ
โโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ YOLOv8n Detection โ
โ Vehicles โ Pedestrians โ Animals โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ADAS Same-Lane Filtering โ
โ Trapezoidal ROI โ Lane-Only Warnings โ
โโโโโโโโโโโโโฌโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Proximity โ Accident โ Speed Limit โ Environment โ
โ Scoring โ Detection โ (Roboflow AI) โ Analysis โ
โโโโโโโโโโโโโดโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Voice Alerts (pyttsx3) + Beep (pygame) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Detects and classifies objects into three categories simultaneously:
| Category | Objects Detected |
|---|---|
| ๐ Vehicles | Car, Bus, Truck, Motorcycle, Bicycle |
| ๐ถ Pedestrians | Person |
| ๐ |
| Cat, Dog, Horse, Cow, Elephant, Bear, Zebra, Giraffe + more |
The system only warns about objects inside your driving lane using a dynamic trapezoidal ROI โ eliminating false alerts from vehicles on adjacent lanes.
โโโโโโโโ โ Lane Top (16% frame width)
/ \
/ \
/ \
โโโโโโโโโโโโโโโโ โ Lane Bottom (70% frame width)
Proximity Levels (based on bounding box height ratio):
| Level | Threshold | Color | Action |
|---|---|---|---|
| ๐ด DANGER | โฅ 55% frame height | Red | High-pitch beep + HUD alert |
| ๐ WARNING | โฅ 35% frame height | Orange | Mid-pitch beep + HUD alert |
| ๐ก CAUTION | โฅ 18% frame height | Yellow | Low beep |
| ๐ข SAFE | < 18% frame height | Green | No alert |
Voice Alerts (pyttsx3 โ spoken audio):
Audio Beeps (pygame โ synthesized tones):
| Alert Level | Frequency | Duration |
|---|---|---|
| Danger | 880 Hz | 180ms |
| Warning | 660 Hz | 140ms |
| Caution | 440 Hz | 100ms |
A background thread submits road frames to a Roboflow-hosted Speed Limit Detection model every 5 seconds โ detecting speed limit signs from live video and displaying them on the HUD in real-time.
AccidentScorer)Multi-signal scoring system that raises an alert when any combination of these triggers is detected:
cv2.absdiff) between consecutive frames| Condition | Detection Method | Response |
|---|---|---|
| Night | Frame brightness < 50 | Voice alert |
| Low Light | Frame brightness 50โ99 | Voice alert |
| Camera Blocked | โฅ80% grid patches with std < 15 | Voice alert + red HUD bar |
Real-time heads-up display rendered on the video feed:
ai-powered-dashcam/
โ
โโโ driverview.py # Driver-facing camera system (USB Webcam / Index 1)
โโโ roadview.py # Road-facing camera system (Laptop Camera / Index 0)
โโโ README.md
Note: Both scripts use the same integrated ADAS engine. Run them simultaneously for the full dual-camera experience โ
driverview.pyon the interior camera androadview.pyon the forward-facing road camera.
git clone https://github.com/ashwinsiva007/ai-powered-dashcam.git
cd ai-powered-dashcam
pip install ultralytics opencv-python pyttsx3 pygame numpy roboflow
The yolov8n.pt model is automatically downloaded on first run via Ultralytics. No manual download needed.
python roadview.py
python driverview.py
python roadview.py --source path/to/video.mp4
# Terminal 1 โ Road view
python roadview.py
# Terminal 2 โ Driver view
python driverview.py
When prompted:
Press
Qto quit either window.
| Library | Purpose |
|---|---|
ultralytics | YOLOv8 object detection |
opencv-python | Video capture, frame processing, HUD rendering |
numpy | Frame difference analysis, lane polygon math |
pyttsx3 | Cross-platform text-to-speech voice alerts |
pygame | Synthesized audio beep alerts |
roboflow | Speed limit sign detection via cloud API |
threading | Non-blocking TTS and API calls |
All thresholds and settings are centralized in the CONFIG dictionary at the top of each script:
CONFIG = {
"danger_threshold": 0.55, # bbox height ratio for danger
"warning_threshold": 0.35, # bbox height ratio for warning
"caution_threshold": 0.18, # bbox height ratio for caution
"beep_cooldown": 1.5, # seconds between audio beeps
"confidence": 0.40, # YOLO detection confidence
"frame_skip": 2, # process every N frames (performance)
"lane_top_width": 0.16, # lane ROI top width (% of frame)
"lane_bottom_width": 0.70, # lane ROI bottom width (% of frame)
}
Built with โค๏ธ by Ashwin Sivaram
โญ Star this repo if you find it useful!