Driver Drowsiness Detector
A real-time computer vision system to detect driver drowsiness and alertness using deep learning.

Overview
The Driver Drowsiness Detector is an AI-powered system designed to reduce road accidents caused by driver fatigue. By analyzing facial landmarks and eye aspect ratios using a webcam feed, the application can accurately determine when a driver is becoming drowsy and trigger visual and audible alerts.
The problem
Drowsy driving is a leading cause of traffic accidents, often resulting from drivers unintentionally falling asleep or losing focus at the wheel. There is a need for an automated, real-time solution to monitor driver alertness and prevent accidents.
The solution
This system leverages deep learning and computer vision to continuously monitor a driver's facial features and eye states. When drowsiness or microsleeps are detected, the application issues immediate alerts, helping to keep drivers attentive and safe.
Features
Real-Time Drowsiness Detection
Monitors driver's eyes and facial features in real time to detect drowsiness or microsleeps.
Eye Aspect Ratio Calculation
Calculates EAR from facial landmarks to determine if eyes are closed for extended periods.
Deep Learning Classification
Uses a trained CNN to distinguish between open and closed eye states, improving detection accuracy.
Immediate Alerts
Triggers visual and audible alarms when drowsiness is detected, warning the driver instantly.
Configurable Thresholds
Allows customization of EAR and time thresholds to adapt to different drivers and environments.
Architecture
The application uses OpenCV to capture and process video frames, MediaPipe for facial landmark detection, and a pre-trained CNN to classify eye states (open or closed). The logic computes the Eye Aspect Ratio (EAR) and triggers alerts when drowsiness is detected. The system is designed for real-time processing and can be deployed on laptops or embedded systems with a webcam.
- OpenCV
- Webcam Capture
- Frame Preprocessing
- MediaPipe
- 68-point Landmark Model
- CNN
- Keras
- TensorFlow
- Eye State Classification
- Visual Alerts
- Audio Alerts
- Threshold Logic
Screenshots












Challenges
Real-Time Performance
Ensuring low-latency video processing and accurate detection required optimization of both the computer vision pipeline and neural network inference.
Robustness to Lighting & Angles
The system needed to work reliably across varying lighting conditions and different driver positions, requiring data augmentation and careful calibration.
Lessons learned
- Combining classical computer vision with deep learning improves reliability for real-world applications.
- Real-time systems must balance accuracy with speed, especially for safety-critical use cases.
- Customizable parameters are essential for adapting AI solutions to diverse environments and users.