Driver Drowsiness Detection using Computer Vision & ML
Learn how to build a real-time driver drowsiness detection system using Mediapipe, Eye Aspect Ratio (EAR), and Python for improved road safety.
A Mini Project Report
DRIVER DROWSINESS DETECTION
USING COMPUTER VISION
Department of Computer Science & Engineering
Barak Valley Engineering College
(Affiliated to ASTU, Approved by AICTE)
Nirala, Sribhumi, Assam - 788701
May 2026
STATUS: ACTIVE
Baharul Islam | Bhaskar Sha | Bongso Hanse | Hafizur Rahman | Md. Dilshan Ul Hassan Choudhury
TABLE OF CONTENTS
02
Introduction
Need of Machine Learning
Literature Survey
Existing Technology
Problem Statement
Objectives
Requirement Analysis
Data Flow Diagram
Use Case Diagram
Methodology
Eye Aspect Ratio (EAR)
Classification Model
Dataset Description
Experimental Setup
Results & Discussion
Performance Evaluation
Limitations
Conclusion
Future Scope
References
03
INTRODUCTION
Road accidents are a major global concern — driver drowsiness is a leading cause.
Fatigue, lack of sleep, and long driving hours reduce alertness and reaction time.
Traditional vehicle safety systems monitor external conditions only (braking, collision avoidance) — NOT the driver's internal state.
Need for intelligent real-time systems to detect early signs of drowsiness.
This project proposes a Driver Drowsiness Detection System using Computer Vision and Machine Learning.
Core technique: Eye Aspect Ratio (EAR) computed via Mediapipe Face Mesh facial landmarks.
Lightweight, real-time, cost-effective — no GPU required.
~20%
of fatal accidents caused by drowsy driving
04
NEED OF MACHINE LEARNING
Feature Extraction
EAR converts visual data into numerical form for analysis
Binary Classification
Classifies driver as Alert (0) or Drowsy (1)
Decision Boundary
EAR < 0.21 threshold acts as ML decision boundary
Temporal Analysis
Frame count distinguishes blinking from drowsiness
Scalability
Extendable to SVM, Logistic Regression, CNN models
ML enables adaptability across different users, lighting, and driving conditions.
05
LITERATURE SURVEY
Paper 1
Real-Time Eye Blink Detection using Facial Landmarks
Introduces EAR concept. EAR remains constant when eyes open, drops when closed. Efficient for real-time use.
Paper 2
Driver Drowsiness Detection Using Computer Vision
Uses OpenCV webcam-based eye tracking. Non-intrusive, cost-effective.
Paper 3
Drowsy Driver Detection Using ML
SVM and neural networks for classification. High accuracy but needs large datasets.
Paper 4
Real-Time Fatigue Detection Using Mediapipe
Mediapipe Face Mesh for accurate landmarks. Faster than Haar cascades.
Paper 5
Vision-Based Driver Monitoring System
Combines eye detection + head movement. Multi-feature reduces false detection.
06
EXISTING TECHNOLOGY
OpenCV
Open Source Computer Vision Library
Lightweight • Cross-platform • Python-ready
Mediapipe Face Mesh
Google's Real-Time Perception Framework
Accurate • Fast • Cross-platform
ML Techniques
Classification & Feature Analysis
Scalable • Adaptable • Efficient
07
PROBLEM STATEMENT
Most vehicle safety systems monitor roads, NOT the driver.
Lack of Real-Time Monitoring
Traditional systems don't continuously track driver alertness.
Inability to Detect Early Signs
Subtle behavioral changes like slow blinking go undetected.
High Cost of Advanced Systems
Infrared/EEG-based solutions are expensive, limited to premium vehicles.
Dependency on Manual Observation
Drivers may not recognize their own fatigue.
Limited Adaptability & Accuracy
Fixed rules fail across users, lighting, and environments.
No Lightweight Real-Time Solutions
Deep learning models need powerful hardware, impractical for real-time use.
This project addresses all the above challenges with a lightweight, real-time, cost-effective CV-based solution.
08
OBJECTIVES OF THE PROJECT
01 — Real-Time Detection
Develop a real-time drowsiness detection system using webcam input.
02 — ML Classification
Apply Machine Learning concepts for binary classification (Alert / Drowsy).
03 — Eye Closure via EAR
Detect eye closure using Eye Aspect Ratio (EAR) feature extraction.
04 — Instant Audio Alert
Trigger immediate sound alarm (Pygame) when drowsiness is detected.
05 — Low-Cost Solution
Create a lightweight system deployable on standard CPU hardware.
Under the Guidance of: Mr. Swmdwm Basumatary, Asst. Professor, Dept. of CSE, BVEC
10
DATA FLOW DIAGRAM (DFD)
Level 0 — Context Diagram
Driver
Facial video (webcam)
Drowsiness Detection
System
Drowsiness alert
Alert Output
Level 1 — Detailed Flow
Driver
— Live video stream
P1:
Webcam Input & Frame Capture
— Continuous frame extraction
P2:
Face Detection (Mediapipe)
— Facial landmark localization
P3:
Eye Landmark Extraction
— 6 eye region points per eye
P4:
EAR Calculation
— Eye openness ratio
P5:
ML Classification
— Drowsy vs Alert decision
Alert Trigger
— Alarm/buzzer
Normal State
— Continue monitoring
USE CASE DIAGRAM
DETAILED METHODOLOGY
Data Acquisition
Webcam captures live video
Frame-by-frame real-time extraction
Non-intrusive, continuous
Feature Extraction
Mediapipe detects 468 facial landmarks
Eye region coordinates extracted
EAR computed (6 points per eye)
Feature Processing
EAR compared to threshold (0.21)
Frame counter incremented/reset
Noise filtered (blink vs drowsiness)
Classification
Rule-based ML binary classifier
EAR < 0.21 AND frames > 30 → Drowsy
Otherwise → Alert
Output & Alert
Audio alarm via Pygame
Visual warning on screen
System continues monitoring
EYE ASPECT RATIO (EAR)
What is EAR?
EAR measures eye openness using 6 facial landmark points per eye.
EAR Threshold Visualization
CLASSIFICATION MODEL
Rule-Based ML Classifier
Binary classification using EAR + frame count as features
DROWSY
ALERT
Binary Classes
0 = ALERT
— Eyes open, normal
1 = DROWSY
— Prolonged eye closure
Temporal Analysis
Normal blink: EAR drops briefly → counter resets
Drowsiness: EAR stays low > 30 frames → alert triggered
Frame counter prevents false positives
EAR Value Computed
Increment Frame Counter
Reset Frame Counter
TRIGGER ALERT
Drowsy
Continue Monitoring
15
DATASET & EXPERIMENTAL SETUP
Dataset Description
No predefined dataset used — real-time dynamic data from webcam.
Primary Feature: EAR (Eye Aspect Ratio) computed per frame
Frame No.
EAR Value
Frame Count
State
Data generated dynamically — no storage needed → lightweight system
Experimental Setup
Python 3.x — Core Programming Language
OpenCV — Video capture & image processing
Mediapipe — Face mesh landmark detection
NumPy — Numerical computations
Pygame — Audio alert system
Standard CPU — No GPU required
Webcam — Real-time video input
20–30 FPS processing speed
16
RESULTS & DISCUSSION
Case 1: Alert State
Eyes Fully Open
0.32
Frame Count: 0
✅ GREEN ALERT — No action taken
System continues monitoring
Case 2: Normal Blink
Brief Eye Closure
0.18
Frame Count: 3 (low)
🟡 AMBER TRANSITION — No false alert
Counter resets — blink detected correctly
Case 3: Drowsy State
Prolonged Eye Closure
0.16
Frame Count: 32+
🔴 RED DROWSY — Alert Triggered!
Audio alarm activated immediately
System accurately distinguishes blinking from drowsiness with real-time alert response.
17
PERFORMANCE EVALUATION
Confusion Matrix
Accuracy = (TP + TN) / Total = (45+46)/100 ≈ 91%
91% ACCURACY
High precision & recall confirm system reliability for real-time drowsiness detection.
18
LIMITATIONS
Poor Lighting Conditions
Performance degrades in very low-light or high-glare environments. Infrared cameras needed for night use.
Face Detection Dependency
System requires clear face visibility. Accuracy drops with masks, head turns, or occlusions.
Fixed EAR Threshold
Single threshold (0.21) may not suit all users due to variations in eye size and structure.
Single Feature Reliance
Only EAR used; head nod, yawning, and other fatigue signs not detected.
No Hardware Integration
Currently software-only; not yet embedded in vehicle systems.
Rule-Based Approach
Simple threshold logic; no adaptive learning to individual user patterns.
These limitations guide the path toward future improvements and advanced ML integration.
19
CONCLUSION
Successfully developed a real-time Driver Drowsiness Detection System
Eye Aspect Ratio (EAR) proved effective as the primary detection feature
Mediapipe Face Mesh provides accurate, fast facial landmark detection
Lightweight ML approach achieves ~91% accuracy without GPU
Instant audio alert via Pygame ensures timely driver notification
System operates on standard CPU hardware — cost-effective & accessible
This project demonstrates that Computer Vision and AI can significantly enhance road safety by detecting driver fatigue in real time.
91%
20–30 FPS
Standard CPU
Webcam
Audio (Pygame)
Mediapipe + OpenCV
FUTURE SCOPE
Deep Learning Integration
Implement CNN models to analyze facial images directly for improved accuracy under challenging conditions.
Large-Scale Dataset Training
Collect diverse user datasets for training adaptive ML models.
Vehicle Integration
Embed system into vehicle dashboards with OBD integration and real hardware alerts.
Infrared / Night Vision
Add infrared camera support for reliable performance in low-light and nighttime conditions.
Mobile Application
Develop portable app for smartphones to make system widely accessible.
Multi-Feature Detection
Include head nodding, yawning detection, and heart rate monitoring for comprehensive fatigue analysis.
Rule-Based → SVM/Logistic Regression → CNN → Multi-Modal Deep Learning System
21
REFERENCES
[1]
Soukupova & Cech (2016)
Real-Time Eye Blink Detection using Facial Landmarks
CVWW 2016
[2]
Viola & Jones (2001)
Rapid Object Detection using Boosted Cascade of Simple Features
CVPR 2001
[3]
Lugaresi et al. (2019)
MediaPipe: A Framework for Building Perception Pipelines
Google Research
[4]
Bradski (2000)
The OpenCV Library
Dr. Dobb's Journal of Software Tools
[5]
Ngxande et al. (2017)
Driver Drowsiness Detection Using Behavioral Measures
IEEE ROBMECH 2017
[6]
Zhang et al. (2020)
Drowsiness Detection with EAR using CNN
IEEE Access
We extend our sincere gratitude to our guide and faculty for their support.
Baharul Islam | Bhaskar Sha | Bongso Hanse | Hafizur Rahman | Md. Dilshan Ul Hassan Choudhury
Under the guidance of:
Mr. Swmdwm Basumatary, Asst. Professor, CSE
Barak Valley Engineering College, Assam — May 2026
- computer-vision
- machine-learning
- python
- mediapipe
- opencv
- road-safety
- ai-project