How baaotraan0407/drowsiness-detection works
This repository is a real-time webcam driver-drowsiness detector, with a separate script for training eye-state and yawn CNNs. The user workflow captures video, detects a face, classifies eye and mouth regions, combines temporal signals into a drowsiness score, and presents visual and audio alerts. README documents model/device selection, ROI fallback, scoring, hysteresis, recovery, and optional CSV logging. The main implementation is partly sampled, so documented relationships are cited to README where appropriate.
Main entry points: main.py Webcam application · Train.py CNN trainer
Components 18
Detection runtime
- Webcam application
main.py - Face detector
main.py - Eye/mouth ROIs
main.py - Eye classifier
main.py - Mouth classifier
main.py
Drowsiness analysis
- Mouth temporal features
main.py - PERCLOS and closure
main.py - Drowsiness score
main.py - Alert and recovery
main.py
Model training
- CNN trainer
Train.py - Training datasets
- Trained CNNs
Models and output
- Visual alert
main.py - Audio beep
main.py - CSV logging
main.py - Pretrained models
Other components
- Driver
- Webcam frames
Connections 19
- Driver → Webcam frames: provides video
README.md - Webcam frames → Webcam application: streams frames
main.py - Webcam application → Face detector: processes frames
README.md - Face detector → Eye/mouth ROIs: provides face
README.md - Eye/mouth ROIs → Eye classifier: classifies eyes
README.md - Eye/mouth ROIs → Mouth classifier: classifies mouth
README.md - Mouth classifier → Mouth temporal features: feeds MAR history
README.md - Eye classifier → PERCLOS and closure: updates closure
README.md - Mouth temporal features → Drowsiness score: informs yawn signal
README.md - PERCLOS and closure → Drowsiness score: supplies eye signals
README.md - Drowsiness score → Alert and recovery: drives state
README.md - Webcam application → Visual alert: renders alert
README.md - Alert and recovery → Audio beep: triggers beep
main.py - Webcam application → CSV logging: writes metrics
main.py - Webcam application → Pretrained models: loads models
- Training datasets → CNN trainer: supplies images
Train.py - CNN trainer → Trained CNNs: trains and saves
Train.py - Trained CNNs → Eye classifier: provides eye weights
- Trained CNNs → Mouth classifier: provides mouth weights