Tobii Pro SDK Python API
tobii_research.EyeTracker Class Reference

Provides methods and properties to manage and get data from an eye tracker. More...

Inherits object.

Public Member Functions

def __init__ (self, address)
 Gets an eye tracker object that has the specified URI. More...
 
def apply_licenses (self, license_key_ring)
 Sets a key ring of licenses or a single license for unlocking features of the eye tracker. More...
 
def clear_applied_licenses (self)
 Clears any previously applied licenses. More...
 
def retrieve_calibration_data (self)
 Gets the calibration data used currently by the eye tracker. More...
 
def apply_calibration_data (self, calibration_data)
 Sets the provided calibration data to the eye tracker, which means it will be active calibration. More...
 
def get_all_gaze_output_frequencies (self)
 Gets a list of gaze output frequencies supported by the eye tracker. More...
 
def get_gaze_output_frequency (self)
 Gets the gaze output frequency of the eye tracker. More...
 
def set_gaze_output_frequency (self, gaze_output_frequency)
 Sets the gaze output frequency of the eye tracker. More...
 
def get_all_eye_tracking_modes (self)
 Gets a tuple of eye tracking modes supported by the eye tracker. More...
 
def get_eye_tracking_mode (self)
 Gets the eye tracking mode of the eye tracker. More...
 
def set_eye_tracking_mode (self, eye_tracking_mode)
 Sets the eye tracking mode of the eye tracker. More...
 
def get_track_box (self)
 Gets the track box of the eye tracker. More...
 
def get_display_area (self)
 Gets the size and corners of the display area. More...
 
def set_display_area (self, display_area)
 Sets the display area of the eye tracker. More...
 
def get_hmd_lens_configuration (self)
 Gets the current lens configuration of the HMD based eye tracker. More...
 
def set_hmd_lens_configuration (self, lens_configuration)
 Sets the lens configuration of the HMD based eye tracker. More...
 
def set_device_name (self, device_name)
 Changes the device name. More...
 
def subscribe_to (self, subscription_type, callback, as_dictionary=False)
 Subscribes to data for the eye tracker. More...
 
def unsubscribe_from (self, subscription_type, callback=None)
 Unsubscribes from data for the eye tracker. More...
 

Data Fields

 address
 Gets the address (URI) of the eye tracker device.
 
 device_name
 Gets the name of the eye tracker.
 
 serial_number
 Gets the serial number of the eye tracker. More...
 
 model
 Gets the model of the eye tracker.
 
 firmware_version
 Gets the firmware version of the eye tracker.
 
 runtime_version
 Gets the runtime version of the eye tracker.
 
 device_capabilities
 Gets a tuple with the capabilities of the device. More...
 

Detailed Description

Provides methods and properties to manage and get data from an eye tracker.

EyeTracker objects are either created from an address or returned in a tuple from find_all_eyetrackers.

Constructor & Destructor Documentation

def tobii_research.EyeTracker.__init__ (   self,
  address 
)

Gets an eye tracker object that has the specified URI.

