Skip to main content

Webcam-based eye-tracking

Project description

EyeTrax

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 / 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, kde, none none Smoothing filter
--camera int 0 Physical webcam index
--calibration 9p, 5p, lissajous 9p Calibration routine
--background (demo only) path Background image
--confidence (KDE only) 0–1 0.5 Contour probability

Quick Examples

eyetrax-demo --filter kalman
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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eyetrax-0.2.3.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eyetrax-0.2.3-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file eyetrax-0.2.3.tar.gz.

File metadata

  • Download URL: eyetrax-0.2.3.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.20

File hashes

Hashes for eyetrax-0.2.3.tar.gz
Algorithm Hash digest
SHA256 cb9e6704f73b791455b62bcd31b27ff536816d4a97a435e3f7f42a4ca60c8a3a
MD5 c168a379a88b32a512cfbcb169d4a0e6
BLAKE2b-256 abcc034be993f8d50ccdc401a0ac24023ae31b4e0cddc2ab63b6b3a1f54ff9ef

See more details on using hashes here.

File details

Details for the file eyetrax-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: eyetrax-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.20

File hashes

Hashes for eyetrax-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 03ae65c8c2f8b25b13e654641da7ada9735009859ada8cc504cac5e21a85e0d1
MD5 5d986e8bfe49b3d3f1e4dc975b5b7db7
BLAKE2b-256 33a1ecd61ba72ebdcf3c13707877f171a5efcf374e23a3bf0c074f2cd8a66631

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page