Skip to content

aamar-shahzad/blinkEye

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BlinkEye 👁️

A native macOS app for eye health monitoring. Track your blink rate, get break reminders, and protect your eyes from screen fatigue.

macOS Swift License

Features

🎯 Blink Tracking

  • Real-time blink detection using Apple's Vision framework
  • Eye Aspect Ratio (EAR) algorithm for accurate blink detection
  • Neural Engine optimized for low CPU usage
  • Live camera preview with eye tracking visualization

⏰ Break Reminders (20-20-20 Rule)

  • Automatic reminders every 20 minutes
  • Full-screen break overlay with countdown timer
  • Customizable intervals and break duration
  • Skip or take break immediately options

🔔 Smart Alerts

  • Health status monitoring (Healthy / Warning / Critical)
  • System notifications when blink rate drops
  • Sound alerts for immediate attention
  • Visual menu bar indicators

📊 Statistics & Data

  • Session tracking with historical data
  • Trend charts showing blink patterns
  • Export to CSV/JSON for analysis
  • SwiftData persistence for reliable storage

⚙️ Customization

  • Personal calibration for your eyes
  • Adjustable thresholds for blink detection
  • Keyboard shortcuts for quick control
  • Launch at login option

😴 Drowsiness Detection

  • Prolonged eye closure detection
  • Fatigue level indicators
  • PERCLOS-based analysis

Requirements

  • macOS 14.0 (Sonoma) or later
  • Mac with built-in camera or external webcam
  • Camera permission for blink detection

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/BlinkEye.git
  1. Open BlinkEye.xcodeproj in Xcode

  2. Build and run (⌘+R)

  3. Grant camera permission when prompted

Usage

Menu Bar

Click the 👁️ icon in the menu bar to:

  • View current blink rate and health status
  • Start/Stop tracking
  • Access camera preview
  • View statistics
  • Open settings

Keyboard Shortcuts

Shortcut Action
⌘⇧B Toggle tracking
⌘⇧E Show menu
⌘⇧R Take break now

Camera Preview

Shows live eye tracking with:

  • Green box around detected face
  • Cyan dots on eyes (red when blinking)
  • Real-time EAR value and confidence

How It Works

BlinkEye uses the Eye Aspect Ratio (EAR) algorithm to detect blinks:

  1. Face Detection: Vision framework detects face landmarks
  2. Eye Landmarks: Extracts 6 points around each eye
  3. EAR Calculation: Computes vertical to horizontal ratio
  4. Blink Detection: EAR drops below threshold = blink

The typical EAR is ~0.3 with open eyes and ~0.1 during a blink.

Architecture

BlinkEye/
├── BlinkEyeApp.swift      # App entry point & delegate
├── Models/
│   ├── BlinkSession.swift  # Session data model
│   └── BlinkEvent.swift    # Individual blink event
├── Services/
│   ├── CameraManager.swift      # AVFoundation camera handling
│   ├── BlinkDetector.swift      # Vision-based blink detection
│   ├── BlinkTracker.swift       # Blink counting & rate calc
│   ├── AlertManager.swift       # Notifications & alerts
│   ├── BreakReminderManager.swift # 20-20-20 rule
│   ├── CalibrationManager.swift  # Personal calibration
│   ├── KeyboardShortcutManager.swift # Global hotkeys
│   ├── LaunchAtLoginManager.swift # Startup management
│   └── DataExportManager.swift   # CSV/JSON export
└── Views/
    ├── MenuBarView.swift        # Menu bar dropdown
    ├── CameraPreviewView.swift  # Live camera feed
    ├── StatsView.swift          # Statistics charts
    ├── SettingsView.swift       # Preferences
    └── Components/
        ├── BlinkRateGauge.swift # Rate visualization
        └── BlinkChartView.swift # Trend charts

Performance

  • CPU Usage: ~10-15% (optimized frame processing)
  • Memory: ~90MB
  • Frame Rate: 15 FPS (configurable)
  • Battery: Minimal impact with adaptive processing

Privacy

  • All processing happens on-device
  • No data is sent to external servers
  • Camera data is never recorded or stored
  • Only blink statistics are persisted locally

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE for details.

Acknowledgments

  • Eye blink detection based on the EAR algorithm by Soukupová and Čech (2016)
  • Icons from SF Symbols
  • Built with SwiftUI, Vision, and AVFoundation

Made with ❤️ for healthy eyes