A real-time computer vision system that detects driver drowsiness using facial landmark analysis and triggers an audible alert to help prevent fatigue-related accidents.
Driver fatigue is a major cause of road accidents.
Drive Alarm monitors the driver's eye state using a webcam and calculates the Eye Aspect Ratio (EAR) to determine drowsiness. If the eyes remain closed for a defined duration, an alarm is triggered.
This project demonstrates:
- Real-time computer vision
- Facial landmark detection (dlib)
- Geometric eye state analysis
- Alert-based safety system implementation
- Real-time face and eye detection
- Eye Aspect Ratio (EAR) calculation
- Frame-based drowsiness threshold detection
- Audible alert system
- Live EAR display on video feed
- Python
- OpenCV
- dlib
- NumPy
- SciPy
- Pygame
Drive_alarm/
│
├── project 2.py
├── project 3.py
├── requirements.txt
├── .gitignore
└── assets/
├── beep.mp3
└── shape_predictor_68_face_landmarks.dat (not included in repo)
git clone https://github.com/AdityaSharma-Git3207/Sleep-Detector-Program.git
cd Sleep-Detector-Programpython -m venv venv
venv\Scripts\activatepip install -r requirements.txtNote:
dlibinstallation may require Visual Studio Build Tools on Windows.
This project requires the pre-trained dlib facial landmark predictor model.
Due to its large size (~100MB), it is not included in this repository.
-
Download from:
http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2 -
Extract the
.bz2file -
Place the extracted file inside:
assets/
Final structure should look like:
assets/shape_predictor_68_face_landmarks.dat
python "project 2.py"Press q to quit the application.
The system calculates the Eye Aspect Ratio (EAR) using facial landmarks.
- Eyes are considered closed when:
EAR < 0.25
- If eyes remain closed for:
20 consecutive frames
The alarm is triggered.
The following files are intentionally excluded:
venv/→ Virtual environment directoryassets/shape_predictor_68_face_landmarks.dat→ Large binary model file
This keeps the repository lightweight and maintainable.
- Blink rate monitoring
- Head pose estimation
- Performance optimization
- GUI interface
- Mobile device integration
Aditya Sharma
Open Source Contributor | Computer Vision Enthusiast