A 2018 CV tutorial, still blinking after 542 stars
A straightforward OpenCV demo that tracks eye aspect ratio to nag drowsy drivers—useful as a teaching aid, not a production safety system.

What it does
This repo implements a classic computer-vision pipeline: dlib’s facial landmark predictor locates 6 points around each eye, and the code computes an Eye Aspect Ratio (EAR) over 20 consecutive frames. If EAR drops below 0.25, it triggers an alarm. The intended use case is warning long-haul drivers before they nod off.
The interesting bit
The project is essentially a polished, runnable packaging of Adrian Rosebrock’s 2017 PyImageSearch tutorial—complete with the same diagrams and algorithm. That isn’t a knock; it’s a decent on-ramp for someone who wants to see landmark detection and threshold-based alerting in a single script without wrestling with notebook fragmentation.
Key highlights
- Single-file execution:
python Drowsiness_Detection.pyand you’re watching your webcam - Hard dependency on dlib’s 68-point face model (bundled or downloaded separately)
- Threshold logic is brutally simple: 20 frames, EAR < 0.25, sound the alarm
- Ships with explanatory eye-geometry diagrams that actually clarify the math
- Python 2.7 is still listed as the baseline, though 3.x “will work”
Caveats
- No mention of head-pose variation, glasses occlusion, or lighting robustness—real-world edge cases the README doesn’t address
- The alarm mechanism itself isn’t shown in the source excerpts; it’s unclear whether it plays a system beep, an audio file, or just prints to stdout
- Citation instructions suggest academic gravitas, but this is a tutorial implementation, not a validated safety system
Verdict
Grab this if you’re learning OpenCV and want a clean, complete facial-landmark example that does something concrete. Skip it if you need an actual driver-safety product, or if you’re already comfortable with dlib and want something you can tune without rewriting from scratch.