A real-time driver drowsiness detection system built using Computer Vision that monitors the driver's face through a webcam and triggers an audio-visual alert when signs of drowsiness are detected.
Drowsy driving is one of the leading causes of road accidents worldwide. This system continuously monitors the driver and alerts them before a dangerous situation occurs.
The system uses three signals combined together (multi-signal fusion) to detect drowsiness:
- EAR (Eye Aspect Ratio) detects eye closure and slow drooping
- MAR (Mouth Aspect Ratio) detects yawning
- Head Pose Estimation detects head drooping forward
A single signal alone does not trigger the alarm, the system is smart enough to avoid false alarms from blinking, laughing, talking to passengers, or looking at the dashboard.
- Python 3.11
- OpenCV
- MediaPipe
- NumPy
- SciPy
- Pygame
- Real-time face, eye, and mouth tracking
- Multi-signal fusion to minimize false alarms
- Audio alarm when drowsiness detected
- Visual HUD overlay with live EAR, MAR, and head angle
- Pause/Resume detector with P key
- Automatic session logging with timestamps
1. Install dependencies:
pip install opencv-python mediapipe numpy scipy pygame2. Place alarm.wav in the same folder as detector.py
3. Run the detector:
python detector.pyControls:
| Key | Action |
|---|---|
P |
Pause / Resume |
Q |
Quit |