-
Notifications
You must be signed in to change notification settings - Fork 0
Quick Start
Gancheng Zhu edited this page Sep 8, 2025
·
1 revision
Here is a minimal example of how to start streaming gaze data:
# load PyGame library
import pygame
from pygame.locals import FULLSCREEN, HWSURFACE
# initialize PyGame
pygame.init()
# define the scree size
scn_width, scn_height = (1920, 1080)
# set a fullscreen mode with the above size
win = pygame.display.set_mode((scn_width, scn_height), FULLSCREEN|HWSURFACE)
# load Pupilio library
from pupilio import Pupilio
# instantiate a connection to the tracker
pupil_io = Pupilio()
# create a task session, and set a session name.
# The session name must contain only letters, digits or underscores without any special characters.
pupil_io.create_session(session_name="quick_start")
# calibration and validation (recommended)
# set 'validate' to True if we would like to verify the calibration results
pupil_io.calibration_draw(screen=win, validate=True)
# start retrieving gaze
pupil_io.start_sampling()
# hang the main thread for 5 seconds by game
# eye tracking sampling are running on the background thread
pygame.time.wait(5 * 1000)
# stop eye tracking sampling
pupil_io.stop_sampling()
# sleep for 100 ms to capture ending samples
pygame.time.wait(100)
# save eye movement data
pupil_io.save_data("eye_movement.csv")
# release the tracker instance
# clean up Pupilio resources
pupil_io.release()
# quit pygame
pygame.quit()