This project implements a real-time drowsy driver detection system using computer vision and deep learning. The system monitors drivers through a webcam and alerts them when signs of drowsiness are detected, helping prevent accidents caused by fatigue while driving.
- Real-time face detection and tracking
- Eye state monitoring (open/closed)
- Yawning detection
- Multiple alert scenarios
- Works in various lighting conditions
- Support for non-frontal face angles
The drowsiness detection system is trained using the Drowsiness Detection Dataset from Kaggle (link). This dataset includes images of open/closed eyes and yawning/non-yawning mouths. It consists of 11,566 images divided into train, validation, and test sets.
The eye state detection model is trained to classify eyes as either open or closed.
Figure 1: Training and validation accuracy/loss curves for eye detection model
Figure 2: Confusion matrix showing eye detection model performance
The mouth state detection model is trained to detect yawning.
Figure 3: Training and validation accuracy/loss curves for mouth detection model
Figure 4: Confusion matrix showing mouth detection model performance
- Python 3.9 or higher
- Webcam
- Clone the repository:
git clone https://github.com/hoangtung386/Drowsy-Driver-Detection-System.git
cd Drowsy-Driver-Detection-System
- Install required packages:
pip install -r requirements.txt
-
Download Required Model Files:
- Download the following model files from this Google Drive link:
simple_CNN_eye_modelV6_3.keras
simple_CNN_mouth_modelV6_3.keras
- After downloading, move both model files (
.keras
files) into theModels
folder.
- Download the following model files from this Google Drive link:
-
The face landmark predictor has been preloaded and placed in the Models folder:
shape_predictor_68_face_landmarks.dat
To run the detection script, please navigate to the Source code
directory first:
cd Source_code
python detection.py
-
Yawning with Closed Eyes
- Triggers a 5-second alarm at 70% volume
- Indicates severe drowsiness
-
Prolonged Eye Closure
- Triggers when eyes remain closed for 3 seconds
- Alarm at 100% volume until eyes reopen
- Prevents microsleep episodes
-
Face Not Visible/Not Forward-Facing
- Triggers alarm at 70% volume
- Ensures driver maintains proper attention
Figure 5: System detecting normal state
Figure 6: System detecting drowsiness state
Figure 7: System detecting sleep state
Figure 8: Face not detected - When distracted looking in another direction
- CLAHE (Contrast Limited Adaptive Histogram Equalization) for enhanced contrast
- Grayscale conversion
- Resolution standardization (128x128 for eyes, 256x256 for mouth)
- Uses dlib's facial landmark detector
- 68 facial landmarks for precise feature localization
- Robust to various head poses and lighting conditions
-
Eye State Detection:
- High accuracy in varying light conditions
- Real-time processing capability
- Robust to different eye shapes
-
Mouth State Detection:
- Accurate yawn detection
- Low false positive rate
- Handles partial occlusions
- Integration with vehicle systems
- Support for infrared cameras for nighttime operation
- Driver attention scoring system
- Machine learning model optimization for embedded systems
- Multiple camera angle support
- Cloud connectivity for fleet management
This project is licensed under the MIT License
- dlib community for facial landmark detection
- TensorFlow team for the deep learning framework
- OpenCV community for computer vision tools
For any queries regarding this project, please contact:
Email: levuhoangtung1542003@gmail.com