Back to projects

Drowsy Driver Detection

Prototype

A real-time computer vision system that tracks eye closure with facial landmarks and the Eye Aspect Ratio, calibrates to each driver, and triggers an audio alarm when it detects drowsiness.

  • Python
  • OpenCV
  • dlib
  • NumPy
  • Computer Vision

Drowsy Driver Detection watches a driver’s eyes through a webcam and raises an alarm before a long blink turns into falling asleep at the wheel.

What it does

  • Real-time monitoring: tracks both eyes on a live webcam feed.
  • Calibration: a short calibration phase at the start sets the baseline for the person in front of the camera, so it isn’t tuned to one face.
  • Alarm: plays an audio alert when the eyes stay closed for too long.
  • Live EAR graph: a separate window plots the eye openness signal over time.
  • Logging and summary: events are written to a CSV log, and a session summary is shown when you stop.

How it works

dlib’s 68-point facial landmark model finds six points around each eye. From those, the system computes the Eye Aspect Ratio (EAR): the vertical eye distances divided by the horizontal one. The ratio stays fairly steady while the eye is open and drops toward zero when it closes. If EAR stays under the calibrated threshold for enough consecutive frames, the alarm fires.

What I learned

A fixed threshold doesn’t work for everyone. Eye shapes, camera angles, and lighting all shift the baseline, which is why the calibration phase was added. I also learned how much setup friction matters: getting dlib to compile on Windows was its own project, so the README walks through it step by step.