Skip to content

fatigue: Eye Aspect Ratio (EAR) drowsiness features from MediaPipe landmarks#1

Open
nikita-shar wants to merge 1 commit into
mainfrom
nikita/mediapipe-eye-aspect-ratio
Open

fatigue: Eye Aspect Ratio (EAR) drowsiness features from MediaPipe landmarks#1
nikita-shar wants to merge 1 commit into
mainfrom
nikita/mediapipe-eye-aspect-ratio

Conversation

@nikita-shar

Copy link
Copy Markdown
Collaborator

Adds fatigue/ear.py — continuous Eye Aspect Ratio (Soukupová & Čech 2016) computed from raw MediaPipe Face Mesh landmarks, plus drowsiness features (PERCLOS, blink rate, closure durations, microsleep count). Local / on-device, no gateway or token. Implements the next-step from fatigue/RESULTS.md ("eye-aspect-ratio from raw MediaPipe landmarks would likely lift the 0.665").

Why: the gateway only exposes a boolean blink (eyeBlink > 0.5); EAR keeps the continuous signal + closure-duration info the boolean discards.

Evidence (local, single-clip):

  • Alert courtroom clip → microsleep_count 0, perclos 0.02 (correctly alert)
  • Drowsy webcam clip → microsleep_count 3, longest closure 11.4s, perclos 0.44 (correctly drowsy)
  • A signal-vs-signal comparison validates EAR matches MediaPipe's own blink timing.

Honest scope: prove-it-works on single clips, not an AUC comparison — confirming it lifts 0.665 needs labeled UTA-RLDD + LOSO (not run here; needs the dataset). Standalone (not wired into train.py); a 3-line integration snippet is in the module docstring. Fixed closed_thr=0.20; MediaPipe's EAR scale runs higher than classic dlib, so an adaptive per-person threshold is a sensible follow-up.

Tests: tests/test_ear.py (6, pure logic — no model/video).
Deps: fatigue/requirements-ear.txt (mediapipe + opencv, optional lane); model bundle auto-downloads to fatigue/models/ (gitignored).

🤖 Generated with Claude Code

…ndmarks)

Continuous EAR (Soukupova & Cech 2016) from raw MediaPipe Face Mesh landmarks,
with PERCLOS / blink-rate / closure-duration / microsleep features. Local +
on-device, no gateway or token. Implements the fatigue/RESULTS.md next-step.
Standalone for now (3-line integration snippet in the module docstring).
Tests in tests/test_ear.py (pure logic, no model/video).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant