This project is an advanced real-time computer vision framework designed to mitigate highway transit accidents caused by operator exhaustion and micro-sleep events [AnshumanSrivastava108/Real-Time-Drowsiness-Detection-System].
By processing live camera frames, the system maps facial telemetry landmarks using spatial equations to calculate eye and mouth ratios, instantly executing audio alarms when safety limits are breached.
AWAKE, DROWSY (WARNING), or DROWSY (CRITICAL!)).BGR: 0, 255, 0) draw clean outlines around ocular and labial zones for optimal low-light tracking [AnshumanSrivastava108/Real-Time-Drowsiness-Detection-System].driver_drowsiness_detection/
│
├── models/
│ └── shape_predictor_68_face_landmarks.dat # Neural network weights database
│
├── utils/
│ ├── __init__.py
│ └── metrics.py # Formulas file (EAR & MAR math)
│
├── config.py # Calibration thresholds hub
├── main.py # Central camera loops engine
├── requirements.txt # Software dependencies list
└── drowsiness_logs.txt # Automated telemetry data file
The core analytical loops rely on scaling-invariant mathematical fractions, guaranteeing accurate processing regardless of how close or far the driver sits from the lens.
Calculates horizontal and vertical eyelids vectors: [\text{EAR} = \frac{\vert{}\vert{}p_2 - p_6\vert{}\vert{} + \vert{}\vert{}p_3 - p_5\vert{}\vert{}}{2 \vert{}\vert{}p_1 - p_4\vert{}\vert{}}]
🟢 STATUS: AWAKE → EAR ≥ 0.25🟠 STATUS: DROWSY (WARNING) → EAR < 0.25 (Triggers soft loop after 10 frames)🔴 STATUS: DROWSY (CRITICAL!) → EAR < 0.25 (Triggers double-beep sirens after 20 frames)Calculates inner lip dilation layouts during active driving shifts: [\text{MAR} = \frac{\vert{}\vert{}p_{51} - p_{59}\vert{}\vert{} + \vert{}\vert{}p_{53} - p_{57}\vert{}\vert{}}{2 \vert{}\vert{}p_{49} - p_{55}\vert{}\vert{}}]
🟠 STATUS: YAWNING DETECTED → MAR > 0.60 (Triggers cooldown logging after 15 frames)drowsiness_logs.txt)The system appends clean chronological records automatically during active run states:
[2026-07-21 14:30:05] SYSTEM START: Safety monitoring initialized.
[2026-07-21 14:32:14] ALERT: Driver was Drowsy - Duration: 2.45 seconds
[2026-07-21 14:35:40] NOTICE: Yawn Pattern Logged
[2026-07-21 14:40:12] SYSTEM SHUTDOWN: Monitoring ended cleanly.
Deploy all mandatory dependencies into your localized sandbox environment by running:
pip install -r requirements.txt
shape_predictor_68_face_landmarks.dat inside your models/ directory.Initialize the central driver dashboard panel loop using your terminal interface:
python main.py
q: Safely stops camera input channels, flushes file writing streams, terminates background threads, and kills display windows cleanly.Artificial Intelligence & Machine Learning (AI/ML) Student