A real-time Driver Drowsiness Detection System developed using Python and OpenCV. This project detects driver fatigue by monitoring eye closure and facial features through a live camera feed. If drowsiness is detected for a sustained period, the system raises an alert to help prevent road accidents.
Driver fatigue is one of the major causes of road accidents. This project aims to:
- Detect driver drowsiness in real time
- Alert the driver before a dangerous situation occurs
- Provide a lightweight and extendable computer vision solution
- Real-time face and eye detection
- Live webcam-based monitoring
- Raspberry Pi camera support
- Uses Haar Cascade classifiers
- Modular Python codebase
- Can be extended with alarms, buzzers, or notifications
- Captures live video frames from a webcam or Pi camera
- Detects the driver's face using Haar Cascade classifier
- Detects eyes within the face region
- Determines eye state (open / closed)
- Tracks duration of eye closure
- If eyes remain closed beyond a threshold, drowsiness is detected
- An alert can be triggered to warn the driver
DriverDrowsiness/
│
├── haarcascade_eye.xml
├── haarcascade_frontalface_default.xml
├── live_detect.py
├── liveDetectionPi.py
├── model.py
├── preprocessing.py
├── testing.py
├── model.zip
└── README.md
-
haarcascade_eye.xml Haar Cascade classifier for eye detection
-
haarcascade_frontalface_default.xml Haar Cascade classifier for face detection
-
live_detect.py Main script for real-time drowsiness detection using a webcam
-
liveDetectionPi.py Detection script designed for Raspberry Pi camera
-
model.py Loads and manages the trained model
-
preprocessing.py Handles image preprocessing and feature extraction
-
testing.py Used for testing the detection logic
-
model.zip Pre-trained model (extract before running)
- Python 3.7 or higher
- Webcam or Raspberry Pi Camera
pip install opencv-python numpy tensorflow keraspython live_detect.pypython liveDetectionPi.pyMake sure the Haar cascade XML files and extracted model files are in the same directory.
- Ensure proper lighting for accurate detection
- Camera should clearly capture the driver's face
- Sensitivity and thresholds can be tuned in the code
- Add sound or buzzer alerts
- Integrate deep learning–based eye landmark detection
- Add performance metrics (accuracy, FPS)
- Build a dashboard for monitoring driver alertness
This project is open-source and free to use for educational and research purposes.
Pranav Nagaraji Driver Drowsiness Detection Project