Tobii Pro SDK Python API
tobii_research.HMDBasedCalibration Class Reference

Represents the calibration data used by the eye tracker. More...

Inherits object.

Public Member Functions

def __init__ (self, eyetracker)
 Initialize a new HMDBasedCalibration object from an existing EyeTracker object.
 
def enter_calibration_mode (self)
 Enters the calibration mode and the eye tracker is made ready for collecting data and calculating new calibrations. More...
 
def leave_calibration_mode (self)
 Leaves the calibration mode. More...
 
def collect_data (self, x, y, z)
 Starts collecting data for a calibration point. More...
 
def compute_and_apply (self)
 Uses the data in the temporary buffer and tries to compute calibration parameters. More...
 

Detailed Description

Represents the calibration data used by the eye tracker.

Member Function Documentation

def tobii_research.HMDBasedCalibration.collect_data (   self,
  x,
  y,
  z 
)

Starts collecting data for a calibration point.

The argument used is the point the calibration user is assumed to be looking at and is given in the HMD coordinate system. See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.

1 import time
2 import tobii_research as tr
3 
4 calibration = tr.HMDBasedCalibration(eyetracker)
5 
6 # Enter calibration mode.
7 calibration.enter_calibration_mode()
8 print("Entered calibration mode for eye tracker with serial number {0}.".format(eyetracker.serial_number))
9 
10 # Define the points on the HMD we should calibrate at.
11 # The coordinates are are in the HMD coordinate system.
12 points_to_calibrate = [(0.0, 0.0, 100.0), (20.0, 0.0, 100.0), (0.0, 20.0, 100.0)]
13 
14 for point in points_to_calibrate:
15  print("Show a point on the HMD at {0}.".format(point))
16 
17  # Wait a little for user to focus.
18  time.sleep(0.7)
19 
20  print("Collecting data at {0}.".format(point))
21  if calibration.collect_data(point[0], point[1], point[2]) != tr.CALIBRATION_STATUS_SUCCESS:
22  # Try again if it didn't go well the first time.
23  # Not all eye tracker models will fail at this point, but instead fail on ComputeAndApply.
24  calibration.collect_data(point[0], point[1], point[2])
25 
26 print("Computing and applying calibration.")
27 calibration_result = calibration.compute_and_apply()
28 print("Compute and apply returned {0} and collected at {1} points.".
29  format(calibration_result.status, len(calibration_result.calibration_points)))
30 
31 # The calibration is done. Leave calibration mode.
32 calibration.leave_calibration_mode()
33 
34 print("Left calibration mode.")
Parameters
xx coordinate in the HMD coordinate system.
yy coordinate in the HMD coordinate system.
zz coordinate in the HMD coordinate system.
Exceptions
EyeTrackerConnectionFailedError
EyeTrackerFeatureNotSupportedError
EyeTrackerInvalidOperationError
EyeTrackerLicenseError
EyeTrackerInternalError
Returns
CALIBRATION_STATUS_SUCCESS on success. CALIBRATION_STATUS_FAILURE on failure.
def tobii_research.HMDBasedCalibration.compute_and_apply (   self)

Uses the data in the temporary buffer and tries to compute calibration parameters.

If the call is successful, the data is copied from the temporary buffer to the active buffer. If there is insufficient data to compute a new calibration or if the collected data is not good enough then an exception will be raised. See find_all_eyetrackers or EyeTracker.__init__ on how to create an EyeTracker object.

1 import time
2 import tobii_research as tr
3 
4 calibration = tr.ScreenBasedCalibration(eyetracker)
5 
6 # Enter calibration mode.
7 calibration.enter_calibration_mode()
8 print("Entered calibration mode for eye tracker with serial number {0}.".format(eyetracker.serial_number))
9 
10 # Define the points on screen we should calibrate at.
11 # The coordinates are normalized, i.e. (0.0, 0.0) is the upper left corner and (1.0, 1.0) is the lower right corner.
12 points_to_calibrate = [(0.5, 0.5), (0.1, 0.1), (0.1, 0.9), (0.9, 0.1), (0.9, 0.9)]
13 
14 for point in points_to_calibrate:
15  print("Show a point on screen at {0}.".format(point))
16 
17  # Wait a little for user to focus.
18  time.sleep(0.7)
19 
20  print("Collecting data at {0}.".format(point))
21  if calibration.collect_data(point[0], point[1]) != tr.CALIBRATION_STATUS_SUCCESS:
22  # Try again if it didn't go well the first time.
23  # Not all eye tracker models will fail at this point, but instead fail on ComputeAndApply.
24  calibration.collect_data(point[0], point[1])
25 
26 print("Computing and applying calibration.")
27 calibration_result = calibration.compute_and_apply()
28 print("Compute and apply returned {0} and collected at {1} points.".
29  format(calibration_result.status, len(calibration_result.calibration_points)))
30 
31 # Analyze the data and maybe remove points that weren't good.
32 recalibrate_point = (0.1, 0.1)
33 print("Removing calibration point at {0}.".format(recalibrate_point))
34 calibration.discard_data(recalibrate_point[0], recalibrate_point[1])
35 
36 # Redo collection at the discarded point
37 print("Show a point on screen at {0}.".format(recalibrate_point))
38 calibration.collect_data(recalibrate_point[0], recalibrate_point[1])
39 
40 # Compute and apply again.
41 print("Computing and applying calibration.")
42 calibration_result = calibration.compute_and_apply()
43 print("Compute and apply returned {0} and collected at {1} points.".
44  format(calibration_result.status, len(calibration_result.calibration_points)))
45 
46 # See that you're happy with the result.
47 
48 # The calibration is done. Leave calibration mode.
49 calibration.leave_calibration_mode()
50 
51 print("Left calibration mode.")
Exceptions
EyeTrackerConnectionFailedError
EyeTrackerFeatureNotSupportedError
EyeTrackerInvalidOperationError
EyeTrackerLicenseError
EyeTrackerInternalError
Returns
A CalibrationResult object.
def tobii_research.HMDBasedCalibration.enter_calibration_mode (   self)

