The Driver Monitoring System is a real-time AI-based application that detects driver drowsiness and yawning using computer vision techniques. It leverages OpenCV, Dlib, and Flask to process video feeds and provide visual and auditory alerts when signs of fatigue are detected.
- Eye Aspect Ratio (EAR) Calculation: Detects drowsiness by monitoring the eye-blinking rate.
- Lip Distance Measurement: Identifies yawning based on mouth opening.
- Live Video Streaming: Integrates with Flask for real-time web-based monitoring.
- Alert System: Displays visual alerts when drowsiness or yawning is detected.
Ensure you have the following dependencies installed:
- Python 3.8+
- OpenCV
- Dlib
- imutils
- Flask
- NumPy
- SciPy
- Clone the repository:
git clone https://github.com/your-repo/driver-monitoring.git cd driver-monitoring - Install dependencies:
pip install -r requirements.txt
- Download the required dlib facial landmark model:
wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2 bzip2 -d shape_predictor_68_face_landmarks.dat.bz2
- Start the Flask server:
python app.py
- Open a browser and visit:
http://127.0.0.1:5000/ - The web interface will display the live video feed and issue alerts if drowsiness or yawning is detected.
Modify thresholds in config.py:
EYE_AR_THRESH(default:0.27): Eye aspect ratio threshold for drowsiness detection.EYE_AR_CONSEC_FRAMES(default:17): Number of frames before drowsiness alert.YAWN_THRESH(default:20): Lip distance threshold for yawning detection.YAWN_CONSEC_FRAMES(default:7): Number of frames before yawning alert.
/driver-monitoring
│── app.py # Main application script
│── requirements.txt # List of dependencies
│── shape_predictor_68_face_landmarks.dat # Dlib model
│── templates/
│ └── index.html # Web interface template
│── static/
│ └── style.css # Stylesheet (optional)
│── config.py # Configuration parameters
│── README.md # Project Documentation
Install dependencies using:
pip install -r requirements.txtOr install manually:
pip install opencv-python dlib imutils flask numpy scipyDownload the 68-face landmark model:
wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
bzip2 -d shape_predictor_68_face_landmarks.dat.bz2Place this file in the project directory.
git clone https://github.com/your-repo/driver-monitoring.git
cd driver-monitoringpython app.pyOpen your browser and go to:
http://127.0.0.1:5000/
Modify config.py to adjust thresholds:
class Config:
EYE_AR_THRESH = 0.27 # Eye Aspect Ratio Threshold
EYE_AR_CONSEC_FRAMES = 17 # Consecutive Frames for Drowsiness
YAWN_THRESH = 20 # Lip Distance Threshold for Yawning
YAWN_CONSEC_FRAMES = 7 # Consecutive Frames for Yawning- No Video Feed? Ensure your webcam is connected.
- Dlib Model Not Found? Download and place
shape_predictor_68_face_landmarks.datin the project folder. - Errors in Flask? Ensure Flask is installed and running on Python 3.8+.
- Sound Alerts for drowsiness detection.
- Mobile App Integration for remote monitoring.
- Better Performance Optimization for real-time processing.
- OpenCV for real-time video processing.
- Dlib for facial landmark detection.
- SciPy for Euclidean distance calculation.