It is a real time driver monitoring system that uses facial landmark detection to identify signs of drowsiness, yawning and distraction(head tilt). It avoids accidents on road as it triggers visual alerts.
Pre requisites- Python 3.8 or higher, pip, a webcam Clone the repository Create a virtual environment Install dependencies
When the eye is open EAR approx 0.30+. When it closes EAR drops to 0. So if EAR stays below 0.22 for 20+ frames consecutively a drowsiness alert is triggered. if MAR exceeds 0.6 yawn is detected The angle between the nose tip and chin landmarks is computed. If the angle exceeds 25 degrees a head tilt warning is fired.
Most drowsiness detectors only track eye closure. This system tracks three signals simultaneously:
- Eye closure — Eye Aspect Ratio (EAR) with a 20-frame temporal filter to eliminate false alarms from normal blinks
- Yawning — Mouth Aspect Ratio (MAR) detects early fatigue signs
- Head tilt — Geometric angle between nose and chin landmarks flags distraction or phone use
Built with MediaPipe (no external model files needed) instead of dlib — faster, lighter, works on CPU at 30+ FPS.
OpenCV MediaPipe NumPy
press Q on the video window