1 import tobii_research as tr
2 
3 # address = "tet-tcp://12.13.14.15"
4 eyetracker = tr.EyeTracker(address)
5 
6 print("Address: " + eyetracker.address)
7 print("Model: " + eyetracker.model)
8 print("Name (It's OK if this is empty): " + eyetracker.device_name)
9 print("Serial number: " + eyetracker.serial_number)
10 
11 if tr.CAPABILITY_CAN_SET_DISPLAY_AREA in eyetracker.device_capabilities:
12  print("The display area can be set on the eye tracker.")
13 else:
14  print("The display area can not be set on the eye tracker.")
15 
16 if tr.CAPABILITY_HAS_EXTERNAL_SIGNAL in eyetracker.device_capabilities:
17  print("The eye tracker can deliver an external signal stream.")
18 else:
19  print("The eye tracker can not deliver an external signal stream.")
20 
21 if tr.CAPABILITY_HAS_EYE_IMAGES in eyetracker.device_capabilities:
22  print("The eye tracker can deliver an eye image stream.")
23 else:
24  print("The eye tracker can not deliver an eye image stream.")
25 
26 if tr.CAPABILITY_HAS_GAZE_DATA in eyetracker.device_capabilities:
27  print("The eye tracker can deliver a gaze data stream.")
28 else:
29  print("The eye tracker can not deliver a gaze data stream.")
30 
31 if tr.CAPABILITY_HAS_HMD_GAZE_DATA in eyetracker.device_capabilities:
32  print("The eye tracker can deliver a HMD gaze data stream.")
33 else:
34  print("The eye tracker can not deliver a HMD gaze data stream.")
35 
36 if tr.CAPABILITY_CAN_DO_SCREEN_BASED_CALIBRATION in eyetracker.device_capabilities:
37  print("The eye tracker can do a screen based calibration.")
38 else:
39  print("The eye tracker can not do a screen based calibration.")
40 
41 if tr.CAPABILITY_CAN_DO_MONOCULAR_CALIBRATION in eyetracker.device_capabilities:
42  print("The eye tracker can do a monocular calibration.")
43 else:
44  print("The eye tracker can not do a monocular calibration.")
45 
46 if tr.CAPABILITY_CAN_DO_HMD_BASED_CALIBRATION in eyetracker.device_capabilities:
47  print("The eye tracker can do a HMD screen based calibration.")
48 else:
49  print("The eye tracker can not do a HMD screen based calibration.")
50 
51 if tr.CAPABILITY_HAS_HMD_LENS_CONFIG in eyetracker.device_capabilities:
52  print("The eye tracker can get/set the HMD lens configuration.")
53 else:
54  print("The eye tracker can not get/set the HMD lens configuration.")
Parameters
addressAddress (URI) to the eye tracker.
Exceptions
EyeTrackerConnectionFailedError
EyeTrackerInternalError
ValueError

Member Function Documentation

def tobii_research.EyeTracker.apply_calibration_data (   self,
  calibration_data 
)

Sets the provided calibration data to the eye tracker, which means it will be active calibration.

See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.

1 filename = "saved_calibration.bin"
2 
3 # Save the calibration to file.
4 with open(filename, "wb") as f:
5  calibration_data = eyetracker.retrieve_calibration_data()
6 
7  # None is returned on empty calibration.
8  if calibration_data is not None:
9  print("Saving calibration to file for eye tracker with serial number {0}.".format(eyetracker.serial_number))
10  f.write(eyetracker.retrieve_calibration_data())
11  else:
12  print("No calibration available for eye tracker with serial number {0}.".format(eyetracker.serial_number))
13 
14 # Read the calibration from file.
15 with open(filename, "rb") as f:
16  calibration_data = f.read()
17 
18  # Don't apply empty calibrations.
19  if len(calibration_data) > 0:
20  print("Applying calibration on eye tracker with serial number {0}.".format(eyetracker.serial_number))
21  eyetracker.apply_calibration_data(calibration_data)
Exceptions
EyeTrackerConnectionFailedError
EyeTrackerInternalError
EyeTrackerLicenseError
ValueError
def tobii_research.EyeTracker.apply_licenses (   self,
  license_key_ring 
)

Sets a key ring of licenses or a single license for unlocking features of the eye tracker.

See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.

1 import tobii_research as tr
2 
3 print("Applying license from {0}.".format(license_file_path))
4 with open(license_file_path, "rb") as f:
5  license = f.read()
6 
7 failed_licenses_applied_as_list_of_keys = eyetracker.apply_licenses([tr.LicenseKey(license)])
8 failed_licenses_applied_as_list_of_bytes = eyetracker.apply_licenses([license])
9 failed_licenses_applied_as_key = eyetracker.apply_licenses(tr.LicenseKey(license))
10 failed_licenses_applied_as_bytes = eyetracker.apply_licenses(license)
11 
12 if len(failed_licenses_applied_as_list_of_keys) == 0:
13  print("Successfully applied license from list of keys.")
14 else:
15  print("Failed to apply license from list of keys. Validation result: {0}.".
16  format(failed_licenses_applied_as_list_of_keys[0].validation_result))
17 
18 if len(failed_licenses_applied_as_list_of_bytes) == 0:
19  print("Successfully applied license from list of bytes.")
20 else:
21  print("Failed to apply license from list of bytes. Validation result: {0}.".
22  format(failed_licenses_applied_as_list_of_bytes[0].validation_result))
23 
24 if len(failed_licenses_applied_as_key) == 0:
25  print("Successfully applied license from single key.")
26 else:
27  print("Failed to apply license from single key. Validation result: {0}.".
28  format(failed_licenses_applied_as_key[0].validation_result))
29 
30 if len(failed_licenses_applied_as_bytes) == 0:
31  print("Successfully applied license from bytes object.")
32 else:
33  print("Failed to apply license from bytes object. Validation result: {0}.".
34  format(failed_licenses_applied_as_bytes[0].validation_result))
Parameters
license_key_ringList of LicenseKey objects, list of bytes, LicenseKey object or bytes object.
Exceptions
EyeTrackerConnectionFailedError
EyeTrackerInternalError
AttributeError
TypeError
Returns
Tuple of FailedLicense objects for licenses that failed. Empty tuple if all licenses were successfully applied.
def tobii_research.EyeTracker.clear_applied_licenses (   self)

Clears any previously applied licenses.

Exceptions
EyeTrackerConnectionFailedError
EyeTrackerInternalError
EyeTrackerLicenseError
def tobii_research.EyeTracker.get_all_eye_tracking_modes (   self)

Gets a tuple of eye tracking modes supported by the eye tracker.

See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.

1 initial_eye_tracking_mode = eyetracker.get_eye_tracking_mode()
2 
3 print("The eye tracker's initial eye tracking mode is {0}.".format(initial_eye_tracking_mode))
4 
5 try:
6  for eye_tracking_mode in eyetracker.get_all_eye_tracking_modes():
7  eyetracker.set_eye_tracking_mode(eye_tracking_mode)
8  print("Eye tracking mode set to {0}.".format(eye_tracking_mode))
9 finally:
10  eyetracker.set_eye_tracking_mode(initial_eye_tracking_mode)
11  print("Eye tracking mode reset to {0}.".format(initial_eye_tracking_mode))
Exceptions
EyeTrackerConnectionFailedError
EyeTrackerInternalError
EyeTrackerLicenseError
Returns
Tuple of strings with available eye tracking modes.
def tobii_research.EyeTracker.get_all_gaze_output_frequencies (   self)

Gets a list of gaze output frequencies supported by the eye tracker.

See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.

1 initial_gaze_output_frequency = eyetracker.get_gaze_output_frequency()
2 
3 print("The eye tracker's initial gaze output frequency is {0} Hz.".format(initial_gaze_output_frequency))
4 
5 try:
6  for gaze_output_frequency in eyetracker.get_all_gaze_output_frequencies():
7  eyetracker.set_gaze_output_frequency(gaze_output_frequency)
8  print("Gaze output frequency set to {0} Hz.".format(gaze_output_frequency))
9 finally:
10  eyetracker.set_gaze_output_frequency(initial_gaze_output_frequency)
11  print("Gaze output frequency reset to {0} Hz.".format(initial_gaze_output_frequency))
Exceptions
EyeTrackerConnectionFailedError
EyeTrackerInternalError
EyeTrackerLicenseError
Returns
Tuple of floats with all gaze output frequencies.
def tobii_research.EyeTracker.get_display_area (   self)

Gets the size and corners of the display area.

See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.

