Skip to content

About

Control your mouse with your eyes using any webcam - MediaPipe iris tracking + ridge-regression calibration, hotkey click, live gaze overlay

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Eyetracker

Control your mouse with your eyes using nothing but a webcam. No IR hardware, no Tobii — a laptop camera, a 30-second calibration, and a hotkey to click where you're looking.

How it works

  1. Iris tracking — MediaPipe Face Mesh with refined landmarks gives 5-point iris contours for each eye plus the eye corners, per frame, from any webcam.
  2. Feature extraction — iris centers are normalized against the eye corners (position within the eye, independent of head distance), giving a small feature vector that mostly isolates gaze direction.
  3. Calibration — a fullscreen 3x3 grid of dots. Look at each dot and press SPACE; 10 samples are captured per point. The 9 points fit two ridge regressions (one per screen axis) over degree-2 polynomial features. The model is pickled to calibration.pkl so you calibrate once, not every launch.
  4. Tracking — at ~60 Hz the regressor maps live iris features to screen coordinates, smoothed with an exponential moving average. A click-through, always-on-top overlay draws a dot where you're looking, and a hotkey clicks at that spot.

Install

git clone https://github.com/1Aa1k/Eyetracker.git
cd Eyetracker
pip install -r requirements.txt

Requires Python 3.9+ with a webcam. Dependencies: OpenCV, MediaPipe, scikit-learn, pyautogui, pynput.

Run

python main.py    # command-line version
python ui.py      # tkinter control panel (webcam picker, settings, live status)

On Windows you can also double-click start.bat.

First launch walks you through webcam selection and calibration. After that it loads the saved calibration and starts tracking immediately.

Controls

Key Action
F10 Click at gaze position
F11 Toggle the gaze overlay dot
F12 Recalibrate
ESC Quit

Hotkeys, overlay color/size, smoothing factor, and webcam index are all in config.json (created on first run).

Tuning

  • Cursor jitters — raise smoothing_factor in config.json (0 = raw, closer to 1 = heavier smoothing).
  • Accuracy drifts — press F12 and recalibrate; big posture or lighting changes invalidate the fit. Keep your head roughly where it was during calibration.
  • Wrong camera — set webcam_index in config.json, or pick one in the UI version.

Notes

  • The transparent overlay uses tkinter's -transparentcolor, which is Windows-only. Tracking and hotkey clicking work everywhere; on Linux/macOS run with the overlay toggled off (F11) if it renders as a black fullscreen window.
  • All processing is local — frames never leave your machine.

Files

  • main.py — CLI entry point
  • ui.py — tkinter GUI entry point
  • tracker.py — webcam capture + MediaPipe landmark extraction
  • gaze.py — feature engineering, ridge-regression gaze model, smoothing
  • calibration.py — fullscreen 9-point calibration flow
  • overlay.py — transparent always-on-top gaze dot
  • hotkeys.py — global hotkey listener (pynput)
  • config.py — JSON config load/save + hotkey parsing

About

Control your mouse with your eyes using any webcam - MediaPipe iris tracking + ridge-regression calibration, hotkey click, live gaze overlay

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages