Tobii Pro SDK Unity API
Tobii.Research.IEyeTracker Interface Reference

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

Inheritance diagram for Tobii.Research.IEyeTracker:

Public Member Functions

GazeOutputFrequencyCollection GetAllGazeOutputFrequencies ()
 Gets a list of gaze output frequencies supported by the eye tracker. More...
 
float GetGazeOutputFrequency ()
 Gets the gaze output frequency of the eye tracker. More...
 
void SetGazeOutputFrequency (float gazeOutputFrequency)
 Sets the gaze output frequency of the eye tracker. More...
 
EyeTrackingModeCollection GetAllEyeTrackingModes ()
 Gets a list of eye tracking modes supported by the eye tracker. More...
 
string GetEyeTrackingMode ()
 Gets the eye tracking mode of the eye tracker. More...
 
void SetEyeTrackingMode (string eyeTrackingMode)
 Sets the eye tracking mode of the eye tracker. More...
 
CalibrationData RetrieveCalibrationData ()
 Gets the calibration data used currently by the eye tracker. This data can be saved to a file for later use. More...
 
void ApplyCalibrationData (CalibrationData calibrationData)
 Sets the provided calibration data to the eye tracker, which means it will be active calibration. More...
 
bool TryApplyLicenses (LicenseCollection licenses, out FailedLicenseCollection failedLicenses)
 Apply one or more licenses to unlock features of the eye tracker. A return value indicates whether all licenses where applied or not. More...
 
void ClearAppliedLicenses ()
 Clears any previously applied licenses. More...
 
TrackBox GetTrackBox ()
 Gets the track box of the eye tracker. More...
 
DisplayArea GetDisplayArea ()
 Gets the size and corners of the display area. More...
 
void SetDisplayArea (DisplayArea displayArea)
 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." More...
 
void SetDeviceName (string deviceName)
 Changes the device name. This is not supported by all eye trackers. More...
 
HMDLensConfiguration GetHMDLensConfiguration ()
 Gets the current lens configuration of the HMD based eye tracker. The lens configuration describes how the lenses of the HMD device are positioned. More...
 
void SetHMDLensConfiguration (HMDLensConfiguration hmdLensConfiguration)
 Sets the lens configuration of the HMD based eye tracker. The lens configuration describes how the lenses of the HMD device are positioned. More...
 

Properties

Uri Address [get]
 Gets the address (URI) of the eye tracker device. More...
 
string DeviceName [get]
 Gets the name of the eye tracker. More...
 
string SerialNumber [get]
 Gets the serial number of the eye tracker. All physical eye trackers have a unique serial number. More...
 
string Model [get]
 Gets the model of the eye tracker. More...
 
string FirmwareVersion [get]
 Gets the firmware version of the eye tracker. More...
 
Capabilities DeviceCapabilities [get]
 Gets the capabilities of the device. More...
 

Events

EventHandler< GazeDataEventArgsGazeDataReceived
 Event fired when gaze data is received. More...
 
EventHandler< HMDGazeDataEventArgsHMDGazeDataReceived
 Event fired when HMD gaze data is received. More...
 
EventHandler< TimeSynchronizationReferenceEventArgsTimeSynchronizationReferenceReceived
 Occurs when the computer and the eye trackers clocks gets synchronized. To handle normal drifts between clocks the clocks are checked on regular basis, and this results in that the time stamps are adjusted for the drifts in the data streams. This drift handling is done in real time. The data received from this event could be used for an even more accurate drift adjustment in the post processing. More...
 
EventHandler< ExternalSignalValueEventArgsExternalSignalReceived
 Occurs when the value of the external signal port (TTL input) on the eye tracker device changes. Not all eye trackers have a sampling trigger port. The sampling feature could be used to synchronize the eye tracker data with data from other devices. The sampling data contains a time reference that matches the time reference on the time synchronized gaze data. More...
 
EventHandler< EventErrorEventArgsEventErrorOccurred
 Fired when an error occurs on any of the other events for the eye tracker. More...
 
EventHandler< EyeImageEventArgsEyeImageReceived
 Occurs when a new eye image is received, and the occurrence depends on the eye tracker model. Not all eye tracker models support this feature. If no one is listening to gaze data, the eye tracker will only deliver full images, otherwise either cropped or full images will be delivered depending on whether or not the eye tracker has detected eyes. More...
 
EventHandler< EyeImageRawEventArgsEyeImageRawReceived
 Occurs when a new eye image raw is received, and the occurrence depends on the eye tracker model. Not all eye tracker models support this feature. If no one is listening to gaze data, the eye tracker will only deliver full images, otherwise either cropped or full images will be delivered depending on whether or not the eye tracker has detected eyes. More...
 
EventHandler< GazeOutputFrequencyEventArgsGazeOutputFrequencyChanged
 Occurs when the gaze output frequency has changed. More...
 
EventHandler< CalibrationModeEnteredEventArgsCalibrationModeEntered
 Occurs when the eye tracker enters calibration mode. More...
 
EventHandler< CalibrationModeLeftEventArgsCalibrationModeLeft
 Occurs when the eye tracker leaves calibration mode. More...
 
EventHandler< CalibrationChangedEventArgsCalibrationChanged
 Occurs when the calibration is changed for the eye tracker. More...
 
EventHandler< DisplayAreaEventArgsDisplayAreaChanged
 Occurs when the display area has changed. More...
 
EventHandler< ConnectionLostEventArgsConnectionLost
 Occurs when the client loses connection to the eye tracker. More...
 
EventHandler< ConnectionRestoredEventArgsConnectionRestored
 Occurs when connection to the eye tracker is restored. More...
 
EventHandler< TrackBoxEventArgsTrackBoxChanged
 Occurs when the track box size has changed. More...
 
EventHandler< EyeTrackingModeChangedEventArgsEyeTrackingModeChanged
 Occurs when the eye tracking mode has changed. More...
 

Detailed Description

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

Member Function Documentation

void Tobii.Research.IEyeTracker.ApplyCalibrationData ( CalibrationData  calibrationData)

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

Parameters
calibrationDataThe calibration data to apply.
private static void CalibrationData(IEyeTracker eyeTracker)
{
// Create a file in the current directory and store the calibration data in it.
string path = "calibrationData.xml";
using (System.IO.FileStream fileStream = System.IO.File.Create(path))
{
var dataContractSerializer = new System.Runtime.Serialization.DataContractSerializer(typeof(CalibrationData));
// Retrieve the calibration data from the eye tracker.
CalibrationData calibrationData = eyeTracker.RetrieveCalibrationData();
// Save the calibration data to the file;
dataContractSerializer.WriteObject(fileStream, calibrationData);
}
// Reopen the file and read the calibration data back.
using (System.IO.FileStream fileStream = System.IO.File.OpenRead(path))
{
var dataContractSerializer = new System.Runtime.Serialization.DataContractSerializer(typeof(CalibrationData));
// Read the calibration data from file.
CalibrationData calibrationData = dataContractSerializer.ReadObject(fileStream) as CalibrationData;
// Don't apply empty calibration.
if (calibrationData.Data.Length != 0)
{
// Apply the calibration data to the eye tracker.
eyeTracker.ApplyCalibrationData(calibrationData);
}
}
}
void Tobii.Research.IEyeTracker.ClearAppliedLicenses ( )

Clears any previously applied licenses.

private static void ApplyLicense(IEyeTracker eyeTracker, string licensePath)
{
// Create a collection with the license.
var licenseCollection = new LicenseCollection(
new System.Collections.Generic.List<LicenseKey>
{
new LicenseKey(System.IO.File.ReadAllBytes(licensePath))
});
// See if we can apply the license.
FailedLicenseCollection failedLicenses;
if (eyeTracker.TryApplyLicenses(licenseCollection, out failedLicenses))
{
Debug.Log(string.Format(
"Successfully applied license from {0} on eye tracker with serial number {1}.",
licensePath, eyeTracker.SerialNumber));
}
else
{
Debug.Log(string.Format(
"Failed to apply license from {0} on eye tracker with serial number {1}.\n" +
"The validation result is {2}.",
licensePath, eyeTracker.SerialNumber, failedLicenses[0].ValidationResult));
}
}
EyeTrackingModeCollection Tobii.Research.IEyeTracker.GetAllEyeTrackingModes ( )

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

Returns
A list of valid and available eye tracking modes.
internal static void EyeTrackingModes(IEyeTracker eyeTracker)
{
Debug.Log(string.Format("\nEye tracking modes."));
// Get and store current eye tracking mode so it can be restored.
var initialEyeTrackingMode = eyeTracker.GetEyeTrackingMode();
Debug.Log(string.Format("New eye tracking mode is: {0}.", initialEyeTrackingMode));
try
{
// Get all eye tracking modes.
var allEyeTrackingModes = eyeTracker.GetAllEyeTrackingModes();
foreach (var eyeTrackingMode in allEyeTrackingModes)
{
eyeTracker.SetEyeTrackingMode(eyeTrackingMode);
Debug.Log(string.Format("New eye tracking mode is: {0}.", eyeTrackingMode.ToString()));
}
}
finally
{
eyeTracker.SetEyeTrackingMode(initialEyeTrackingMode);
Debug.Log(string.Format("Eye tracking mode reset to: {0}.", eyeTracker.GetEyeTrackingMode()));
}
}
GazeOutputFrequencyCollection Tobii.Research.IEyeTracker.GetAllGazeOutputFrequencies ( )

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

Returns
A list of valid and available gaze output frequencies in hertz.
static void GazeOutputFrequencies(IEyeTracker eyeTracker)
{
Debug.Log(string.Format("\nGaze output frequencies."));
// Get and store current frequency so it can be restored.
var initialGazeOutputFrequency = eyeTracker.GetGazeOutputFrequency();
Debug.Log(string.Format("Gaze output frequency is: {0} hertz.", initialGazeOutputFrequency));
try
{
// Get all gaze output frequencies.
var allGazeOutputFrequencies = eyeTracker.GetAllGazeOutputFrequencies();
foreach (var gazeOutputFrequency in allGazeOutputFrequencies)
{
eyeTracker.SetGazeOutputFrequency(gazeOutputFrequency);
Debug.Log(string.Format("New gaze output frequency is: {0} hertz.", gazeOutputFrequency.ToString()));
}
}
finally
{
eyeTracker.SetGazeOutputFrequency(initialGazeOutputFrequency);
Debug.Log(string.Format("Gaze output frequency reset to: {0} hertz.", eyeTracker.GetGazeOutputFrequency()));
}
}
DisplayArea Tobii.Research.IEyeTracker.GetDisplayArea ( )

