Skip to content

scoville/blink-detection-public

Repository files navigation

Blink Detection Module

demo

This repository provides the backend for DryEye Defender project.

A Python module for real-time blink detection using MediaPipe's face mesh detection. This module processes facial keypoints to detect eye pose and blink events, reporting the extent of eye closure via an "EAR ratio" (Eye Aspect Ratio) and eye open/closed flags.

Features

  • Real-time blink detection using MediaPipe face mesh
  • Eye Aspect Ratio (EAR) calculation for precise blink measurement
  • Filtered output to reduce noise and improve accuracy
  • Cross-platform compatibility

Technical Details

The module uses MediaPipe's face mesh detection to track facial landmarks, particularly around the eyes. The Eye Aspect Ratio (EAR) is calculated based on the relative positions of eye landmarks, following the method described by Soukupová and Čech (2016).

The EAR values are processed through:

  1. Raw EAR calculation (always positive)
  2. Median filtering (resulting in values that can be negative after normalization)
  3. Threshold-based blink detection

Requirements

  • Python 3.11
  • X11 for visualisation (for OSX you may wish to install XQuartz: brew install xquartz)

Installation

1 git lfs install && git lfs pull

  1. Install the dependencies:
pip install -r requirements.txt
  1. Running inference on ./blinkdetector/example_videos/video.mp4`:
python -m blinkdetector

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Attribution

This software uses:

  • MediaPipe (https://github.com/google/mediapipe) - Licensed under Apache 2.0
  • Eye Aspect Ratio calculation based on: Soukupová and Čech, "Real-Time Eye Blink Detection using Facial Landmarks" (2016)
  • Stock video of blinking person AI generated using Google Vids.

See the NOTICE file for detailed attribution information.

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •