Real-Time Driver Monitoring with Computer Vision, Web Dashboard & Arduino Feedback
This system detects driver drowsiness in real-time using computer vision and provides visual + audio + physical alerts using web dashboard & Arduino components.
-
Real-Time Eye & Face Analysis
- Uses MediaPipe Face Mesh + OpenCV
- Detects blinks, microsleep, yawning, head tilt
-
Sleepiness Score Calculation
- Tracks recent eye state to calculate sleep percentage
-
Live Threshold Adjustment
- Press
+/-to adjust EAR threshold - Press
tto save/load presets
- Press
-
Web Dashboard (Flask)
- View live state, graphs, and logs at
http://127.0.0.1:5000
- View live state, graphs, and logs at
-
Arduino Alert System
- 7 LEDs as alert severity meter
- OLED Display (128x32) shows sleep level
- Uses smoothed values (no flickering)
-
Session Summary HTML Report
- Generated automatically on exit
| Component | Requirement |
|---|---|
| Camera | USB / Laptop Webcam |
| Arduino | Uno / Nano |
| OLED Display | SSD1306 128x32 I2C |
| LEDs | 7 LEDs + 330Ω resistors |
| Wires | Male-to-male jumper wires |
Python 3.8+
Arduino IDEpip install -r requirements.txt- Adafruit GFX Library
- Adafruit SSD1306
git clone https://github.com/yourusername/drowsiness-detection-system.git
cd drowsiness-detection-system
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtArduino Pin → Component
2–8 → LEDs (+330Ω → GND)
A4 (SDA) → OLED SDA
A5 (SCL) → OLED SCL
5V → OLED VCC
GND → OLED GND & LED GND
Upload sleep_monitor.ino to Arduino.
python main.pyThis starts:
| File | Function |
|---|---|
sleep_detector.py |
Runs detection + logs state |
app.py |
Web dashboard |
display.py |
Sends data to Arduino |
| Key | Action |
|---|---|
+ / - |
Increase / decrease EAR threshold |
t |
Threshold menu (save/load) |
s |
Toggle alert sound |
q |
Quit & generate HTML report |
C:.
| .gitignore
| main.py
| README.md
| requirements.txt
| sleep_detector.py
| structure.txt
|
+---circuit
| Advance.pdf
|
+---IoT
| | display.py
| |
| \---sleep_moniter
| sleep_moniter.ino
|
+---JSON
| saved_thresholds.json
| sleep_detection_data.json
| state_history.json
|
+---session
| session_summary.html
|
\---web
| app.py
|
+---static
| style.css
|
\---templates
dashboard.html
When you press q:
session_summary_YYYY-MM-DD_HH-MM-SS.html
Includes:
- Duration
- Blinks + microsleep count
- Final sleep percentage
- Timeline visualization
- Recommendations
- Fork repo
- Create branch
- Make improvements
- Submit pull request
Made with ❤️ to help prevent fatigue-related accidents.



