Skip to content
Caleb.ee
Computer VisionCompleted2025

DriveGuard Driver Monitoring System

A real-time driver monitor built with OpenCV and MediaPipe — scoring drowsiness and distraction from eye closure, gaze, head pose, and yawns, then escalating alerts by danger level.

DriveGuard L0 SAFE — green HUD showing an alert driver

L0 SAFE — driver appears alert; landmarks tracked, no alert action

Role

Developer

Team

Individual

Status

Completed

Timeline

2025

PythonOpenCVMediaPipeNumPyRichRequests
  • Tiered alerts: L0 Safe → L1 Caution → L3 Danger
  • PERCLOS, blink, and yawn tracking feed the danger score
  • Gaze / looking-away timers with temporal hysteresis
  • Live HUD with FPS, smoothed score, and action cues

Problem Statement

Distraction and drowsiness build up over seconds, not frames. A camera-based monitor needs to watch eyes, gaze, head pose, and yawns together, then escalate only when the evidence holds — not on a single blink.

Design Goals

  • Real-time facial landmark analysis with MediaPipe
  • Multi-signal cues: eye closure (PERCLOS), blinks, yawns, looking away, phone
  • Tiered danger levels with distinct actions (none → soft beep → critical alarm)
  • Temporal timers so brief gestures do not trip false alarms

System Architecture

Webcam frames → OpenCV capture → MediaPipe face landmarks → feature extractors (PERCLOS, blink/yawn counts, looking-away / mouth-open timers) → smoothed danger score → level state machine (L0 / L1 / L3) → HUD + alert action.

Stack: Python, OpenCV, MediaPipe, NumPy, Rich (console UI), Requests / python-dotenv for optional remote or config hooks.

Danger Levels

  • L0 SAFE — driver looks alert; action none
  • L1 CAUTION — early cues (partial eye closure, yawn); actions like soft_beep or vibration_and_beep
  • L3 DANGER — sustained risk (e.g. looking away for several seconds); action critical_alarm

Live metrics on the HUD include FPS, smoothed score, PERCLOS, blink/yawn totals, and per-cue timers (eyes closed, mouth open, looking away, phone seen).

Software Design

Each cue contributes to a smoothed score. Sustained evidence — not single-frame spikes — advances the level. Landmark overlays (eyes in green, mouth in blue) make it obvious what the model is measuring while you tune thresholds.

Testing and Validation

Staged behaviors in front of the webcam: alert baseline (L0), blinks and yawns (L1), and looking down / away long enough to hit L3. Thresholds and warn/danger dwell times were tuned from those runs.

Results

Working real-time monitor with clear L0 / L1 / L3 escalation, on-screen telemetry, and alert actions tied to blink, yawn, gaze, and PERCLOS cues.

Challenges

  • Lighting and camera angle change landmark quality
  • Natural blinks vs. drowsiness without temporal filtering
  • Balancing sensitivity so L1 fires early without constant false L3s

Lessons Learned

Timers and hysteresis matter more than any single landmark feature. PERCLOS and yawn/blink counts only become useful once you require evidence over time.

Future Improvements

  • Calibration UX for different cameras and seating positions
  • On-device optimization for lower-power hardware
  • More labeled clips for threshold tuning

Questions about this project? Email Caleb.