1 from tobii_research import DisplayArea
2 
3 display_area = eyetracker.get_display_area()
4 
5 print("Got display area from tracker with serial number {0}:".format(eyetracker.serial_number))
6 
7 print("Bottom Left: {0}".format(display_area.bottom_left))
8 print("Bottom Right: {0}".format(display_area.bottom_right))
9 print("Height: {0}".format(display_area.height))
10 print("Top Left: {0}".format(display_area.top_left))
11 print("Top Right: {0}".format(display_area.top_right))
12 print("Width: {0}".format(display_area.width))
13 
14 # To set the display area it is possible to either use a previously saved instance of
15 # the class Display area, or create a new one as shown bellow.
16 new_display_area_dict = dict()
17 new_display_area_dict['top_left'] = display_area.top_left
18 new_display_area_dict['top_right'] = display_area.top_right
19 new_display_area_dict['bottom_left'] = display_area.bottom_left
20 
21 new_display_area = DisplayArea(new_display_area_dict)
22 
23 eyetracker.set_display_area(new_display_area)
Exceptions
EyeTrackerFeatureNotSupportedError
EyeTrackerConnectionFailedError
EyeTrackerInternalError
EyeTrackerLicenseError
Returns
Display area in the user coordinate system as a DisplayArea object.
def tobii_research.EyeTracker.get_eye_tracking_mode (   self)

Gets the eye tracking mode of the eye tracker.

See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.

1 initial_eye_tracking_mode = eyetracker.get_eye_tracking_mode()
2 
3 print("The eye tracker's initial eye tracking mode is {0}.".format(initial_eye_tracking_mode))
4 
5 try:
6  for eye_tracking_mode in eyetracker.get_all_eye_tracking_modes():
7  eyetracker.set_eye_tracking_mode(eye_tracking_mode)
8  print("Eye tracking mode set to {0}.".format(eye_tracking_mode))
9 finally:
10  eyetracker.set_eye_tracking_mode(initial_eye_tracking_mode)
11  print("Eye tracking mode reset to {0}.".format(initial_eye_tracking_mode))
Exceptions
EyeTrackerConnectionFailedError
EyeTrackerInternalError
EyeTrackerLicenseError
Returns
String with the current eye tracking mode.
def tobii_research.EyeTracker.get_gaze_output_frequency (   self)

Gets the gaze output frequency of the eye tracker.

See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.

1 initial_gaze_output_frequency = eyetracker.get_gaze_output_frequency()
2 
3 print("The eye tracker's initial gaze output frequency is {0} Hz.".format(initial_gaze_output_frequency))
4 
5 try:
6  for gaze_output_frequency in eyetracker.get_all_gaze_output_frequencies():
7  eyetracker.set_gaze_output_frequency(gaze_output_frequency)
8  print("Gaze output frequency set to {0} Hz.".format(gaze_output_frequency))
9 finally:
10  eyetracker.set_gaze_output_frequency(initial_gaze_output_frequency)
11  print("Gaze output frequency reset to {0} Hz.".format(initial_gaze_output_frequency))
Exceptions
EyeTrackerConnectionFailedError
EyeTrackerInternalError
EyeTrackerLicenseError
Returns
Float with the current gaze output frequency.
def tobii_research.EyeTracker.get_hmd_lens_configuration (   self)

Gets the current lens configuration of the HMD based eye tracker.

The lens configuration describes how the lenses of the HMD device are positioned. See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.

1 lens_configuration = eyetracker.get_hmd_lens_configuration()
2 
3 print("Got HMD lens configuration from tracker with serial number {0}:".format(eyetracker.serial_number))
4 
5 print("Left: {0}".format(lens_configuration.left))
6 print("Right: {0}".format(lens_configuration.right))
Exceptions
EyeTrackerFeatureNotSupportedError
EyeTrackerConnectionFailedError
EyeTrackerInternalError
EyeTrackerLicenseError
Returns
Lens configuration as a HMDLensConfiguration object.
def tobii_research.EyeTracker.get_track_box (   self)

Gets the track box of the eye tracker.

See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.

1 track_box = eyetracker.get_track_box()
2 
3 print("Got track box from tracker with serial number {0} with corners:".format(eyetracker.serial_number))
4 
5 print("Back Lower Left: {0}".format(track_box.back_lower_left))
6 print("Back Lower Right: {0}".format(track_box.back_lower_right))
7 print("Back Upper Left: {0}".format(track_box.back_upper_left))
8 print("Back Upper Right: {0}".format(track_box.back_upper_right))
9 print("Front Lower Left: {0}".format(track_box.front_lower_left))
10 print("Front Lower Right: {0}".format(track_box.front_lower_right))
11 print("Front Upper Left: {0}".format(track_box.front_upper_left))
12 print("Front Upper Right: {0}".format(track_box.front_upper_right))
Exceptions
EyeTrackerConnectionFailedError
EyeTrackerInternalError
EyeTrackerLicenseError
Returns
Track box in the user coordinate system as a TrackBox object.
def tobii_research.EyeTracker.retrieve_calibration_data (   self)

Gets the calibration data used currently by the eye tracker.

This data can be saved to a file for later use. See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.

1 filename = "saved_calibration.bin"
2 
3 # Save the calibration to file.
4 with open(filename, "wb") as f:
5  calibration_data = eyetracker.retrieve_calibration_data()
6 
7  # None is returned on empty calibration.
8  if calibration_data is not None:
9  print("Saving calibration to file for eye tracker with serial number {0}.".format(eyetracker.serial_number))
10  f.write(eyetracker.retrieve_calibration_data())
11  else:
12  print("No calibration available for eye tracker with serial number {0}.".format(eyetracker.serial_number))
13 
14 # Read the calibration from file.
15 with open(filename, "rb") as f:
16  calibration_data = f.read()
17 
18  # Don't apply empty calibrations.
19  if len(calibration_data) > 0:
20  print("Applying calibration on eye tracker with serial number {0}.".format(eyetracker.serial_number))
21  eyetracker.apply_calibration_data(calibration_data)
Exceptions
EyeTrackerConnectionFailedError
EyeTrackerInternalError
EyeTrackerLicenseError
def tobii_research.EyeTracker.set_device_name (   self,
  device_name 
)

Changes the device name.

This is not supported by all eye trackers. See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.

1 import tobii_research as tr
2 
3 print("The current name of the eye tracker is {0}".format(eyetracker.device_name))
4 
5 try:
6  eyetracker.set_device_name("A new name")
7  print("The eye tracker changed name to {0}".format(eyetracker.device_name))
8 except tr.EyeTrackerFeatureNotSupportedError:
9  print("This eye tracker doesn't support changing the device name.")
10 except tr.EyeTrackerLicenseError:
11  print("You need a higher level license to change the device name.")
Parameters
device_nameThe eye tracker's desired name.
Exceptions
EyeTrackerFeatureNotSupportedError
EyeTrackerConnectionFailedError
EyeTrackerInternalError
EyeTrackerLicenseError
def tobii_research.EyeTracker.set_display_area (   self,
  display_area 
)

Sets the display area of the eye tracker.

It is strongly recommended to use Eye Tracker Manager to calculate the display area coordinates as the origin of the User Coordinate System differs between eye tracker models. See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.

1 from tobii_research import DisplayArea
2 
3 display_area = eyetracker.get_display_area()
4 
5 print("Got display area from tracker with serial number {0}:".format(eyetracker.serial_number))
6 
7 print("Bottom Left: {0}".format(display_area.bottom_left))
8 print("Bottom Right: {0}".format(display_area.bottom_right))
9 print("Height: {0}".format(display_area.height))
10 print("Top Left: {0}".format(display_area.top_left))
11 print("Top Right: {0}".format(display_area.top_right))
12 print("Width: {0}".format(display_area.width))
13 
14 # To set the display area it is possible to either use a previously saved instance of
15 # the class Display area, or create a new one as shown bellow.
16 new_display_area_dict = dict()
17 new_display_area_dict['top_left'] = display_area.top_left
18 new_display_area_dict['top_right'] = display_area.top_right
19 new_display_area_dict['bottom_left'] = display_area.bottom_left
20 
21 new_display_area = DisplayArea(new_display_area_dict)
22 
23 eyetracker.set_display_area(new_display_area)
Parameters
display_areaThe eye tracker's desired display_area as a DisplayArea object.
Exceptions
EyeTrackerFeatureNotSupportedError
EyeTrackerConnectionFailedError
EyeTrackerInternalError
EyeTrackerLicenseError
def tobii_research.EyeTracker.set_eye_tracking_mode (   self,
  eye_tracking_mode 
)

Sets the eye tracking mode of the eye tracker.

See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.

1 initial_eye_tracking_mode = eyetracker.get_eye_tracking_mode()
2 
3 print("The eye tracker's initial eye tracking mode is {0}.".format(initial_eye_tracking_mode))
4 
5 try:
6  for eye_tracking_mode in eyetracker.get_all_eye_tracking_modes():
7  eyetracker.set_eye_tracking_mode(eye_tracking_mode)
8  print("Eye tracking mode set to {0}.".format(eye_tracking_mode))
9 finally:
10  eyetracker.set_eye_tracking_mode(initial_eye_tracking_mode)
11  print("Eye tracking mode reset to {0}.".format(initial_eye_tracking_mode))
Parameters
eye_tracking_modeThe eye tracking mode as a string.
Exceptions
EyeTrackerConnectionFailedError
EyeTrackerInternalError
EyeTrackerLicenseError
ValueError
def tobii_research.EyeTracker.set_gaze_output_frequency (   self,
  gaze_output_frequency 
)

Sets the gaze output frequency of the eye tracker.

See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.

1 initial_gaze_output_frequency = eyetracker.get_gaze_output_frequency()
2 
3 print("The eye tracker's initial gaze output frequency is {0} Hz.".format(initial_gaze_output_frequency))
4 
5 try:
6  for gaze_output_frequency in eyetracker.get_all_gaze_output_frequencies():
7  eyetracker.set_gaze_output_frequency(gaze_output_frequency)
8  print("Gaze output frequency set to {0} Hz.".format(gaze_output_frequency))
9 finally:
10  eyetracker.set_gaze_output_frequency(initial_gaze_output_frequency)
11  print("Gaze output frequency reset to {0} Hz.".format(initial_gaze_output_frequency))
Parameters
gaze_output_frequencyThe gaze output frequency as a float value.
Exceptions
EyeTrackerConnectionFailedError
EyeTrackerInternalError
EyeTrackerLicenseError
ValueError
def tobii_research.EyeTracker.set_hmd_lens_configuration (   self,
  lens_configuration 
)

Sets the lens configuration of the HMD based eye tracker.

The lens configuration describes how the lenses of the HMD device are positioned See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.

1 from tobii_research import HMDLensConfiguration
2 
3 lens_configuration = HMDLensConfiguration(left=(0.0, 0.0, 0.0), right=(0.0, 0.0, 0.0))
4 
5 eyetracker.set_hmd_lens_configuration(lens_configuration)
Parameters
lens_configurationThe eye tracker's desired lens configuration as a HMDLensConfiguration object.
Exceptions
EyeTrackerFeatureNotSupportedError
EyeTrackerConnectionFailedError
EyeTrackerInternalError
EyeTrackerLicenseError
def tobii_research.EyeTracker.subscribe_to (   self,
  subscription_type,
  callback,
  as_dictionary = False 
)

Subscribes to data for the eye tracker.

See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object. You can subscribe to EYETRACKER_EXTERNAL_SIGNAL, EYETRACKER_EYE_IMAGES, EYETRACKER_HMD_GAZE_DATA, EYETRACKER_GAZE_DATA, EYETRACKER_USER_POSITION_GUIDE, EYETRACKER_NOTIFICATION_CONNECTION_LOST, EYETRACKER_NOTIFICATION_CONNECTION_RESTORED, EYETRACKER_NOTIFICATION_CALIBRATION_MODE_ENTERED, EYETRACKER_NOTIFICATION_CALIBRATION_MODE_LEFT, EYETRACKER_NOTIFICATION_CALIBRATION_CHANGED, EYETRACKER_NOTIFICATION_TRACK_BOX_CHANGED, EYETRACKER_NOTIFICATION_DISPLAY_AREA_CHANGED, EYETRACKER_NOTIFICATION_GAZE_OUTPUT_FREQUENCY_CHANGED, EYETRACKER_NOTIFICATION_EYE_TRACKING_MODE_CHANGED, EYETRACKER_NOTIFICATION_DEVICE_FAULTS, EYETRACKER_NOTIFICATION_DEVICE_WARNINGS, EYETRACKER_TIME_SYNCHRONIZATION_DATA or EYETRACKER_STREAM_ERRORS.

