A real-time driver monitoring system that detects fatigue, distraction, and drowsiness using Computer Vision, MediaPipe Face Mesh, and a CNN-LSTM deep learning model.
Driver fatigue is one of the leading causes of road accidents worldwide. Traditional driver monitoring systems often rely on a single indicator such as eye closure, making them susceptible to false positives.
DrowsiGuard addresses this challenge by combining multiple physiological and behavioral indicators to provide more reliable driver state detection.
The system continuously analyzes:
- ๐๏ธ Eye closure
- ๐ฎ Yawning
- โ Head movement
- ๐ง CNN-LSTM temporal prediction
These signals are fused to classify the driver's condition and generate timely alerts before fatigue becomes dangerous.
- ๐ Real-time driver monitoring
- ๐ง CNN-LSTM temporal deep learning model
- ๐๏ธ MediaPipe Face Mesh based facial landmark detection
- ๐ด Multi-feature decision fusion
- ๐ฆ Four-stage driver state classification
- ๐ Intelligent alert generation
- โก Low-latency webcam inference
- Real-time webcam monitoring
- Eye Aspect Ratio (EAR) based eye closure detection
- Mouth Aspect Ratio (MAR) based yawning detection
- Head Yaw Angle estimation
- CNN-LSTM based temporal drowsiness prediction
- Driver distraction detection
- Multi-stage driver state classification
- Intelligent alert system
The following screenshots demonstrate the different driver states detected by DrowsiGuard.
| ๐ข Alert / Vigilant | ๐ก Slightly Drowsy |
|---|---|
![]() |
![]() |
| ๐ Distracted | ๐ด Critical Drowsy |
|---|---|
![]() |
![]() |
| Category | Technologies |
|---|---|
| Programming Language | Python |
| Deep Learning | TensorFlow, Keras |
| Computer Vision | OpenCV |
| Facial Landmark Detection | MediaPipe Face Mesh |
| Numerical Computing | NumPy |
| Visualization | Matplotlib |
| Development Environment | Jupyter Notebook |
DrowsiGuard/
โ
โโโ model/
โ โโโ cnn_lstm_model.py
โ โโโ drowsiguard_cnn_lstm.h5
โ
โโโ notebooks/
โ โโโ data_preprocessing.ipynb
โ โโโ model_training_log.ipynb
โ
โโโ screenshots/
โ โโโ alert_vigilant.jpg
โ โโโ slightly_drowsy.jpg
โ โโโ distracted.jpg
โ โโโ critical_drowsy.jpeg
โ
โโโ src/
โ โโโ alerts.py
โ โโโ create_placeholder_data.py
โ โโโ drowsiness_logic.py
โ โโโ feature_functions.py
โ โโโ tracking_module.py
โ
โโโ .gitignore
โโโ LICENSE
โโโ README.md
โโโ requirements.txt
git clone https://github.com/mik07005/DrowsiGuard.git
cd DrowsiGuardpython -m venv venv
venv\Scripts\activatepython3 -m venv venv
source venv/bin/activatepip install -r requirements.txtThe training datasets are not included in this repository because of licensing restrictions and repository size limitations.
Datasets used during development:
- Closed Eyes in the Wild (CEW)
- YawDD (Yawning Detection Dataset)
| Metric | Value |
|---|---|
| Closed Eye Images | 1500 |
| Open Eye Images | 1500 |
| Total Processed Images | 3000 |
| Temporal Sequences Generated | 2971 |
| Sequence Length | 30 Frames |
DrowsiGuard uses a hybrid CNN-LSTM architecture for temporal driver drowsiness detection.
The CNN extracts spatial features from consecutive eye images, while the LSTM learns temporal eye movement patterns across multiple frames to distinguish between alert and drowsy states.
| Parameter | Value |
|---|---|
| Sequence Length | 30 Frames |
| Image Resolution | 64 ร 64 |
| Channels | 1 (Grayscale) |
| Model | CNN-LSTM |
python src/tracking_module.pyThe webcam will automatically start and begin monitoring the driver's state.
flowchart TD
A[Webcam Input]
B[MediaPipe Face Mesh]
C[Extract Facial Landmarks]
D[EAR โข MAR โข Head Pose]
E[CNN-LSTM Model]
F[Decision Fusion]
G[Driver State]
H[Audio Alert]
A --> B
B --> C
C --> D
D --> E
E --> F
F --> G
G --> H
The system continuously monitors multiple physiological and behavioral indicators.
| Parameter | Purpose |
|---|---|
| ๐๏ธ Eye Aspect Ratio (EAR) | Detect prolonged eye closure |
| ๐ฎ Mouth Aspect Ratio (MAR) | Detect yawning |
| โ Head Yaw Angle | Detect driver distraction |
| ๐ง CNN-LSTM Probability | Predict temporal drowsiness |
| ๐จ Decision Fusion | Combine all features for final prediction |
| Metric | Value |
|---|---|
| Training Accuracy | 98.95% |
| Best Validation Accuracy | 99.33% |
| Validation Loss | 0.0384 |
| Training Epochs | 50 |
| Input Resolution | 64 ร 64 |
| Sequence Length | 30 Frames |
| State | Description |
|---|---|
| ๐ข Alert / Vigilant | Driver is attentive and no fatigue is detected. |
| ๐ก Slightly Drowsy | Early signs of fatigue are detected. |
| ๐ Distracted | Driver is looking away or appears distracted. |
| ๐ด Critical Drowsy | High-confidence drowsiness detected and immediate alert triggered. |
Unlike conventional driver monitoring systems that rely on a single fatigue indicator, DrowsiGuard combines multiple complementary features to improve reliability.
The system fuses:
- ๐๏ธ Eye Aspect Ratio (EAR)
- ๐ฎ Mouth Aspect Ratio (MAR)
- โ Head Pose Estimation
- ๐ง CNN-LSTM Temporal Prediction
These signals are combined using a multi-feature decision fusion strategy to classify four driver states and trigger alerts only when necessary, reducing false alarms.
- Raspberry Pi deployment
- Infrared camera support
- Mobile application integration
- Cloud dashboard
- Driver fatigue analytics
- Night-time performance optimization
- Multi-driver support
Contributions are welcome.
-
Fork the repository.
-
Create a feature branch.
git checkout -b feature-name- Commit your changes.
git commit -m "Add new feature"- Push the branch.
git push origin feature-name- Open a Pull Request.
This project is licensed under the MIT License.
See the LICENSE file for more details.
Mohammed Intekhab Khan
B.Tech Computer Science & Engineering (Artificial Intelligence & Machine Learning)
VIT-AP University
GitHub: https://github.com/mik07005



