How nan2006-ditha/driver-drowsiness-detection works
This is a real-time driver-drowsiness monitoring application: a driver’s camera frames are processed for facial cues, combined into a drowsiness status and metrics, then presented through a FastAPI dashboard and video stream; prolonged eye closure also triggers an alarm. The graph separates frame capture, perception, scoring/alerting, and dashboard delivery, with a secondary model-training branch. The README documents dashboard controls and metrics; source excerpts confirm the API, processing, and metrics paths, but do not show the frontend controls or the eye-classifier implementation.
Main entry points: detector.py Frame Processor · app.py FastAPI Routes · webcam.py Webcam Runtime · index.html Dashboard Page
Components 20
Capture and API
- FastAPI Routes
api/app.py - Webcam Runtime
src/webcam.py - Live Metrics
src/webcam.py
Face Perception
- MediaPipe Face Mesh
- Frame Processor
src/detector.py - EAR Calculation
src/ear.py - MAR Calculation
src/mar.py - Eye Classification
src/eye_detector.py - Head Pose
src/head_pose.py
Scoring and Alerts
- Drowsiness Score
src/drowsiness_score.py - Alarm Control
src/alarm.py
Dashboard Delivery
- Dashboard Page
templates/index.html - Metrics Poller
static/script.js - Dashboard Styling
static/style.css
Model Training
- CNN Architecture
src/cnn_model.py - CNN Trainer
src/train.py - Eye Image Dataset
src/data_loader.py
Other components
- Driver
- Dashboard User
- Webcam
Connections 22
- Dashboard User → FastAPI Routes: requests dashboard
- FastAPI Routes → Dashboard Page: renders page
- Dashboard Page → Metrics Poller: loads script
- Dashboard Page → Dashboard Styling: loads styles
- Metrics Poller → FastAPI Routes: fetches metrics
- FastAPI Routes → Webcam Runtime: starts capture
- FastAPI Routes → Webcam Runtime: streams frames
- Webcam → Webcam Runtime: supplies frames
- Webcam Runtime → Frame Processor: processes frames
- Frame Processor → MediaPipe Face Mesh: extracts landmarks
- Frame Processor → EAR Calculation: calculates EAR
- Frame Processor → MAR Calculation: calculates MAR
- Frame Processor → Eye Classification: classifies eyes
- Frame Processor → Head Pose: estimates pose
- Frame Processor → Drowsiness Score: calculates score
- Frame Processor → Alarm Control: controls alarm
- Webcam Runtime → Live Metrics: updates metrics
- FastAPI Routes → Live Metrics: reads metrics
- Webcam Runtime → Dashboard User: streams video
- Driver → Webcam: provides video
- Eye Image Dataset → CNN Trainer: supplies training data
- CNN Trainer → CNN Architecture: builds and trains