A high-performance, real-time computer vision project designed to enhance road safety through Driver Drowsiness Detection and Vehicle Traffic Analysis.
- Real-time Drowsiness Detection: Monitors Eye Aspect Ratio (EAR) and triggers an alarm if fatigue is detected.
- Aural Alerts: Immediate beep sound notification when eyes stay closed for too long.
- Vehicle Counter: Robust traffic analysis counting vehicles crossing a detection line.
- User-Friendly Interface: Real-time feedback with intuitive UI overlays and easy exit options.
- Python 3.8 or higher
- A working webcam (for drowsiness detection)
# Install dependencies
pip install -r requirements.txtTip
Windows Users: If you face issues installing dlib, we have pre-configured the project to use dlib-bin, which installs instantly without requiring complex C++ build tools.
Monitor alertness in real-time using your webcam.
python dds.py- How it works: If your eyes stay closed for ~1 second, a "DROWSY ALERT!" appears and a beep sounds.
Analyze traffic from the included video file.
python vehicle.py- How it works: Increments the counter every time a vehicle crosses the horizontal detection line.
Each application window can be closed using any of the following methods:
- Keyboard Shortcuts:
- Press
qto quit immediately. - Press
ESCto exit. - Press
Enter(specifically in the Vehicle Counter).
- Press
- Mouse Control:
- Click the Red "X" Button on the top-right of the window.
- Terminal Shutdown:
- If you need to force-stop the script from the command line, press
Ctrl + Cin your terminal.
- If you need to force-stop the script from the command line, press
The drowsiness system calculates the Eye Aspect Ratio (EAR) using 6 facial landmarks per eye.
- Threshold:
0.25 - Consecutive Frames:
20(triggers alarm if eyes are closed for 20 frames).
dds.py: Main Drowsiness Detection script.vehicle.py: Traffic Analysis & Vehicle Counting script.face_detection_demo.py: Simple Haar Cascade face detection test.shape_predictor_68_face_landmarks.dat: Pre-trained dlib landmark model.requirements.txt: Python package dependencies.
This project is licensed under the MIT License.