Tobii Pro SDK .NET 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.
 
float GetGazeOutputFrequency ()
 Gets the gaze output frequency of the eye tracker.
 
void SetGazeOutputFrequency (float gazeOutputFrequency)
 Sets the gaze output frequency of the eye tracker.
 
EyeTrackingModeCollection GetAllEyeTrackingModes ()
 Gets a list of eye tracking modes supported by the eye tracker.
 
string GetEyeTrackingMode ()
 Gets the eye tracking mode of the eye tracker.
 
void SetEyeTrackingMode (string eyeTrackingMode)
 Sets the eye tracking mode of the eye tracker.
 
CalibrationData RetrieveCalibrationData ()
 Gets the calibration data used currently by the eye tracker. This data can be saved to a file for later use.
 
void ApplyCalibrationData (CalibrationData calibrationData)
 Sets the provided calibration data to the eye tracker, which means it will be active calibration.
 
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.
 
void ClearAppliedLicenses ()
 Clears any previously applied licenses.
 
DisplayArea GetDisplayArea ()
 Gets the size and corners of the display area.
 
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.".
 
void SetDeviceName (string deviceName)
 Changes the device name. This is not supported by all eye trackers.
 

Properties

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

Events

EventHandler< GazeDataEventArgsGazeDataReceived
 Event fired when gaze data is received.
 
EventHandler< EyeOpennessDataEventArgsEyeOpennessDataReceived
 Event fired when eye openness data is received.
 
EventHandler< UserPositionGuideEventArgsUserPositionGuideReceived
 Event fired when user position guide is received.
 
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.
 
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.
 
EventHandler< EventErrorEventArgsEventErrorOccurred
 Fired when an error occurs on any of the other events for the eye tracker.
 
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.
 
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.
 
EventHandler< GazeOutputFrequencyEventArgsGazeOutputFrequencyChanged
 Occurs when the gaze output frequency has changed.
 
EventHandler< CalibrationModeEnteredEventArgsCalibrationModeEntered
 Occurs when the eye tracker enters calibration mode.
 
EventHandler< CalibrationModeLeftEventArgsCalibrationModeLeft
 Occurs when the eye tracker leaves calibration mode.
 
EventHandler< CalibrationChangedEventArgsCalibrationChanged
 Occurs when the calibration is changed for the eye tracker.
 
EventHandler< DisplayAreaEventArgsDisplayAreaChanged
 Occurs when the display area has changed.
 
EventHandler< ConnectionLostEventArgsConnectionLost
 Occurs when the client loses connection to the eye tracker.
 
EventHandler< ConnectionRestoredEventArgsConnectionRestored
 Occurs when connection to the eye tracker is restored.
 
EventHandler< EyeTrackingModeChangedEventArgsEyeTrackingModeChanged
 Occurs when the eye tracking mode has changed.
 
EventHandler< DeviceFaultsEventArgsDeviceFaults
 Occurs when the device reports new faults.
 
EventHandler< DeviceWarningsEventArgsDeviceWarnings
 Occurs when the device reports new warnings.
 
EventHandler< StreamBufferOverflowEventArgsStreamBufferOverflow
 Occurs when there is a stream buffer overflow, usually caused by a user-provided callback being unable to process its stream's data quickly enough.
 

Detailed Description

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

Examples
ScreenBasedCalibration_CalibrateDuringGazeRecording.cs.

Member Function Documentation

◆ ApplyCalibrationData()

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);
}
}
}
Stores calibration data.
Definition: CalibrationData.cs:18
byte[] Data
Gets or sets the calibration data.
Definition: CalibrationData.cs:39
Provides methods and properties to manage and get data from an eye tracker.
Definition: IEyeTracker.cs:16
CalibrationData RetrieveCalibrationData()
Gets the calibration data used currently by the eye tracker. This data can be saved to a file for lat...
void ApplyCalibrationData(CalibrationData calibrationData)
Sets the provided calibration data to the eye tracker, which means it will be active calibration.