1 import time
2 import tobii_research as tr
3 
4 global_gaze_data = None
5 
6 
7 def gaze_data_callback(gaze_data):
8  global global_gaze_data
9  global_gaze_data = gaze_data
10 
11 
12 def gaze_data(eyetracker):
13  global global_gaze_data
14 
15  print("Subscribing to gaze data for eye tracker with serial number {0}.".format(eyetracker.serial_number))
16  eyetracker.subscribe_to(tr.EYETRACKER_GAZE_DATA, gaze_data_callback, as_dictionary=True)
17 
18  # Wait while some gaze data is collected.
19  time.sleep(2)
20 
21  eyetracker.unsubscribe_from(tr.EYETRACKER_GAZE_DATA, gaze_data_callback)
22  print("Unsubscribed from gaze data.")
23 
24  print("Last received gaze package:")
25  print(global_gaze_data)
Parameters
subscription_typeType of data to subscribe to.
callbackCallback receiveing the data. See documentation of subscription types for details.
as_dictionaryIf True, the callback will receive a dictionary with values instead of a custom object.
def tobii_research.EyeTracker.unsubscribe_from (   self,
  subscription_type,
  callback = None 
)

Unsubscribes from data for the eye tracker.

See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object. You can unsubscribe from EYETRACKER_EXTERNAL_SIGNAL, EYETRACKER_EYE_IMAGES, EYETRACKER_GAZE_DATA, EYETRACKER_HMD_GAZE_DATA, EYETRACKER_USER_POSITION_GUIDE, EYETRACKER_NOTIFICATION_CONNECTION_LOST, EYETRACKER_NOTIFICATION_CONNECTION_RESTORED, EYETRACKER_NOTIFICATION_CALIBRATION_MODE_ENTERED, EYETRACKER_NOTIFICATION_CALIBRATION_MODE_LEFT, EYETRACKER_NOTIFICATION_CALIBRATION_CHANGED, EYETRACKER_NOTIFICATION_TRACK_BOX_CHANGED, EYETRACKER_NOTIFICATION_DISPLAY_AREA_CHANGED, EYETRACKER_NOTIFICATION_GAZE_OUTPUT_FREQUENCY_CHANGED, EYETRACKER_NOTIFICATION_EYE_TRACKING_MODE_CHANGED, EYETRACKER_NOTIFICATION_DEVICE_FAULTS, EYETRACKER_NOTIFICATION_DEVICE_WARNINGS, EYETRACKER_TIME_SYNCHRONIZATION_DATA or EYETRACKER_STREAM_ERRORS.

1 import time
2 import tobii_research as tr
3 
4 global_gaze_data = None
5 
6 
7 def gaze_data_callback(gaze_data):
8  global global_gaze_data
9  global_gaze_data = gaze_data
10 
11 
12 def gaze_data(eyetracker):
13  global global_gaze_data
14 
15  print("Subscribing to gaze data for eye tracker with serial number {0}.".format(eyetracker.serial_number))
16  eyetracker.subscribe_to(tr.EYETRACKER_GAZE_DATA, gaze_data_callback, as_dictionary=True)
17 
18  # Wait while some gaze data is collected.
19  time.sleep(2)
20 
21  eyetracker.unsubscribe_from(tr.EYETRACKER_GAZE_DATA, gaze_data_callback)
22  print("Unsubscribed from gaze data.")
23 
24  print("Last received gaze package:")
25  print(global_gaze_data)
Parameters
subscription_typeType of data to unsubscribe from.
callbackCallback sent to subscribe_to or None to unsubscribe all subscriptions of this type.

Field Documentation

tobii_research.EyeTracker.device_capabilities

Gets a tuple with the capabilities of the device.

Valid values in the tuple are CAPABILITY_CAN_SET_DISPLAY_AREA, CAPABILITY_HAS_EXTERNAL_SIGNAL and CAPABILITY_HAS_EYE_IMAGES.

tobii_research.EyeTracker.serial_number

Gets the serial number of the eye tracker.

All physical eye trackers have a unique serial number.