Skip to main content

EyeTrax

DOI PyPI version License: MIT made-with-python GitHub stars

Demo

EyeTrax is a Python library that provides webcam-based eye tracking. Extract facial features, train a model and predict gaze with an easy‑to‑use interface.

Features

  • Real‑time gaze estimation
  • Multiple calibration workflows
  • Optional filtering (Kalman / Kalman+EMA / KDE)
  • Model persistence – save / load a trained GazeEstimator
  • Virtual-camera overlay that integrates with streaming software (e.g., OBS) via the bundled eyetrax-virtualcam CLI

Installation

From PyPI

pip install eyetrax

From source

git clone https://github.com/ck-zhang/eyetrax && cd eyetrax

# editable install — pick one
python -m pip install -e .
pip install uv && uv sync

Demo

The EyeTrax package provides two command‑line entry points

Command Purpose
eyetrax-demo Run an on‑screen gaze overlay demo
eyetrax-virtualcam Stream the overlay to a virtual webcam

Options

Flag Values Default Description
--filter kalman, kalman_ema, kde, none none Smoothing filter
--ema-alpha (kalman_ema only) 0–1 0.25 EMA smoothing strength
--camera int 0 Physical webcam index
--calibration 9p, 5p, lissajous, dense 9p Calibration routine
--grid-rows (dense only) int 5 Calibration grid rows
--grid-cols (dense only) int 5 Calibration grid columns
--grid-margin (dense only) float 0.10 Margin ratio from edges
--background (demo only) path — Background image
--confidence (KDE only) 0–1 0.5 Contour probability

Quick Examples

eyetrax-demo --filter kalman

# Kalman + EMA smoothing (tune EMA strength)
eyetrax-demo --filter kalman_ema --ema-alpha 0.5

# Dense grid calibration (higher spatial coverage)
eyetrax-demo --calibration dense --grid-rows 7 --grid-cols 7
eyetrax-virtualcam --filter kde --calibration 5p

Virtual camera demo

https://github.com/user-attachments/assets/de4a0b63-8631-4c16-9901-9f83bc0bb766

Library Usage

from eyetrax import GazeEstimator, run_9_point_calibration
import cv2

# Create estimator and calibrate
estimator = GazeEstimator()
run_9_point_calibration(estimator)

# Save model
estimator.save_model("gaze_model.pkl")

# Load model
estimator = GazeEstimator()
estimator.load_model("gaze_model.pkl")

cap = cv2.VideoCapture(0)

while True:
    # Extract features from frame
    ret, frame = cap.read()
    features, blink = estimator.extract_features(frame)

    # Predict screen coordinates
    if features is not None and not blink:
        x, y = estimator.predict([features])[0]
        print(f"Gaze: ({x:.0f}, {y:.0f})")

More

If you find EyeTrax useful, consider starring the repo or contributing. If you use it in your research, please cite it. The project is available under the MIT license.

BibTeX

@software{Zhang2025_EyeTrax,
  author       = {Chenkai Zhang},
  title        = {EyeTrax},
  version      = {0.2.2},
  date         = {2025-04-23},
  url          = {https://pypi.org/project/eyetrax/},
  repository   = {https://github.com/ck-zhang/EyeTrax},
  doi          = {10.5281/zenodo.17188537},
  keywords     = {eye tracking, computer vision}
}

APA style

Zhang, C. (2025). EyeTrax (0.2.2) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.17188537

Metadata

Release files for eyetrax 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for eyetrax 0.4.0
File Size Uploaded
eyetrax-0.4.0.tar.gz 18.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for eyetrax 0.4.0
File Interpreter ABI Platform
eyetrax-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 48.6 kB

Release files / eyetrax-0.4.0.tar.gz

Download URL eyetrax-0.4.0.tar.gz
Size 18.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a67595a9266ba86e698a10c4199db5b4a1a9897ff2fc0ef06b9a04bed17ba91f
BLAKE2b-256 checksum
How to use checksums
dab9a47f2d589e578a122260f9584b3f0c53a7857f13927e058ef7b3180a02a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.29

Release files / eyetrax-0.4.0-py3-none-any.whl

Download URL eyetrax-0.4.0-py3-none-any.whl
Size 30.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc21f561e84906e2b64f869fadbbb5edb494ab85041b0821523cbb87eca88377
BLAKE2b-256 checksum
How to use checksums
c38dc4f5f8a0e01bd23fa5c035d981c8b7c8dbc4f8c71d07fbed4022bb3593c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.4.29

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page