๐ง DriveSense AI โ Adaptive Driver Fatigue & Attention Monitor
"Every year, 100,000 people die from drowsy driving. DriveSense AI predicts fatigue before it kills."
๐ฏ Judge's Pitch
Existing driver monitoring systems detect drowsiness after your eyes close. DriveSense AI uses a multi-factor fatigue fusion model that combines PERCLOS, blink anomalies, head pose drift, yawn frequency, and circadian rhythm data to predict dangerous fatigue levels 10 minutes before they happen โ giving drivers time to save their own lives. It's the difference between a near-miss and a funeral.
๐ก Inspiration
We started with a question: Why do driver monitoring systems only react instead of predict?
openpilot has a driver-facing camera that checks if you're looking at the road. But alertness isn't binary. Fatigue is a gradual physiological process โ it shows up in your blink patterns 20 minutes before you feel sleepy. Your head starts micro-drifting. Your yawns cluster together.
We built DriveSense AI to catch what humans can't feel happening to themselves.
๐ What It Does
DriveSense AI is a real-time driver fatigue monitoring and prediction dashboard that:
- ๐ Tracks 6+ biometric signals โ PERCLOS (eye closure percentage), blink rate, head yaw/pitch, yawn frequency, gaze direction, mouth openness
- ๐ง Runs a multi-factor AI fatigue model โ Weighted fusion of all signals through an exponential moving average pipeline
- ๐ Predicts fatigue 10 minutes ahead โ Linear regression on trend data projects when you'll cross danger thresholds
- ๐ Computes a real-time Safety Score (0โ100, AโF grade) โ With component breakdowns showing exactly what's degrading
- ๐จ 3-tier alert system โ Info nudges โ Warning chimes โ Critical "PULL OVER" full-screen overlay with audio
- ๐ Circadian rhythm modeling โ Knows that 3 AM and 2 PM are biologically dangerous times
- โ Coffee break simulation โ Models temporary alertness recovery after a rest stop
- ๐บ๏ธ Gaze attention heatmap โ Visualizes where the driver is looking over time
4 Realistic Driving Scenarios
| Scenario | Description |
|---|---|
| ๐ Night Highway | Monotonous highway at 11 PM โ fatigue builds fast |
| ๐ Morning Commute | Rush hour at 7:30 AM โ stop-and-go keeps you alert |
| ๐ด Post-Lunch Dip | Afternoon drive at 2 PM โ the circadian dip strikes |
| ๐ Long Haul Trucker | 6-hour interstate haul โ relentless fatigue accumulation |
๐๏ธ How We Built It
Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Dashboard UI โ
โ (index.html + glassmorphism CSS) โ
โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ โ
โ โ Driver โ โ Chart.js โ โ Alert Feed โ โ
โ โ Face โ โ Timeline โ โ + Toast โ โ
โ โ Canvas โ โ + Gauge โ โ Notifications โ โ
โ โโโโโโฌโโโโโโ โโโโโโโฌโโโโโโ โโโโโโโโฌโโโโโโโโโโ โ
โ โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโ โ
โ โโโโโโโโผโโโโโโโ โ
โ โ app.js โ โ Main Controller โ
โ โ (60fps) โ โ
โ โโโโฌโโโโฌโโโโฌโโโ โ
โ โโโโโโโโโ โ โโโโโโโโโโ โ
โ โโโโโโผโโโโ โโโโโโโผโโโโโ โโโโโโผโโโโโ โ
โ โAI Eng. โ โSimulationโ โScoring โ โ
โ โFatigue โ โScenario โ โSafety โ โ
โ โModel โ โGenerator โ โScore โ โ
โ โโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโ โ
โ โ
โ config.js utils.js alerts.js โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Tech Stack
| Technology | Why We Chose It |
|---|---|
| Vanilla JS | Zero build step, instant demo, max portability. Opens from a file. |
| Canvas API | Real-time face visualization at 60fps without DOM overhead |
| Chart.js 4 | Beautiful animated charts with 5 lines of config |
| CSS Glassmorphism | Premium dark theme that wows judges instantly |
| Web Audio API | Alert sounds without loading audio files |
| requestAnimationFrame | Smooth, battery-efficient render loop |
Key Technical Decisions
- Multi-factor fusion over binary detection โ Real fatigue is a spectrum. Our weighted model captures gradients that threshold-based systems miss.
- Predictive regression โ Instead of just reporting current state, we project the fatigue trajectory forward using linear regression on rolling history.
- Circadian rhythm modeling โ Physiological alertness follows a 24-hour curve. Our model factors in time-of-day to correlate with biological fatigue patterns.
- Simulation with realistic noise โ Gaussian noise, smooth sine-based drift, and Box-Muller transforms create data that feels organic, not robotic.
๐ฎ Demo
Running Locally
# No build step needed! Just serve static files:
npx -y serve .
# Then open http://localhost:3000
Controls
- Scenario Selector โ Switch between 4 driving scenarios
- Speed Controls โ 1ร, 2ร, 5ร, 10ร simulation speed
- Pause/Resume โ Freeze the simulation to inspect state
- Reset โ Start the scenario fresh
What to Watch For
- Start with Night Highway at 5ร speed
- Watch the fatigue line climb on the timeline chart
- Notice the face canvas โ eyes start closing, head drifts
- Info alerts appear first, then warnings
- At ~80% fatigue: PULL OVER overlay with urgent audio
- The Safety Score drops from A (green) to F (red) in real-time
- Check the gaze heatmap โ attention scatter increases with fatigue
๐งฉ Challenges
- Making simulated data feel real โ Purely random data looks fake. We used Gaussian noise, Box-Muller transforms, and multi-frequency sine wave composition to create organic physiological patterns.
- Alert fatigue โ Ironic for a fatigue system! We implemented cooldown timers per alert level to prevent notification spam while still catching every real danger.
- Predictive accuracy โ Linear regression is simple but effective on monotone fatigue curves. More complex scenarios (coffee breaks, conversation) required modeling recovery dynamics.
- 60fps Canvas rendering โ Drawing a face + indicators + eyes every frame while updating Chart.js and managing alerts required careful throttling of expensive operations.
๐ Accomplishments
- Full real-time fatigue prediction โ Not just detection, but a 10-minute lookahead
- 5-component weighted AI model running at 60fps with no jank
- Production-quality UI with glassmorphism, micro-animations, and responsive design
- Zero dependencies (except Chart.js CDN) โ opens from any file server
- Realistic simulation engine that models circadian rhythms, microsleeps, coffee breaks, and yawn clustering
- Multi-modal alerts โ visual toasts, feed history, audio chimes, and emergency overlay
๐ What We Learned
- PERCLOS (Percentage of Eye Closure) is the gold standard metric in fatigue research โ we implemented it using a rolling 60-second window
- Circadian rhythms create two daily valleys of alertness: 2โ4 AM and 1โ3 PM โ both are peak crash windows
- Alert design matters as much as detection accuracy โ a system that annoys the driver is a system that gets turned off
- Exponential Moving Averages are surprisingly effective for real-time signal smoothing with minimal computational cost
- Canvas 2D can render surprisingly expressive face visualizations with basic shape primitives
๐ฎ Future Improvements
- Real camera integration โ Replace simulation with MediaPipe Face Mesh for actual driver monitoring via webcam
- openpilot plugin โ Deploy as a companion app that reads openpilot's driver monitoring camera feed
- ML model upgrade โ Train an LSTM on real fatigue datasets (like DROZY or UTA-RLDD) for higher accuracy
- Heart rate variability โ Integrate smartwatch HRV data for cardiovascular fatigue markers
- Fleet management dashboard โ Multi-driver monitoring for commercial trucking companies
- V2X communication โ Share fatigue state with nearby vehicles and infrastructure
- Personalized baselines โ Learn individual driver patterns to customize thresholds
๐ Project Structure
car/
โโโ index.html # Main dashboard (single page)
โโโ README.md # This file
โโโ config/
โ โโโ config.js # All tunable constants
โโโ css/
โ โโโ style.css # Premium dark glassmorphism theme
โโโ js/
โโโ utils.js # Helpers (EMA, noise, color interpolation)
โโโ ai-engine.js # Multi-factor fatigue AI model
โโโ simulation.js # Driving scenario simulator
โโโ scoring.js # Safety score engine (0โ100, AโF)
โโโ alerts.js # 3-tier alert manager + Web Audio
โโโ charts.js # Chart.js timeline + canvas gauge + heatmap
โโโ app.js # Main controller + face renderer
๐ License
MIT License โ Free to use, modify, and distribute.
Because the best safety system is the one that works before you need it.
Log in or sign up for Devpost to join the conversation.