Enters the calibration mode and the eye tracker is made ready for collecting data and calculating new calibrations.

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

1 import time
2 import tobii_research as tr
3 
4 calibration = tr.HMDBasedCalibration(eyetracker)
5 
6 # Enter calibration mode.
7 calibration.enter_calibration_mode()
8 print("Entered calibration mode for eye tracker with serial number {0}.".format(eyetracker.serial_number))
9 
10 # Define the points on the HMD we should calibrate at.
11 # The coordinates are are in the HMD coordinate system.
12 points_to_calibrate = [(0.0, 0.0, 100.0), (20.0, 0.0, 100.0), (0.0, 20.0, 100.0)]
13 
14 for point in points_to_calibrate:
15  print("Show a point on the HMD at {0}.".format(point))
16 
17  # Wait a little for user to focus.
18  time.sleep(0.7)
19 
20  print("Collecting data at {0}.".format(point))
21  if calibration.collect_data(point[0], point[1], point[2]) != tr.CALIBRATION_STATUS_SUCCESS:
22  # Try again if it didn't go well the first time.
23  # Not all eye tracker models will fail at this point, but instead fail on ComputeAndApply.
24  calibration.collect_data(point[0], point[1], point[2])
25 
26 print("Computing and applying calibration.")
27 calibration_result = calibration.compute_and_apply()
28 print("Compute and apply returned {0} and collected at {1} points.".
29  format(calibration_result.status, len(calibration_result.calibration_points)))
30 
31 # The calibration is done. Leave calibration mode.
32 calibration.leave_calibration_mode()
33 
34 print("Left calibration mode.")
Exceptions
EyeTrackerConnectionFailedError
EyeTrackerFeatureNotSupportedError
EyeTrackerInvalidOperationError
EyeTrackerLicenseError
EyeTrackerInternalError
def tobii_research.HMDBasedCalibration.leave_calibration_mode (   self)

Leaves the calibration mode.

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

1 import time
2 import tobii_research as tr
3 
4 calibration = tr.HMDBasedCalibration(eyetracker)
5 
6 # Enter calibration mode.
7 calibration.enter_calibration_mode()
8 print("Entered calibration mode for eye tracker with serial number {0}.".format(eyetracker.serial_number))
9 
10 # Define the points on the HMD we should calibrate at.
11 # The coordinates are are in the HMD coordinate system.
12 points_to_calibrate = [(0.0, 0.0, 100.0), (20.0, 0.0, 100.0), (0.0, 20.0, 100.0)]
13 
14 for point in points_to_calibrate:
15  print("Show a point on the HMD at {0}.".format(point))
16 
17  # Wait a little for user to focus.
18  time.sleep(0.7)
19 
20  print("Collecting data at {0}.".format(point))
21  if calibration.collect_data(point[0], point[1], point[2]) != tr.CALIBRATION_STATUS_SUCCESS:
22  # Try again if it didn't go well the first time.
23  # Not all eye tracker models will fail at this point, but instead fail on ComputeAndApply.
24  calibration.collect_data(point[0], point[1], point[2])
25 
26 print("Computing and applying calibration.")
27 calibration_result = calibration.compute_and_apply()
28 print("Compute and apply returned {0} and collected at {1} points.".
29  format(calibration_result.status, len(calibration_result.calibration_points)))
30 
31 # The calibration is done. Leave calibration mode.
32 calibration.leave_calibration_mode()
33 
34 print("Left calibration mode.")
Exceptions
EyeTrackerConnectionFailedError
EyeTrackerFeatureNotSupportedError
EyeTrackerInvalidOperationError
EyeTrackerLicenseError
EyeTrackerInternalError