Driver drowsiness is a major road safety challenge in India, where long-distance travel, night driving, and fatigue contribute to preventable accidents on highways and urban roads. DrowseGuard addresses this issue with a real-time computer vision system that monitors eye closure and mouth opening patterns from a live webcam feed, detects drowsiness risk early, and provides immediate alerts to improve driver awareness and reduce crash probability.
- Real-time EAR and MAR computation using MediaPipe facial landmarks
- Dual classifier inference with KNN and Gaussian Naive Bayes ensemble
- Audio alert subsystem with file-based alarm and generated fallback beep
- Multi-stage preprocessing pipeline visualization for interpretability
- Interactive Streamlit dashboard with live metrics and controls
| Module name | Specific functions |
|---|---|
| Module 1: Image Fundamentals and Enhancement | preprocessor.preprocess_frame(), preprocessor.apply_clahe(), preprocessor.detect_night_mode() |
| Module 2: Feature Extraction and Representation | feature_extractor.extract_hog_features(), feature_extractor.extract_combined_features() |
| Module 3: Segmentation, Edges, and Morphology | preprocessor.apply_canny_edges(), preprocessor.segment_eye_binary(), preprocessor.apply_morphological_ops() |
| Module 4: Statistical Inference and Temporal Metrics | perclos_engine.PerclosEngine.compute(), fatigue_scorer.FatigueScorer.compute(), eye_analyzer.EyeStateTracker.get_blink_rate_per_min() |
| Module 5: Detection and ML Integration | face_detector.FaceDetector.detect(), head_pose.HeadPoseEstimator.estimate(), classifier.EyeStateClassifier.fit() with sklearn.decomposition.PCA |
PERCLOS is computed as the fraction of closed-eye frames in a rolling window:
EAR is computed from six eye landmarks:
Fatigue score is a weighted composite:
- Clone the repository.
git clone https://github.com/your-username/drowseguard.git- Move into the project folder.
cd drowseguard- Install dependencies.
pip install -r requirements.txt- Run the application.
python main.pyUse the Live detection page for real-time inference, calibration, and alerts. Use the Session analytics page to inspect historical metrics, events, and snapshots from previous runs.
Each run is stored under sessions/<session_id>/ with events.csv, metrics.csv, and a snapshots/ folder containing saved critical frames.
| Layer | Technology |
|---|---|
| Language | Python 3.10+ |
| Computer Vision | OpenCV, MediaPipe |
| Numerical Computing | NumPy, SciPy |
| Machine Learning | scikit-learn, PCA |
| UI and Analytics | Streamlit, Plotly, pandas |
| Alerts and Persistence | pygame, CSV logging, JPEG snapshots |
Garv Anand