◆ ClearAppliedLicenses()

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))
{
Console.WriteLine(
"Successfully applied license from {0} on eye tracker with serial number {1}.",
licensePath, eyeTracker.SerialNumber);
}
else
{
Console.WriteLine(
"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);
}
}
Represents a read-only collection of FailedLicense objects.
Definition: FailedLicenseCollection.cs:15
Represents a collection of LicenseKey objects.
Definition: LicenseCollection.cs:15
Represents the eye tracker license key.
Definition: LicenseKey.cs:18
string SerialNumber
Gets the serial number of the eye tracker. All physical eye trackers have a unique serial number.
Definition: IEyeTracker.cs:523
bool TryApplyLicenses(LicenseCollection licenses, out FailedLicenseCollection failedLicenses)
Apply one or more licenses to unlock features of the eye tracker. A return value indicates whether al...

◆ GetAllEyeTrackingModes()

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)
{
Console.WriteLine("\nEye tracking modes.");
// Get and store current eye tracking mode so it can be restored.
var initialEyeTrackingMode = eyeTracker.GetEyeTrackingMode();
Console.WriteLine("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);
Console.WriteLine("New eye tracking mode is: {0}.", eyeTrackingMode.ToString());
}
}
finally
{
eyeTracker.SetEyeTrackingMode(initialEyeTrackingMode);
Console.WriteLine("Eye tracking mode reset to: {0}.", eyeTracker.GetEyeTrackingMode());
}
}
string GetEyeTrackingMode()
Gets the eye tracking mode of the eye tracker.
void SetEyeTrackingMode(string eyeTrackingMode)
Sets the eye tracking mode of the eye tracker.
EyeTrackingModeCollection GetAllEyeTrackingModes()
Gets a list of eye tracking modes supported by the eye tracker.

◆ GetAllGazeOutputFrequencies()

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.
internal static void GazeOutputFrequencies(IEyeTracker eyeTracker)
{
Console.WriteLine("\nGaze output frequencies.");
// Get and store current frequency so it can be restored.
var initialGazeOutputFrequency = eyeTracker.GetGazeOutputFrequency();
Console.WriteLine("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);
Console.WriteLine("New gaze output frequency is: {0} hertz.", gazeOutputFrequency.ToString());
}
}
finally
{
eyeTracker.SetGazeOutputFrequency(initialGazeOutputFrequency);
Console.WriteLine("Gaze output frequency reset to: {0} hertz.", eyeTracker.GetGazeOutputFrequency());
}
}
float GetGazeOutputFrequency()
Gets the gaze output frequency of the eye tracker.
GazeOutputFrequencyCollection GetAllGazeOutputFrequencies()
Gets a list of gaze output frequencies supported by the eye tracker.
void SetGazeOutputFrequency(float gazeOutputFrequency)
Sets the gaze output frequency of the eye tracker.

◆ GetDisplayArea()

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();
Console.WriteLine(
"Got display area from tracker with serial number {0} with height {1}, width {2} and coordinates:",
eyeTracker.SerialNumber,
displayArea.Height,
displayArea.Width);
Console.WriteLine("Bottom Left: ({0}, {1}, {2})",
displayArea.BottomLeft.X, displayArea.BottomLeft.Y, displayArea.BottomLeft.Z);
Console.WriteLine("Bottom Right: ({0}, {1}, {2})",
displayArea.BottomRight.X, displayArea.BottomRight.Y, displayArea.BottomRight.Z);
Console.WriteLine("Top Left: ({0}, {1}, {2})",
displayArea.TopLeft.X, displayArea.TopLeft.Y, displayArea.TopLeft.Z);
Console.WriteLine("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);
}
Represents the three coordinates corresponding to the top left, bottom left, and top right corners of...
Definition: DisplayArea.cs:17
float Width
Gets the width in millimeters of the active display area.
Definition: DisplayArea.cs:134
Point3D TopLeft
Gets or sets the top left corner of the active display area.
Definition: DisplayArea.cs:101
Point3D BottomRight
Gets the bottom right corner of the active display area.
Definition: DisplayArea.cs:90
Point3D TopRight
Gets or sets the top right corner of the active display area.
Definition: DisplayArea.cs:118
float Height
Gets the height in millimeters of the active display area.
Definition: DisplayArea.cs:95
Point3D BottomLeft
Gets or sets the bottom left corner of the active display area.
Definition: DisplayArea.cs:74
float Y
Gets the position of the point in the Y axis.
Definition: Point3D.cs:56
float Z
Gets the position of the point in the Z axis.
Definition: Point3D.cs:61
float X
Gets the position of the point in the X axis.
Definition: Point3D.cs:51
DisplayArea GetDisplayArea()
Gets the size and corners of the display area.
void SetDisplayArea(DisplayArea displayArea)
Sets the display area of the eye tracker. It is strongly recommended to use Eye Tracker Manager to ca...

◆ GetEyeTrackingMode()

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)
{
Console.WriteLine("\nEye tracking modes.");
// Get and store current eye tracking mode so it can be restored.
var initialEyeTrackingMode = eyeTracker.GetEyeTrackingMode();
Console.WriteLine("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);
Console.WriteLine("New eye tracking mode is: {0}.", eyeTrackingMode.ToString());
}
}
finally
{
eyeTracker.SetEyeTrackingMode(initialEyeTrackingMode);
Console.WriteLine("Eye tracking mode reset to: {0}.", eyeTracker.GetEyeTrackingMode());
}
}

◆ GetGazeOutputFrequency()

float Tobii.Research.IEyeTracker.GetGazeOutputFrequency ( )

Gets the gaze output frequency of the eye tracker.

Returns
The gaze output frequency in hertz.
internal static void GazeOutputFrequencies(IEyeTracker eyeTracker)
{
Console.WriteLine("\nGaze output frequencies.");
// Get and store current frequency so it can be restored.
var initialGazeOutputFrequency = eyeTracker.GetGazeOutputFrequency();
Console.WriteLine("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);
Console.WriteLine("New gaze output frequency is: {0} hertz.", gazeOutputFrequency.ToString());
}
}
finally
{
eyeTracker.SetGazeOutputFrequency(initialGazeOutputFrequency);
Console.WriteLine("Gaze output frequency reset to: {0} hertz.", eyeTracker.GetGazeOutputFrequency());
}
}

◆ RetrieveCalibrationData()

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);
}
}
}

◆ SetDeviceName()

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.

◆ SetDisplayArea()

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();
Console.WriteLine(
"Got display area from tracker with serial number {0} with height {1}, width {2} and coordinates:",
eyeTracker.SerialNumber,
displayArea.Height,
displayArea.Width);
Console.WriteLine("Bottom Left: ({0}, {1}, {2})",
displayArea.BottomLeft.X, displayArea.BottomLeft.Y, displayArea.BottomLeft.Z);
Console.WriteLine("Bottom Right: ({0}, {1}, {2})",
displayArea.BottomRight.X, displayArea.BottomRight.Y, displayArea.BottomRight.Z);
Console.WriteLine("Top Left: ({0}, {1}, {2})",
displayArea.TopLeft.X, displayArea.TopLeft.Y, displayArea.TopLeft.Z);
Console.WriteLine("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);
}

◆ SetEyeTrackingMode()

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)
{
Console.WriteLine("\nEye tracking modes.");
// Get and store current eye tracking mode so it can be restored.
var initialEyeTrackingMode = eyeTracker.GetEyeTrackingMode();
Console.WriteLine("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);
Console.WriteLine("New eye tracking mode is: {0}.", eyeTrackingMode.ToString());
}
}
finally
{
eyeTracker.SetEyeTrackingMode(initialEyeTrackingMode);
Console.WriteLine("Eye tracking mode reset to: {0}.", eyeTracker.GetEyeTrackingMode());
}
}

◆ SetGazeOutputFrequency()

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().
internal static void GazeOutputFrequencies(IEyeTracker eyeTracker)
{
Console.WriteLine("\nGaze output frequencies.");
// Get and store current frequency so it can be restored.
var initialGazeOutputFrequency = eyeTracker.GetGazeOutputFrequency();
Console.WriteLine("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);
Console.WriteLine("New gaze output frequency is: {0} hertz.", gazeOutputFrequency.ToString());
}
}
finally
{
eyeTracker.SetGazeOutputFrequency(initialGazeOutputFrequency);
Console.WriteLine("Gaze output frequency reset to: {0} hertz.", eyeTracker.GetGazeOutputFrequency());
}
}

◆ TryApplyLicenses()

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))
{
Console.WriteLine(
"Successfully applied license from {0} on eye tracker with serial number {1}.",
licensePath, eyeTracker.SerialNumber);
}
else
{
Console.WriteLine(
"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

◆ DeviceCapabilities

Capabilities Tobii.Research.IEyeTracker.DeviceCapabilities
get

Gets the capabilities of the device.

internal static IEyeTracker GetEyeTracker(Uri address)
{
Console.WriteLine("\nGet eye tracker from Uri: {0}.", address);
var eyeTracker = EyeTrackingOperations.GetEyeTracker(address);
Console.WriteLine("Got eye tracker");
Console.WriteLine("Address: {0}", eyeTracker.Address);
Console.WriteLine("Device name: {0}", eyeTracker.DeviceName);
Console.WriteLine("Model: {0}", eyeTracker.Model);
Console.WriteLine("Serial number: {0}", eyeTracker.SerialNumber);
Console.WriteLine("Firmware version: {0}", eyeTracker.FirmwareVersion);
Console.WriteLine("Runtime version: {0}", eyeTracker.RuntimeVersion);
return eyeTracker;
}
Provides static methods for searching for eye trackers as well as connecting directly to a specific e...
Definition: EyeTrackingOperations.cs:21
static IEyeTracker GetEyeTracker(Uri address)
Gets an eye tracker object that has the specified address.
Definition: EyeTrackingOperations.cs:186

Event Documentation

◆ CalibrationModeEntered

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)
{
Console.WriteLine("Calibration mode was entered at time stamp {0}.", e.SystemTimeStamp);
}
Provides data for the CalibrationModeEntered event.
Definition: CalibrationModeEnteredEventArgs.cs:15
long SystemTimeStamp
Gets the time stamp in microseconds according to the computer's internal clock.
Definition: CalibrationModeEnteredEventArgs.cs:29
Provides methods and properties for managing calibrations for screen based eye trackers.
Definition: ScreenBasedCalibration.cs:18

◆ CalibrationModeLeft

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)
{
Console.WriteLine("Calibration mode was left at time stamp {0}.", e.SystemTimeStamp);
}
Provides data for the CalibrationModeLeft event.
Definition: CalibrationModeLeftEventArgs.cs:15
long SystemTimeStamp
Gets the time stamp in microseconds according to the computer's internal clock.
Definition: CalibrationModeLeftEventArgs.cs:29

◆ ConnectionLost

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.
Console.WriteLine("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)
{
Console.WriteLine("Connection to the eye tracker was lost at time stamp {0}.", e.SystemTimeStamp);
}
Provides data for the ConnectionLost event.
Definition: ConnectionLostEventArgs.cs:15
long SystemTimeStamp
Gets the time stamp in microseconds according to the computer's internal clock.
Definition: ConnectionLostEventArgs.cs:29
@ ConnectionLost
The connection to the eye tracker was lost.

◆ ConnectionRestored

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.
Console.WriteLine("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)
{
Console.WriteLine("Connection to the eye tracker was restored at time stamp {0}.", e.SystemTimeStamp);
}
Provides data for the ConnectionRestored event.
Definition: ConnectionRestoredEventArgs.cs:15
long SystemTimeStamp
Gets the time stamp in microseconds according to the computer's internal clock.
Definition: ConnectionRestoredEventArgs.cs:29
@ ConnectionRestored
Indicates that there has been a connection lost and now it is restored and the value is the current v...

◆ DisplayAreaChanged

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.
Console.WriteLine("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)
{
Console.WriteLine("Display area changed at time stamp {0}.", e.SystemTimeStamp);
Console.WriteLine("New height {0} and width {1}.", e.DisplayArea.Height, e.DisplayArea.Width);
Console.WriteLine("Coordinates:");
Console.WriteLine("Bottom Left: ({0}, {1}, {2})",
Console.WriteLine("Bottom Right: ({0}, {1}, {2})",
Console.WriteLine("Top Left: ({0}, {1}, {2})",
Console.WriteLine("Top Right: ({0}, {1}, {2})",
}
Provides data for the DisplayAreaChanged event.
Definition: DisplayAreaEventArgs.cs:16
DisplayArea DisplayArea
Gets the new display area that was changed to.
Definition: DisplayAreaEventArgs.cs:37
long SystemTimeStamp
Gets the time stamp in microseconds according to the computer's internal clock.
Definition: DisplayAreaEventArgs.cs:32

◆ EventErrorOccurred

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 void 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;
System.Threading.Thread.Sleep(1000);
eyeTracker.GazeDataReceived -= EyeTracker_GazeDataReceived;
// Stop listening to event errors
eyeTracker.EventErrorOccurred -= EyeTracker_EventErrorOccurred;
}
private static void EyeTracker_EventErrorOccurred(object sender, EventErrorEventArgs e)
{
Console.WriteLine("An error occured at time stamp {0}.", e.SystemTimeStamp);
Console.WriteLine(e.Message);
}
private static void EyeTracker_GazeDataReceived(object sender, GazeDataEventArgs e)
{
if (!errorThrownInEventHandler)
{
// Throw some generic error.
errorThrownInEventHandler = true;
throw new ArgumentNullException();
}
}
Provides data for the EventErrorOccurred event.
Definition: EventErrorEventArgs.cs:16
long SystemTimeStamp
Gets the time stamp in microseconds according to the computer's internal clock.
Definition: EventErrorEventArgs.cs:48
string Message
Gets the log message.
Definition: EventErrorEventArgs.cs:42

◆ ExternalSignalReceived

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 void ExternalSignal(IEyeTracker eyeTracker)
{
// Start listening to external signals.
eyeTracker.ExternalSignalReceived += EyeTracker_ExternalSignalReceived;
// Wait for signals to arrive.
System.Threading.Thread.Sleep(1000);
// Stop listening to external signals.
eyeTracker.ExternalSignalReceived -= EyeTracker_ExternalSignalReceived;
}
private static void EyeTracker_ExternalSignalReceived(object sender, ExternalSignalValueEventArgs e)
{
Console.WriteLine(
"Got external signal with change type {0}, value {1} and device time stamp {2}.",
}
Provides data for the ExternalSignalReceived event.
Definition: ExternalSignalValueEventArgs.cs:16
long DeviceTimeStamp
Gets the time stamp in microseconds according to the eye tracker's internal clock.
Definition: ExternalSignalValueEventArgs.cs:38
long Value
Gets the value of the external signal port on the eye tracker.
Definition: ExternalSignalValueEventArgs.cs:32
ExternalSignalChangeType ChangeType
Gets the type of value change.
Definition: ExternalSignalValueEventArgs.cs:49

◆ EyeImageRawReceived

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 void EyeImageRaws(IEyeTracker eyeTracker)
{
// Start receiving eye image raws.
eyeTracker.EyeImageRawReceived += EyeTracker_EyeImageRawReceived;
// Wait for some eye image raws to come.
System.Threading.Thread.Sleep(5000);
// Stop receiving eye image raws.
eyeTracker.EyeImageRawReceived -= EyeTracker_EyeImageRawReceived;
}
private static void EyeTracker_EyeImageRawReceived(object sender, EyeImageRawEventArgs e)
{
Console.WriteLine("Received a {0} image at system time {1}.", e.ImageType, e.SystemTimeStamp);
// You can use the eye image raw data to create a System.Windows.Media.Imaging.BitmapSource that can be used in a WPF application.
const double dpi = 96;
int bytesPerPixel = (e.BitsPerPixel + e.PaddingBitsPerPixel == 8) ? 1 : 2;
int stride = e.Width * bytesPerPixel;
System.Windows.Media.PixelFormat pixelFormat = bytesPerPixel == 1 ?
System.Windows.Media.PixelFormats.Gray8 :
System.Windows.Media.PixelFormats.Gray16;
System.Windows.Media.Imaging.BitmapSource bitmapSource;
bitmapSource = System.Windows.Media.Imaging.BitmapSource.Create(e.Width, e.Height, dpi, dpi, pixelFormat, null, e.ImageData, stride);
}
Provides data for the EyeImageRawReceived event.
Definition: EyeImageRawEventArgs.cs:15
EyeImageType ImageType
Gets the type of eye image.
Definition: EyeImageRawEventArgs.cs:82
int Height
Gets the height in pixels for the eye image.
Definition: EyeImageRawEventArgs.cs:77
byte[] ImageData
Gets the raw image data.
Definition: EyeImageRawEventArgs.cs:108
int Width
Gets the width in pixel for the eye image.
Definition: EyeImageRawEventArgs.cs:72
long SystemTimeStamp
Gets the time stamp in microseconds according to the computer's internal clock.
Definition: EyeImageRawEventArgs.cs:120

◆ EyeImageReceived

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.

internal static void EyeImages(IEyeTracker eyeTracker)
{
// Start receiving eye images.
eyeTracker.EyeImageReceived += EyeTracker_EyeImageReceived;
// Wait for some eye images to come.
System.Threading.Thread.Sleep(5000);
// Stop receiving eye images.
eyeTracker.EyeImageReceived -= EyeTracker_EyeImageReceived;
}
private static void EyeTracker_EyeImageReceived(object sender, EyeImageEventArgs e)
{
Console.WriteLine("Received a {0} image at system time {1}.", e.ImageType, e.SystemTimeStamp);
// You can convert the image stream to a System.Drawing.Bitmap if you're making a Windows Form application.
var drawingBitmap = new System.Drawing.Bitmap(e.ImageStream);
// Or you can convert it to a System.Windows.Media.Imaging.BitmapImage if you're making a WPF application.
var imagingBitmap = new System.Windows.Media.Imaging.BitmapImage();
imagingBitmap.BeginInit();
imagingBitmap.StreamSource = e.ImageStream;
imagingBitmap.EndInit();
}
Provides data for the EyeImageReceived event.
Definition: EyeImageEventArgs.cs:16
Stream ImageStream
Gets the bitmap data sent by the eye tracker, that can be converted to several image formats.
Definition: EyeImageEventArgs.cs:68
long SystemTimeStamp
Gets the time stamp in microseconds according to the computer's internal clock.
Definition: EyeImageEventArgs.cs:80
EyeImageType ImageType
Gets the type of eye image.
Definition: EyeImageEventArgs.cs:43

◆ EyeOpennessDataReceived

EventHandler<EyeOpennessDataEventArgs> Tobii.Research.IEyeTracker.EyeOpennessDataReceived

Event fired when eye openness data is received.

private static void EyeOpennessData(IEyeTracker eyeTracker)
{
// Start listening to eye openness data.
eyeTracker.EyeOpennessDataReceived += EyeTracker_EyeOpennessDataReceived;
// Wait for some data to be received.
System.Threading.Thread.Sleep(2000);
// Stop listening to eye openness data.
eyeTracker.EyeOpennessDataReceived -= EyeTracker_EyeOpennessDataReceived;
}
private static void EyeTracker_EyeOpennessDataReceived(object sender, EyeOpennessDataEventArgs e)
{
Console.WriteLine("Got eye openness data with:");
Console.WriteLine("Left eye validity: {0}", e.LeftEyeValidity);
Console.WriteLine("Right eye validity: {0}", e.RightEyeValidity);
Console.WriteLine("Left eye value: {0}", e.LeftEyeValue);
Console.WriteLine("Right eye value: {0}", e.RightEyeValue);
Console.WriteLine("Device timestamp: {0}", e.DeviceTimeStamp);
Console.WriteLine("System timestamp: {0}", e.SystemTimeStamp);
}
Provides data for the EyeOpennessDataReceived event.
Definition: EyeOpennessDataEventArgs.cs:17
long SystemTimeStamp
Gets the time stamp in microseconds according to the computer's internal clock.
Definition: EyeOpennessDataEventArgs.cs:81
long DeviceTimeStamp
Gets the time stamp in microseconds according to the eye tracker's internal clock.
Definition: EyeOpennessDataEventArgs.cs:75
float RightEyeValue
Gets the value for the right eye in mm.
Definition: EyeOpennessDataEventArgs.cs:69
float LeftEyeValue
Gets the value for the left eye in mm.
Definition: EyeOpennessDataEventArgs.cs:64
Validity RightEyeValidity
Gets the validity for the right eye.
Definition: EyeOpennessDataEventArgs.cs:59
Validity LeftEyeValidity
Gets the validity for the left eye.
Definition: EyeOpennessDataEventArgs.cs:54

◆ GazeDataReceived

EventHandler<GazeDataEventArgs> Tobii.Research.IEyeTracker.GazeDataReceived

Event fired when gaze data is received.

private static void GazeData(IEyeTracker eyeTracker)
{
// Start listening to stream buffer overflow notifications
// and then subscribe to gaze data. If your code takes to long too process the callback,
// the circular buffer will overflow and EyeTrackerStreamBufferOverflowOccured will be called.
// For further information, we refer to our section on "streambufferoverflow".
eyeTracker.StreamBufferOverflow += EyeTrackerStreamBufferOverflowOccured;
// Start listening to gaze data.
eyeTracker.GazeDataReceived += EyeTrackerGazeDataReceived;
// Wait for some data to be received.
System.Threading.Thread.Sleep(2000);
// Stop listening to gaze data.
eyeTracker.GazeDataReceived -= EyeTrackerGazeDataReceived;
// Stop listening to stream buffer overflow notifications
eyeTracker.StreamBufferOverflow -= EyeTrackerStreamBufferOverflowOccured;
}
private static void EyeTrackerGazeDataReceived(object sender, GazeDataEventArgs e)
{
Console.WriteLine(
"Got gaze data with {0} left eye origin at point ({1}, {2}, {3}) in the user coordinate system.",
}
private static void EyeTrackerStreamBufferOverflowOccured(object sender, StreamBufferOverflowEventArgs e)
{
Console.WriteLine($"Stream buffer overflow at: {e.SystemTimeStamp}");
}
GazeOrigin GazeOrigin
Gets the gaze origin data.
Definition: EyeData.cs:48
Provides data for the GazeDataReceived event.
Definition: GazeDataEventArgs.cs:17
EyeData LeftEye
Gets the gaze data for the left eye.
Definition: GazeDataEventArgs.cs:82
Validity Validity
Gets the validity of the gaze origin data.
Definition: GazeOrigin.cs:40
Point3D PositionInUserCoordinates
Gets the gaze origin position in 3D in the user coordinate system.
Definition: GazeOrigin.cs:35

◆ GazeOutputFrequencyChanged

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)
{
Console.WriteLine("Gaze output frequency changed to {0} at time stamp {1}.", e.GazeOutputFrequency, e.SystemTimeStamp);
}

◆ TimeSynchronizationReferenceReceived

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 void TimeSynchronizationData(IEyeTracker eyeTracker)
{
// Start listening to time synchronization events.
eyeTracker.TimeSynchronizationReferenceReceived += EyeTracker_TimeSynchronizationReferenceReceived;
// Wait for some events to arrive.
System.Threading.Thread.Sleep(2000);
// Stop listening to time synchronization events.
eyeTracker.TimeSynchronizationReferenceReceived -= EyeTracker_TimeSynchronizationReferenceReceived;
}
private static void EyeTracker_TimeSynchronizationReferenceReceived(object sender, TimeSynchronizationReferenceEventArgs e)
{
Console.WriteLine("Received a time synchronization package with latency {0} microseconds. The eye tracker time stamp was {1}.",
}
Provides data for the TimeSynchronizationReferenceReceived event.
Definition: TimeSynchronizationReferenceEventArgs.cs:17
long DeviceTimeStamp
Gets the time stamp in microseconds when the eye tracker received the request, according to the eye t...
Definition: TimeSynchronizationReferenceEventArgs.cs:39
long SystemResponseTimeStamp
Gets the time stamp in microseconds when the computer received the response from the eye tracker.
Definition: TimeSynchronizationReferenceEventArgs.cs:45
long SystemRequestTimeStamp
Gets the time stamp in microseconds when the computer sent the request to the eye tracker.
Definition: TimeSynchronizationReferenceEventArgs.cs:33

◆ UserPositionGuideReceived

EventHandler<UserPositionGuideEventArgs> Tobii.Research.IEyeTracker.UserPositionGuideReceived

Event fired when user position guide is received.

private static void UserPositionGuide(IEyeTracker eyeTracker)
{
// Start listening to user position guide.
eyeTracker.UserPositionGuideReceived += EyeTracker_UserPositionGuideReceived;
// Wait for some data to be received.
System.Threading.Thread.Sleep(2000);
// Stop listening to user position guide.
eyeTracker.UserPositionGuideReceived -= EyeTracker_UserPositionGuideReceived;
}
private static void EyeTracker_UserPositionGuideReceived(object sender, UserPositionGuideEventArgs e)
{
Console.WriteLine(
"Got user position guide with validity: {0} left normalized coordinates: ({1}, {2}, {3}).",
}
Provides data for the UserPositionGuideReceived event.
Definition: UserPositionGuideEventArgs.cs:17
UserPositionGuide LeftEye
Gets the user position guide for the left eye.
Definition: UserPositionGuideEventArgs.cs:47
Provides properties for the gaze point.
Definition: UserPositionGuide.cs:14
Validity Validity
Gets the validity of the user position guide.
Definition: UserPositionGuide.cs:40
NormalizedPoint3D UserPosition
Gets the normalized 3D user position guide.
Definition: UserPositionGuide.cs:35