Gets the size and corners of the display area.

Returns
The eye tracker's display area.
private static void PrintDisplayArea(IEyeTracker eyeTracker)
{
// Get the display area.
DisplayArea displayArea = eyeTracker.GetDisplayArea();
Debug.Log(string.Format(
"Got display area from tracker with serial number {0} with height {1}, width {2} and coordinates:",
eyeTracker.SerialNumber,
displayArea.Height,
displayArea.Width));
Debug.Log(string.Format("Bottom Left: ({0}, {1}, {2})",
displayArea.BottomLeft.X, displayArea.BottomLeft.Y, displayArea.BottomLeft.Z));
Debug.Log(string.Format("Bottom Right: ({0}, {1}, {2})",
displayArea.BottomRight.X, displayArea.BottomRight.Y, displayArea.BottomRight.Z));
Debug.Log(string.Format("Top Left: ({0}, {1}, {2})",
displayArea.TopLeft.X, displayArea.TopLeft.Y, displayArea.TopLeft.Z));
Debug.Log(string.Format("Top Right: ({0}, {1}, {2})",
displayArea.TopRight.X, displayArea.TopRight.Y, displayArea.TopRight.Z));
// Set the display area. A new object is used to show usage.
DisplayArea displayAreaToSet = new DisplayArea(displayArea.TopLeft, displayArea.BottomLeft, displayArea.TopRight);
eyeTracker.SetDisplayArea(displayAreaToSet);
}
string Tobii.Research.IEyeTracker.GetEyeTrackingMode ( )

Gets the eye tracking mode of the eye tracker.

Returns
The eye tracking mode.
internal static void EyeTrackingModes(IEyeTracker eyeTracker)
{
Debug.Log(string.Format("\nEye tracking modes."));
// Get and store current eye tracking mode so it can be restored.
var initialEyeTrackingMode = eyeTracker.GetEyeTrackingMode();
Debug.Log(string.Format("New eye tracking mode is: {0}.", initialEyeTrackingMode));
try
{
// Get all eye tracking modes.
var allEyeTrackingModes = eyeTracker.GetAllEyeTrackingModes();
foreach (var eyeTrackingMode in allEyeTrackingModes)
{
eyeTracker.SetEyeTrackingMode(eyeTrackingMode);
Debug.Log(string.Format("New eye tracking mode is: {0}.", eyeTrackingMode.ToString()));
}
}
finally
{
eyeTracker.SetEyeTrackingMode(initialEyeTrackingMode);
Debug.Log(string.Format("Eye tracking mode reset to: {0}.", eyeTracker.GetEyeTrackingMode()));
}
}
float Tobii.Research.IEyeTracker.GetGazeOutputFrequency ( )

Gets the gaze output frequency of the eye tracker.

Returns
The gaze output frequency in hertz.
static void GazeOutputFrequencies(IEyeTracker eyeTracker)
{
Debug.Log(string.Format("\nGaze output frequencies."));
// Get and store current frequency so it can be restored.
var initialGazeOutputFrequency = eyeTracker.GetGazeOutputFrequency();
Debug.Log(string.Format("Gaze output frequency is: {0} hertz.", initialGazeOutputFrequency));
try
{
// Get all gaze output frequencies.
var allGazeOutputFrequencies = eyeTracker.GetAllGazeOutputFrequencies();
foreach (var gazeOutputFrequency in allGazeOutputFrequencies)
{
eyeTracker.SetGazeOutputFrequency(gazeOutputFrequency);
Debug.Log(string.Format("New gaze output frequency is: {0} hertz.", gazeOutputFrequency.ToString()));
}
}
finally
{
eyeTracker.SetGazeOutputFrequency(initialGazeOutputFrequency);
Debug.Log(string.Format("Gaze output frequency reset to: {0} hertz.", eyeTracker.GetGazeOutputFrequency()));
}
}
HMDLensConfiguration Tobii.Research.IEyeTracker.GetHMDLensConfiguration ( )

Gets the current lens configuration of the HMD based eye tracker. The lens configuration describes how the lenses of the HMD device are positioned.

Returns
Returns the HMD lens configuration.
TrackBox Tobii.Research.IEyeTracker.GetTrackBox ( )

Gets the track box of the eye tracker.

Returns
Returns the track box of the eye tracker.
private static void PrintTrackBox(IEyeTracker eyeTracker)
{
// Get the track box.
TrackBox trackBox = eyeTracker.GetTrackBox();
Debug.Log(string.Format(string.Format("Got track box from tracker with serial number {0} with corners:", eyeTracker.SerialNumber)));
Debug.Log(string.Format("Back Lower Left: ({0}, {1}, {2})",
trackBox.BackLowerLeft.X, trackBox.BackLowerLeft.Y, trackBox.BackLowerLeft.Z));
Debug.Log(string.Format("Back Lower Right: ({0}, {1}, {2})",
trackBox.BackLowerRight.X, trackBox.BackLowerRight.Y, trackBox.BackLowerRight.Z));
Debug.Log(string.Format("Back Upper Left: ({0}, {1}, {2})",
trackBox.BackUpperLeft.X, trackBox.BackUpperLeft.Y, trackBox.BackUpperLeft.Z));
Debug.Log(string.Format("Back Upper Right: ({0}, {1}, {2})",
trackBox.BackUpperRight.X, trackBox.BackUpperRight.Y, trackBox.BackUpperRight.Z));
Debug.Log(string.Format("Front Lower Left: ({0}, {1}, {2})",
trackBox.FrontLowerLeft.X, trackBox.FrontLowerLeft.Y, trackBox.FrontLowerLeft.Z));
Debug.Log(string.Format("Front Lower Right: ({0}, {1}, {2})",
trackBox.FrontLowerRight.X, trackBox.FrontLowerRight.Y, trackBox.FrontLowerRight.Z));
Debug.Log(string.Format("Front Upper Left: ({0}, {1}, {2})",
trackBox.FrontUpperLeft.X, trackBox.FrontUpperLeft.Y, trackBox.FrontUpperLeft.Z));
Debug.Log(string.Format("Front Upper Right: ({0}, {1}, {2})",
trackBox.FrontUpperRight.X, trackBox.FrontUpperRight.Y, trackBox.FrontUpperRight.Z));
}
CalibrationData Tobii.Research.IEyeTracker.RetrieveCalibrationData ( )

Gets the calibration data used currently by the eye tracker. This data can be saved to a file for later use.

Returns
The retrieved calibration data.
private static void CalibrationData(IEyeTracker eyeTracker)
{
// Create a file in the current directory and store the calibration data in it.
string path = "calibrationData.xml";
using (System.IO.FileStream fileStream = System.IO.File.Create(path))
{
var dataContractSerializer = new System.Runtime.Serialization.DataContractSerializer(typeof(CalibrationData));
// Retrieve the calibration data from the eye tracker.
CalibrationData calibrationData = eyeTracker.RetrieveCalibrationData();
// Save the calibration data to the file;
dataContractSerializer.WriteObject(fileStream, calibrationData);
}
// Reopen the file and read the calibration data back.
using (System.IO.FileStream fileStream = System.IO.File.OpenRead(path))
{
var dataContractSerializer = new System.Runtime.Serialization.DataContractSerializer(typeof(CalibrationData));
// Read the calibration data from file.
CalibrationData calibrationData = dataContractSerializer.ReadObject(fileStream) as CalibrationData;
// Don't apply empty calibration.
if (calibrationData.Data.Length != 0)
{
// Apply the calibration data to the eye tracker.
eyeTracker.ApplyCalibrationData(calibrationData);
}
}
}
void Tobii.Research.IEyeTracker.SetDeviceName ( string  deviceName)

Changes the device name. This is not supported by all eye trackers.

Parameters
deviceNameThe eye tracker's desired name.
void Tobii.Research.IEyeTracker.SetDisplayArea ( DisplayArea  displayArea)

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."

Parameters
displayAreaThe eye tracker's display area.
private static void PrintDisplayArea(IEyeTracker eyeTracker)
{
// Get the display area.
DisplayArea displayArea = eyeTracker.GetDisplayArea();
Debug.Log(string.Format(
"Got display area from tracker with serial number {0} with height {1}, width {2} and coordinates:",
eyeTracker.SerialNumber,
displayArea.Height,
displayArea.Width));
Debug.Log(string.Format("Bottom Left: ({0}, {1}, {2})",
displayArea.BottomLeft.X, displayArea.BottomLeft.Y, displayArea.BottomLeft.Z));
Debug.Log(string.Format("Bottom Right: ({0}, {1}, {2})",
displayArea.BottomRight.X, displayArea.BottomRight.Y, displayArea.BottomRight.Z));
Debug.Log(string.Format("Top Left: ({0}, {1}, {2})",
displayArea.TopLeft.X, displayArea.TopLeft.Y, displayArea.TopLeft.Z));
Debug.Log(string.Format("Top Right: ({0}, {1}, {2})",
displayArea.TopRight.X, displayArea.TopRight.Y, displayArea.TopRight.Z));
// Set the display area. A new object is used to show usage.
DisplayArea displayAreaToSet = new DisplayArea(displayArea.TopLeft, displayArea.BottomLeft, displayArea.TopRight);
eyeTracker.SetDisplayArea(displayAreaToSet);
}
void Tobii.Research.IEyeTracker.SetEyeTrackingMode ( string  eyeTrackingMode)

Sets the eye tracking mode of the eye tracker.

Parameters
eyeTrackingModeThe new eye tracking mode. The string must be from the list returned by GetAllEyeTrackingModes().
internal static void EyeTrackingModes(IEyeTracker eyeTracker)
{
Debug.Log(string.Format("\nEye tracking modes."));
// Get and store current eye tracking mode so it can be restored.
var initialEyeTrackingMode = eyeTracker.GetEyeTrackingMode();
Debug.Log(string.Format("New eye tracking mode is: {0}.", initialEyeTrackingMode));
try
{
// Get all eye tracking modes.
var allEyeTrackingModes = eyeTracker.GetAllEyeTrackingModes();
foreach (var eyeTrackingMode in allEyeTrackingModes)
{
eyeTracker.SetEyeTrackingMode(eyeTrackingMode);
Debug.Log(string.Format("New eye tracking mode is: {0}.", eyeTrackingMode.ToString()));
}
}
finally
{
eyeTracker.SetEyeTrackingMode(initialEyeTrackingMode);
Debug.Log(string.Format("Eye tracking mode reset to: {0}.", eyeTracker.GetEyeTrackingMode()));
}
}
void Tobii.Research.IEyeTracker.SetGazeOutputFrequency ( float  gazeOutputFrequency)

Sets the gaze output frequency of the eye tracker.

Parameters
gazeOutputFrequencyThe the gaze output frequency in hertz. The value must be from the list returned by GetAllGazeOutputFrequencies().
static void GazeOutputFrequencies(IEyeTracker eyeTracker)
{
Debug.Log(string.Format("\nGaze output frequencies."));
// Get and store current frequency so it can be restored.
var initialGazeOutputFrequency = eyeTracker.GetGazeOutputFrequency();
Debug.Log(string.Format("Gaze output frequency is: {0} hertz.", initialGazeOutputFrequency));
try
{
// Get all gaze output frequencies.
var allGazeOutputFrequencies = eyeTracker.GetAllGazeOutputFrequencies();
foreach (var gazeOutputFrequency in allGazeOutputFrequencies)
{
eyeTracker.SetGazeOutputFrequency(gazeOutputFrequency);
Debug.Log(string.Format("New gaze output frequency is: {0} hertz.", gazeOutputFrequency.ToString()));
}
}
finally
{
eyeTracker.SetGazeOutputFrequency(initialGazeOutputFrequency);
Debug.Log(string.Format("Gaze output frequency reset to: {0} hertz.", eyeTracker.GetGazeOutputFrequency()));
}
}
void Tobii.Research.IEyeTracker.SetHMDLensConfiguration ( HMDLensConfiguration  hmdLensConfiguration)

Sets the lens configuration of the HMD based eye tracker. The lens configuration describes how the lenses of the HMD device are positioned.

Parameters
hmdLensConfigurationThe lens configuration parameters to set.
bool Tobii.Research.IEyeTracker.TryApplyLicenses ( LicenseCollection  licenses,
out FailedLicenseCollection  failedLicenses 
)

Apply one or more licenses to unlock features of the eye tracker. A return value indicates whether all licenses where applied or not.

Parameters
licensesA LicenseCollection containing the licenses to apply.
failedLicensesThis method always return a FailedLicensesCollection. When this method is successful the collection is empty, when at least one license failed to be applied, then the collection contains the failed licenses together with a reason for failing.
Returns
True if all licenses were successfully applied.
private static void ApplyLicense(IEyeTracker eyeTracker, string licensePath)
{
// Create a collection with the license.
var licenseCollection = new LicenseCollection(
new System.Collections.Generic.List<LicenseKey>
{
new LicenseKey(System.IO.File.ReadAllBytes(licensePath))
});
// See if we can apply the license.
FailedLicenseCollection failedLicenses;
if (eyeTracker.TryApplyLicenses(licenseCollection, out failedLicenses))
{
Debug.Log(string.Format(
"Successfully applied license from {0} on eye tracker with serial number {1}.",
licensePath, eyeTracker.SerialNumber));
}
else
{
Debug.Log(string.Format(
"Failed to apply license from {0} on eye tracker with serial number {1}.\n" +
"The validation result is {2}.",
licensePath, eyeTracker.SerialNumber, failedLicenses[0].ValidationResult));
}
}

Property Documentation

Uri Tobii.Research.IEyeTracker.Address
get

Gets the address (URI) of the eye tracker device.

Capabilities Tobii.Research.IEyeTracker.DeviceCapabilities
get

Gets the capabilities of the device.

internal static IEyeTracker GetEyeTracker(Uri address)
{
Debug.Log(string.Format("\nGet eye tracker from Uri: {0}.", address));
var eyeTracker = EyeTrackingOperations.GetEyeTracker(address);
Debug.Log(string.Format("Got eye tracker"));
Debug.Log(string.Format("Address: {0}", eyeTracker.Address));
Debug.Log(string.Format("Device name: {0}", eyeTracker.DeviceName));
Debug.Log(string.Format("Model: {0}", eyeTracker.Model));
Debug.Log(string.Format("Serial number: {0}", eyeTracker.SerialNumber));
Debug.Log(string.Format("Firmware version: {0}", eyeTracker.FirmwareVersion));
return eyeTracker;
}
string Tobii.Research.IEyeTracker.DeviceName
get

Gets the name of the eye tracker.

string Tobii.Research.IEyeTracker.FirmwareVersion
get

Gets the firmware version of the eye tracker.

string Tobii.Research.IEyeTracker.Model
get

Gets the model of the eye tracker.

string Tobii.Research.IEyeTracker.SerialNumber
get

Gets the serial number of the eye tracker. All physical eye trackers have a unique serial number.

Event Documentation

EventHandler<CalibrationChangedEventArgs> Tobii.Research.IEyeTracker.CalibrationChanged

Occurs when the calibration is changed for the eye tracker.

EventHandler<CalibrationModeEnteredEventArgs> Tobii.Research.IEyeTracker.CalibrationModeEntered

Occurs when the eye tracker enters calibration mode.

private static void CalibrationModeEntered(IEyeTracker eyeTracker)
{
// Start listening to calibration mode entered event.
eyeTracker.CalibrationModeEntered += EyeTracker_CalibrationModeEntered;
var calibration = new ScreenBasedCalibration(eyeTracker);
// Trigger the event.
calibration.EnterCalibrationMode();
// Stop listening to calibration mode entered event.
eyeTracker.CalibrationModeEntered -= EyeTracker_CalibrationModeEntered;
// Cleanup.
calibration.LeaveCalibrationMode();
}
private static void EyeTracker_CalibrationModeEntered(object sender, CalibrationModeEnteredEventArgs e)
{
Debug.Log(string.Format("Calibration mode was entered at time stamp {0}.", e.SystemTimeStamp));
}
EventHandler<CalibrationModeLeftEventArgs> Tobii.Research.IEyeTracker.CalibrationModeLeft

Occurs when the eye tracker leaves calibration mode.

private static void CalibrationModeLeft(IEyeTracker eyeTracker)
{
// Start listening to calibration mode left event.
eyeTracker.CalibrationModeLeft += EyeTracker_CalibrationModeLeft;
var calibration = new ScreenBasedCalibration(eyeTracker);
calibration.EnterCalibrationMode();
// Trigger the event.
calibration.LeaveCalibrationMode();
// Stop listening to calibration mode left event.
eyeTracker.CalibrationModeLeft -= EyeTracker_CalibrationModeLeft;
}
private static void EyeTracker_CalibrationModeLeft(object sender, CalibrationModeLeftEventArgs e)
{
Debug.Log(string.Format("Calibration mode was left at time stamp {0}.", e.SystemTimeStamp));
}
EventHandler<ConnectionLostEventArgs> Tobii.Research.IEyeTracker.ConnectionLost

Occurs when the client loses connection to the eye tracker.

private static void ConnectionLost(IEyeTracker eyeTracker)
{
// Start listening to connection lost event.
eyeTracker.ConnectionLost += EyeTracker_ConnectionLost;
// You can't trigger this event programatically.
Debug.Log(string.Format("Event will be triggered if connection is lost here."));
// Stop listening to connection lost event.
eyeTracker.ConnectionLost -= EyeTracker_ConnectionLost;
}
private static void EyeTracker_ConnectionLost(object sender, ConnectionLostEventArgs e)
{
Debug.Log(string.Format("Connection to the eye tracker was lost at time stamp {0}.", e.SystemTimeStamp));
}
EventHandler<ConnectionRestoredEventArgs> Tobii.Research.IEyeTracker.ConnectionRestored

Occurs when connection to the eye tracker is restored.

private static void ConnectionRestored(IEyeTracker eyeTracker)
{
// Start listening to connection restored event.
eyeTracker.ConnectionRestored += EyeTracker_ConnectionRestored;
// You can't trigger this event programatically.
Debug.Log(string.Format("Event will be triggered if connection is restored here."));
// Stop listening to connection restored event.
eyeTracker.ConnectionRestored -= EyeTracker_ConnectionRestored;
}
private static void EyeTracker_ConnectionRestored(object sender, ConnectionRestoredEventArgs e)
{
Debug.Log(string.Format("Connection to the eye tracker was restored at time stamp {0}.", e.SystemTimeStamp));
}
EventHandler<DisplayAreaEventArgs> Tobii.Research.IEyeTracker.DisplayAreaChanged

Occurs when the display area has changed.

private static void DisplayAreaChanged(IEyeTracker eyeTracker)
{
// Start listening to display area changed event.
eyeTracker.DisplayAreaChanged += EyeTracker_DisplayAreaChanged;
// You can't trigger this event programatically.
Debug.Log(string.Format("Event will be triggered if display area is changed here."));
// Stop listening to display area changed event.
eyeTracker.DisplayAreaChanged -= EyeTracker_DisplayAreaChanged;
}
private static void EyeTracker_DisplayAreaChanged(object sender, DisplayAreaEventArgs e)
{
Debug.Log(string.Format("Display area changed at time stamp {0}.", e.SystemTimeStamp));
Debug.Log(string.Format("New height {0} and width {1}.", e.DisplayArea.Height, e.DisplayArea.Width));
Debug.Log(string.Format("Coordinates:"));
Debug.Log(string.Format("Bottom Left: ({0}, {1}, {2})",
e.DisplayArea.BottomLeft.X, e.DisplayArea.BottomLeft.Y, e.DisplayArea.BottomLeft.Z));
Debug.Log(string.Format("Bottom Right: ({0}, {1}, {2})",
e.DisplayArea.BottomRight.X, e.DisplayArea.BottomRight.Y, e.DisplayArea.BottomRight.Z));
Debug.Log(string.Format("Top Left: ({0}, {1}, {2})",
e.DisplayArea.TopLeft.X, e.DisplayArea.TopLeft.Y, e.DisplayArea.TopLeft.Z));
Debug.Log(string.Format("Top Right: ({0}, {1}, {2})",
e.DisplayArea.TopRight.X, e.DisplayArea.TopRight.Y, e.DisplayArea.TopRight.Z));
}
EventHandler<EventErrorEventArgs> Tobii.Research.IEyeTracker.EventErrorOccurred

Fired when an error occurs on any of the other events for the eye tracker.

private static bool errorThrownInEventHandler = false;
private static IEnumerator EventErrorOccurred(IEyeTracker eyeTracker)
{
// Start listening to event errors.
eyeTracker.EventErrorOccurred += EyeTracker_EventErrorOccurred;
// Trigger an event by throwing an exception in an event handler.
errorThrownInEventHandler = false;
eyeTracker.GazeDataReceived += EyeTracker_GazeDataReceived;
yield return new WaitForSeconds(1);
eyeTracker.GazeDataReceived -= EyeTracker_GazeDataReceived;
// Stop listening to event errors
eyeTracker.EventErrorOccurred -= EyeTracker_EventErrorOccurred;
}
private static void EyeTracker_EventErrorOccurred(object sender, EventErrorEventArgs e)
{
Debug.Log(string.Format("An error occured at time stamp {0}.", e.SystemTimeStamp));
Debug.Log(string.Format(e.Message));
}
private static void EyeTracker_GazeDataReceived(object sender, GazeDataEventArgs e)
{
if (!errorThrownInEventHandler)
{
// Throw some generic error.
errorThrownInEventHandler = true;
throw new ArgumentNullException();
}
}
EventHandler<ExternalSignalValueEventArgs> Tobii.Research.IEyeTracker.ExternalSignalReceived

Occurs when the value of the external signal port (TTL input) on the eye tracker device changes. Not all eye trackers have a sampling trigger port. The sampling feature could be used to synchronize the eye tracker data with data from other devices. The sampling data contains a time reference that matches the time reference on the time synchronized gaze data.

private static IEnumerator ExternalSignal(IEyeTracker eyeTracker)
{
// Start listening to external signals.
eyeTracker.ExternalSignalReceived += EyeTracker_ExternalSignalReceived;
// Wait for signals to arrive.
yield return new WaitForSeconds(1);
// Stop listening to external signals.
eyeTracker.ExternalSignalReceived -= EyeTracker_ExternalSignalReceived;
}
private static void EyeTracker_ExternalSignalReceived(object sender, ExternalSignalValueEventArgs e)
{
Debug.Log(string.Format("Got external signal with change type {0}, value {1} and device time stamp {2}.",
e.ChangeType, e.Value, e.DeviceTimeStamp));
EventHandler<EyeImageRawEventArgs> Tobii.Research.IEyeTracker.EyeImageRawReceived

Occurs when a new eye image raw is received, and the occurrence depends on the eye tracker model. Not all eye tracker models support this feature. If no one is listening to gaze data, the eye tracker will only deliver full images, otherwise either cropped or full images will be delivered depending on whether or not the eye tracker has detected eyes.

internal static IEnumerator RawEyeImages(IEyeTracker eyeTracker)
{
// Start receiving eye images.
eyeTracker.RawEyeImageReceived += EyeTracker_RawEyeImageReceived;
// Wait for some eye images to come.
yield return new WaitForSeconds(2.0f);
// Stop receiving eye images.
eyeTracker.RawEyeImageReceived -= EyeTracker_RawEyeImageReceived;
}
internal static void EyeTracker_RawEyeImageReceived(object sender, RawEyeImageEventArgs e)
{
Color32[] textureContentent = new Color32[e.Width * e.Height];
for (int index = 0; index < textureContentent.Length; index++)
{
byte grayValue = e.ImageData[index];
textureContentent[index] = new Color32(grayValue, grayValue, grayValue, 255);
}
// Use the textContent to populate a Texture2D object using
// <textureobject>.SetPixels32(textureContentent) and <textureobject>.Apply()
}
EventHandler<EyeImageEventArgs> Tobii.Research.IEyeTracker.EyeImageReceived

Occurs when a new eye image is received, and the occurrence depends on the eye tracker model. Not all eye tracker models support this feature. If no one is listening to gaze data, the eye tracker will only deliver full images, otherwise either cropped or full images will be delivered depending on whether or not the eye tracker has detected eyes.

EventHandler<EyeTrackingModeChangedEventArgs> Tobii.Research.IEyeTracker.EyeTrackingModeChanged

Occurs when the eye tracking mode has changed.

EventHandler<GazeDataEventArgs> Tobii.Research.IEyeTracker.GazeDataReceived

Event fired when gaze data is received.

private static IEnumerator GazeData(IEyeTracker eyeTracker)
{
// Start listening to gaze data.
eyeTracker.GazeDataReceived += EyeTracker_GazeDataReceived;
// Wait for some data to be received.
yield return new WaitForSeconds(2);
// Stop listening to gaze data.
eyeTracker.GazeDataReceived -= EyeTracker_GazeDataReceived;
}
private static void EyeTracker_GazeDataReceived(object sender, GazeDataEventArgs e)
{
Debug.Log(string.Format(
"Got gaze data with {0} left eye origin at point ({1}, {2}, {3}) in the user coordinate system.",
e.LeftEye.GazeOrigin.Validity,
e.LeftEye.GazeOrigin.PositionInUserCoordinates.X,
e.LeftEye.GazeOrigin.PositionInUserCoordinates.Y,
e.LeftEye.GazeOrigin.PositionInUserCoordinates.Z));
}
EventHandler<GazeOutputFrequencyEventArgs> Tobii.Research.IEyeTracker.GazeOutputFrequencyChanged

Occurs when the gaze output frequency has changed.

private static void GazeOutputFrequencyChanged(IEyeTracker eyeTracker)
{
// Start listening to gaze output frequency changed event.
eyeTracker.GazeOutputFrequencyChanged += EyeTracker_GazeOutputFrequencyChanged;
var originalGazeOutputFrequency = eyeTracker.GetGazeOutputFrequency();
// Find a frequency (using System.Linq).
var newGazeOutputFrequency = eyeTracker.GetAllGazeOutputFrequencies().Where(f => f != originalGazeOutputFrequency).FirstOrDefault();
if (newGazeOutputFrequency == default(float))
{
// This eye tracker only had one frequency.
return;
}
// Trigger the event.
eyeTracker.SetGazeOutputFrequency(newGazeOutputFrequency);
// Set back original frequency.
eyeTracker.SetGazeOutputFrequency(originalGazeOutputFrequency);
// Stop listening to gaze output frequency changed event.
eyeTracker.GazeOutputFrequencyChanged -= EyeTracker_GazeOutputFrequencyChanged;
}
private static void EyeTracker_GazeOutputFrequencyChanged(object sender, GazeOutputFrequencyEventArgs e)
{
Debug.Log(string.Format("Gaze output frequency changed to {0} at time stamp {1}.", e.GazeOutputFrequency, e.SystemTimeStamp));
}
EventHandler<HMDGazeDataEventArgs> Tobii.Research.IEyeTracker.HMDGazeDataReceived

Event fired when HMD gaze data is received.

private static IEnumerator HMDGazeData(IEyeTracker eyeTracker)
{
// Start listening to HMD gaze data.
eyeTracker.HMDGazeDataReceived += EyeTracker_HMDGazeDataReceived;
// Wait for some data to be received.
yield return new WaitForSeconds(2);
// Stop listening to HMD gaze data.
eyeTracker.HMDGazeDataReceived -= EyeTracker_HMDGazeDataReceived;
}
private static void EyeTracker_HMDGazeDataReceived(object sender, HMDGazeDataEventArgs e)
{
Debug.Log(string.Format(
"Got HMD gaze data with {0} left eye direction described by unit vector ({1}, {2}, {3}) in the HMD coordinate system.",
e.LeftEye.GazeDirection.Validity,
e.LeftEye.GazeDirection.UnitVector.X,
e.LeftEye.GazeDirection.UnitVector.Y,
e.LeftEye.GazeDirection.UnitVector.Z));
}
EventHandler<TimeSynchronizationReferenceEventArgs> Tobii.Research.IEyeTracker.TimeSynchronizationReferenceReceived

Occurs when the computer and the eye trackers clocks gets synchronized. To handle normal drifts between clocks the clocks are checked on regular basis, and this results in that the time stamps are adjusted for the drifts in the data streams. This drift handling is done in real time. The data received from this event could be used for an even more accurate drift adjustment in the post processing.

private static IEnumerator TimeSynchronizationData(IEyeTracker eyeTracker)
{
// Start listening to time synchronization events.
eyeTracker.TimeSynchronizationReferenceReceived += EyeTracker_TimeSynchronizationReferenceReceived;
// Wait for some events to arrive.
yield return new WaitForSeconds(2);
// Stop listening to time synchronization events.
eyeTracker.TimeSynchronizationReferenceReceived -= EyeTracker_TimeSynchronizationReferenceReceived;
}
private static void EyeTracker_TimeSynchronizationReferenceReceived(object sender, TimeSynchronizationReferenceEventArgs e)
{
Debug.Log(string.Format("Received a time synchronization package with latency {0} microseconds. The eye tracker time stamp was {1}.",
e.SystemResponseTimeStamp - e.SystemRequestTimeStamp, e.DeviceTimeStamp));
}
EventHandler<TrackBoxEventArgs> Tobii.Research.IEyeTracker.TrackBoxChanged

Occurs when the track box size has changed.

private static void TrackBoxChanged(IEyeTracker eyeTracker)
{
// Start listening to track box changed event.
eyeTracker.TrackBoxChanged += EyeTracker_TrackBoxChanged;
var originalGazeOutputFrequency = eyeTracker.GetGazeOutputFrequency();
// Find a frequency (using System.Linq).
var newGazeOutputFrequency = eyeTracker.GetAllGazeOutputFrequencies().Where(f => f != originalGazeOutputFrequency).FirstOrDefault();
if (newGazeOutputFrequency == default(float))
{
// This eye tracker only had one frequency.
return;
}
// Trigger the event. Some trackers have different track boxes at different
// gaze output frequencies.
eyeTracker.SetGazeOutputFrequency(newGazeOutputFrequency);
// Set back original frequency.
eyeTracker.SetGazeOutputFrequency(originalGazeOutputFrequency);
// Stop listening to track box changed event.
eyeTracker.TrackBoxChanged -= EyeTracker_TrackBoxChanged;
}
private static void EyeTracker_TrackBoxChanged(object sender, TrackBoxEventArgs e)
{
Debug.Log(string.Format("Track box changed at time stamp {0}.", e.SystemTimeStamp));
}