Vizard 7 » Reference » Input Devices » Other devices » Pupil Labs

Pupil Labs

This plug-in provides support for Pupil Labs HMD eye tracking devices.


A full sample script can be found at \examples\devices\


The Pupil Labs plug-in is implemented as a Vizard extension. In order to use the plug-in you must first install and run either the Pupil Capture or Pupil Service applications provided by Pupil Labs. The plug-in will default to port 50020, so make sure this port is set in the Pupil Capture/Service settings, or specify the port when adding the eye tracker.


The Pupil Labs extension object has the following methods/constants:




Returns a Pupil Labs eye tracker at the specified address. You can optionally specify the port by appending :<port> to the address string.




Modes for performing user eye calibration.

The Pupil Labs Eye Tracker provides both position and orientation data that represent the gaze origin/direction relative to the HMD coordinate frame. By default, the combined gaze values from both eyes is returned. To get the gaze values for each eye, pass the viz.LEFT_EYE or viz.RIGHT_EYE flag to the corresponding sensor function. The eye tracker object has the following methods in addition to the standard extension sensor methods:




Start calibration procedure. Can use one of the calibration modes in table above.


Cancel calibration if currently in progress.

<tracker>.isCalibrating() Return whether calibration is in progress.

Starts recording eye tracker data under the specified session name. Pupil Capture will save all corresponding gaze data in a folder in your user directory named recordings.

<tracker>.stopRecording() Stop recording of current session.
<tracker>.isRecording() Return whether recording is in progress
<tracker>.setViewEyes(mode) Set whether to view video feed of eyes.
<tracker>.getViewEyes() Get whether viewing of eyes is in progress.


The following example shows how to connect to a Pupil Labs eye tracker on the local machine:

# Create extension
PupilLabs = viz.add('PupilLabs.dle')

# Connect to eye tracker
tracker = PupilLabs.addEyeTracker()

The next example shows how to get the gaze vector and perform an intersection test to determine where the user is looking:

# Get gaze matrix in local HMD coordinate system
gazeMat = eyeTracker.getMatrix()

# Transform gaze matrix into world coordinate system using main view

# Intersect world gaze vector with scene
line = gazeMat.getLineForward(1000)
info = viz.intersect(line.begin, line.end)
if info.valid:
    print('User is looking at', info.point)