Skip to content

Anuj092/Sleep-Detector

Repository files navigation

💤 Sleep Detector – Real-Time Drowsiness Monitoring

A Python application that monitors eye activity via webcam and detects signs of drowsiness using facial landmarks. Designed to alert users when eyes remain closed for extended periods — ideal for safety-critical applications like driver monitoring.


Dataset

The dataset used for this project can be found here.


⚙️ Tech Stack

  • Python
  • OpenCV
  • Dlib (Facial Landmark Detection)
  • NumPy
  • Pygame (for alert sound)

🧠 How It Works

The system calculates the Eye Aspect Ratio (EAR) from key facial landmarks. If the ratio drops below a set threshold for consecutive frames, an alarm is triggered.


🎯 Features

  • 🎥 Real-time webcam monitoring (30+ FPS)
  • 👁️ Facial landmark tracking with Dlib
  • 🚨 Alarm sound for prolonged eye closure
  • 📊 Adjustable threshold and detection sensitivity
  • 🪶 Lightweight (CPU-friendly)

📊 Performance Metrics

Metric Value
Video FPS ~30
EAR Detection Latency < 100ms
Detection Accuracy 90%+ (in good light)
Alert Response Time ~500ms

🛠 Setup Instructions

git clone https://github.com/Anuj092/Sleep-Detector
cd Sleep-Detector
pip install -r requirements.txt
python sleep_detector.py

About

Detects if a user is tired or falling asleep by tracking eye activity using webcam-based facial recognition. If the user appears drowsy, it plays an alarm to wake them. The detection is real-time and uses Haar cascades for face and eye detection. Alert logic is based on the percentage of frames where eyes are not detected.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages