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.
- 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.
- 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.
- 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.pklso you calibrate once, not every launch. - 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.
git clone https://github.com/1Aa1k/Eyetracker.git
cd Eyetracker
pip install -r requirements.txtRequires Python 3.9+ with a webcam. Dependencies: OpenCV, MediaPipe, scikit-learn, pyautogui, pynput.
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.
| 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).
- Cursor jitters — raise
smoothing_factorinconfig.json(0 = raw, closer to 1 = heavier smoothing). - Accuracy drifts — press
F12and recalibrate; big posture or lighting changes invalidate the fit. Keep your head roughly where it was during calibration. - Wrong camera — set
webcam_indexinconfig.json, or pick one in the UI version.
- 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.
main.py— CLI entry pointui.py— tkinter GUI entry pointtracker.py— webcam capture + MediaPipe landmark extractiongaze.py— feature engineering, ridge-regression gaze model, smoothingcalibration.py— fullscreen 9-point calibration flowoverlay.py— transparent always-on-top gaze dothotkeys.py— global hotkey listener (pynput)config.py— JSON config load/save + hotkey parsing