Tobii Pro SDK Unity API
Tobii.Research.ScreenBasedCalibration Class Reference

Provides methods and properties for managing calibrations for screen based eye trackers. More...

Inheritance diagram for Tobii.Research.ScreenBasedCalibration:

Public Member Functions

 ScreenBasedCalibration (IEyeTracker eyeTracker)
 Initializes a new instance of the ScreenBasedCalibration class More...
 
CalibrationStatus CollectData (NormalizedPoint2D positionOnDisplayArea)
 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 active display area coordinate system. More...
 
CalibrationResult ComputeAndApply ()
 Uses the collected data and tries to compute calibration parameters. If the calculation is successful, the result is applied to the eye tracker. If there is insufficient data to compute a new calibration or if the collected data is not good enough then calculation is failed and will not be applied. More...
 
void DiscardData (NormalizedPoint2D positionOnDisplayArea)
 Removes the collected data associated with a specific calibration point. More...
 
void EnterCalibrationMode ()
 Enters the calibration mode and the eye tracker is made ready for collecting data and calculating new calibrations More...
 
void LeaveCalibrationMode ()
 Leaves the calibration mode. More...
 
void Dispose ()
 Should be called when done with the Calibration object to release resources. More...
 

Protected Member Functions

virtual void Dispose (bool disposing)
 Dispose(bool disposing) executes in two distinct scenarios. If disposing equals true, the method has been called directly or indirectly by a user's code. Managed and unmanaged resources can be disposed. If disposing equals false, the method has been called by the runtime from inside the finalizer and you should not reference other objects. Only unmanaged resources can be disposed. More...
 

Detailed Description

Provides methods and properties for managing calibrations for screen based eye trackers.

Constructor & Destructor Documentation

Tobii.Research.ScreenBasedCalibration.ScreenBasedCalibration ( IEyeTracker  eyeTracker)
inline

Initializes a new instance of the ScreenBasedCalibration class

Parameters
eyeTrackerThe eye tracker to calibrate.

Member Function Documentation

CalibrationStatus Tobii.Research.ScreenBasedCalibration.CollectData ( NormalizedPoint2D  positionOnDisplayArea)
inline

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 active display area coordinate system.

Parameters
positionOnDisplayAreaData for a calibration point.
Returns
The status of the calibration process.
private static IEnumerator Calibrate(IEyeTracker eyeTracker)
{
// Create a calibration object.
var calibration = new ScreenBasedCalibration(eyeTracker);
// Enter calibration mode.
calibration.EnterCalibrationMode();
// Define the points on screen we should calibrate at.
// The coordinates are normalized, i.e. (0.0f, 0.0f) is the upper left corner and (1.0f, 1.0f) is the lower right corner.
var pointsToCalibrate = new NormalizedPoint2D[] {
new NormalizedPoint2D(0.5f, 0.5f),
new NormalizedPoint2D(0.1f, 0.1f),
new NormalizedPoint2D(0.1f, 0.9f),
new NormalizedPoint2D(0.9f, 0.1f),
new NormalizedPoint2D(0.9f, 0.9f),
};
// Collect data.
foreach (var point in pointsToCalibrate)
{
// Show an image on screen where you want to calibrate.
Debug.Log(string.Format("Show point on screen at ({0}, {1})", point.X, point.Y));
// Wait a little for user to focus.
yield return new WaitForSeconds(.7f);
// Collect data.
CalibrationStatus status = calibration.CollectData(point);
if (status != CalibrationStatus.Success)
{
// Try again if it didn't go well the first time.
// Not all eye tracker models will fail at this point, but instead fail on ComputeAndApply.
calibration.CollectData(point);
}
}
// Compute and apply the calibration.
CalibrationResult calibrationResult = calibration.ComputeAndApply();
Debug.Log(string.Format("Compute and apply returned {0} and collected at {1} points.",
calibrationResult.Status, calibrationResult.CalibrationPoints.Count));
// Analyze the data and maybe remove points that weren't good.
calibration.DiscardData(new NormalizedPoint2D(0.1f, 0.1f));
// Redo collection at the discarded point.
Debug.Log(string.Format("Show point on screen at ({0}, {1})", 0.1f, 0.1f));
calibration.CollectData(new NormalizedPoint2D(0.1f, 0.1f));
// Compute and apply again.
calibrationResult = calibration.ComputeAndApply();
Debug.Log(string.Format("Second compute and apply returned {0} and collected at {1} points.",
calibrationResult.Status, calibrationResult.CalibrationPoints.Count));
// See that you're happy with the result.
// The calibration is done. Leave calibration mode.
calibration.LeaveCalibrationMode();
}
CalibrationResult Tobii.Research.ScreenBasedCalibration.ComputeAndApply ( )
inline

Uses the collected data and tries to compute calibration parameters. If the calculation is successful, the result is applied to the eye tracker. If there is insufficient data to compute a new calibration or if the collected data is not good enough then calculation is failed and will not be applied.

Returns
A CalibrationResult.
private static IEnumerator Calibrate(IEyeTracker eyeTracker)
{
// Create a calibration object.
var calibration = new ScreenBasedCalibration(eyeTracker);
// Enter calibration mode.
calibration.EnterCalibrationMode();
// Define the points on screen we should calibrate at.
// The coordinates are normalized, i.e. (0.0f, 0.0f) is the upper left corner and (1.0f, 1.0f) is the lower right corner.
var pointsToCalibrate = new NormalizedPoint2D[] {
new NormalizedPoint2D(0.5f, 0.5f),
new NormalizedPoint2D(0.1f, 0.1f),
new NormalizedPoint2D(0.1f, 0.9f),
new NormalizedPoint2D(0.9f, 0.1f),
new NormalizedPoint2D(0.9f, 0.9f),
};
// Collect data.
foreach (var point in pointsToCalibrate)
{
// Show an image on screen where you want to calibrate.
Debug.Log(string.Format("Show point on screen at ({0}, {1})", point.X, point.Y));
// Wait a little for user to focus.
yield return new WaitForSeconds(.7f);
// Collect data.
CalibrationStatus status = calibration.CollectData(point);
if (status != CalibrationStatus.Success)
{
// Try again if it didn't go well the first time.
// Not all eye tracker models will fail at this point, but instead fail on ComputeAndApply.
calibration.CollectData(point);
}
}
// Compute and apply the calibration.
CalibrationResult calibrationResult = calibration.ComputeAndApply();
Debug.Log(string.Format("Compute and apply returned {0} and collected at {1} points.",
calibrationResult.Status, calibrationResult.CalibrationPoints.Count));
// Analyze the data and maybe remove points that weren't good.
calibration.DiscardData(new NormalizedPoint2D(0.1f, 0.1f));
// Redo collection at the discarded point.
Debug.Log(string.Format("Show point on screen at ({0}, {1})", 0.1f, 0.1f));
calibration.CollectData(new NormalizedPoint2D(0.1f, 0.1f));
// Compute and apply again.
calibrationResult = calibration.ComputeAndApply();
Debug.Log(string.Format("Second compute and apply returned {0} and collected at {1} points.",
calibrationResult.Status, calibrationResult.CalibrationPoints.Count));
// See that you're happy with the result.
// The calibration is done. Leave calibration mode.
calibration.LeaveCalibrationMode();
}
void Tobii.Research.ScreenBasedCalibration.DiscardData ( NormalizedPoint2D  positionOnDisplayArea)
inline

Removes the collected data associated with a specific calibration point.

Parameters
positionOnDisplayAreaThe calibration point to remove.
private static IEnumerator Calibrate(IEyeTracker eyeTracker)
{
// Create a calibration object.
var calibration = new ScreenBasedCalibration(eyeTracker);
// Enter calibration mode.
calibration.EnterCalibrationMode();
// Define the points on screen we should calibrate at.
// The coordinates are normalized, i.e. (0.0f, 0.0f) is the upper left corner and (1.0f, 1.0f) is the lower right corner.
var pointsToCalibrate = new NormalizedPoint2D[] {
new NormalizedPoint2D(0.5f, 0.5f),
new NormalizedPoint2D(0.1f, 0.1f),
new NormalizedPoint2D(0.1f, 0.9f),
new NormalizedPoint2D(0.9f, 0.1f),
new NormalizedPoint2D(0.9f, 0.9f),
};
// Collect data.
foreach (var point in pointsToCalibrate)
{
// Show an image on screen where you want to calibrate.
Debug.Log(string.Format("Show point on screen at ({0}, {1})", point.X, point.Y));
// Wait a little for user to focus.
yield return new WaitForSeconds(.7f);
// Collect data.
CalibrationStatus status = calibration.CollectData(point);
if (status != CalibrationStatus.Success)
{
// Try again if it didn't go well the first time.
// Not all eye tracker models will fail at this point, but instead fail on ComputeAndApply.
calibration.CollectData(point);
}
}
// Compute and apply the calibration.
CalibrationResult calibrationResult = calibration.ComputeAndApply();
Debug.Log(string.Format("Compute and apply returned {0} and collected at {1} points.",
calibrationResult.Status, calibrationResult.CalibrationPoints.Count));
// Analyze the data and maybe remove points that weren't good.
calibration.DiscardData(new NormalizedPoint2D(0.1f, 0.1f));
// Redo collection at the discarded point.
Debug.Log(string.Format("Show point on screen at ({0}, {1})", 0.1f, 0.1f));
calibration.CollectData(new NormalizedPoint2D(0.1f, 0.1f));
// Compute and apply again.
calibrationResult = calibration.ComputeAndApply();
Debug.Log(string.Format("Second compute and apply returned {0} and collected at {1} points.",
calibrationResult.Status, calibrationResult.CalibrationPoints.Count));
// See that you're happy with the result.
// The calibration is done. Leave calibration mode.
calibration.LeaveCalibrationMode();
}
void Tobii.Research.ScreenBasedCalibration.Dispose ( )
inline

Should be called when done with the Calibration object to release resources.

virtual void Tobii.Research.ScreenBasedCalibration.Dispose ( bool  disposing)
inlineprotectedvirtual

Dispose(bool disposing) executes in two distinct scenarios. If disposing equals true, the method has been called directly or indirectly by a user's code. Managed and unmanaged resources can be disposed. If disposing equals false, the method has been called by the runtime from inside the finalizer and you should not reference other objects. Only unmanaged resources can be disposed.

Parameters
disposingSet to true if the method is called from the user's code.
void Tobii.Research.ScreenBasedCalibration.EnterCalibrationMode ( )
inline

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

private static IEnumerator Calibrate(IEyeTracker eyeTracker)
{
// Create a calibration object.
var calibration = new ScreenBasedCalibration(eyeTracker);
// Enter calibration mode.
calibration.EnterCalibrationMode();
// Define the points on screen we should calibrate at.
// The coordinates are normalized, i.e. (0.0f, 0.0f) is the upper left corner and (1.0f, 1.0f) is the lower right corner.
var pointsToCalibrate = new NormalizedPoint2D[] {
new NormalizedPoint2D(0.5f, 0.5f),
new NormalizedPoint2D(0.1f, 0.1f),
new NormalizedPoint2D(0.1f, 0.9f),
new NormalizedPoint2D(0.9f, 0.1f),
new NormalizedPoint2D(0.9f, 0.9f),
};
// Collect data.
foreach (var point in pointsToCalibrate)
{
// Show an image on screen where you want to calibrate.
Debug.Log(string.Format("Show point on screen at ({0}, {1})", point.X, point.Y));
// Wait a little for user to focus.
yield return new WaitForSeconds(.7f);
// Collect data.
CalibrationStatus status = calibration.CollectData(point);
if (status != CalibrationStatus.Success)
{
// Try again if it didn't go well the first time.
// Not all eye tracker models will fail at this point, but instead fail on ComputeAndApply.
calibration.CollectData(point);
}
}
// Compute and apply the calibration.
CalibrationResult calibrationResult = calibration.ComputeAndApply();
Debug.Log(string.Format("Compute and apply returned {0} and collected at {1} points.",
calibrationResult.Status, calibrationResult.CalibrationPoints.Count));
// Analyze the data and maybe remove points that weren't good.
calibration.DiscardData(new NormalizedPoint2D(0.1f, 0.1f));
// Redo collection at the discarded point.
Debug.Log(string.Format("Show point on screen at ({0}, {1})", 0.1f, 0.1f));
calibration.CollectData(new NormalizedPoint2D(0.1f, 0.1f));
// Compute and apply again.
calibrationResult = calibration.ComputeAndApply();
Debug.Log(string.Format("Second compute and apply returned {0} and collected at {1} points.",
calibrationResult.Status, calibrationResult.CalibrationPoints.Count));
// See that you're happy with the result.
// The calibration is done. Leave calibration mode.
calibration.LeaveCalibrationMode();
}
void Tobii.Research.ScreenBasedCalibration.LeaveCalibrationMode ( )
inline

Leaves the calibration mode.

private static IEnumerator Calibrate(IEyeTracker eyeTracker)
{
// Create a calibration object.
var calibration = new ScreenBasedCalibration(eyeTracker);
// Enter calibration mode.
calibration.EnterCalibrationMode();
// Define the points on screen we should calibrate at.
// The coordinates are normalized, i.e. (0.0f, 0.0f) is the upper left corner and (1.0f, 1.0f) is the lower right corner.
var pointsToCalibrate = new NormalizedPoint2D[] {
new NormalizedPoint2D(0.5f, 0.5f),
new NormalizedPoint2D(0.1f, 0.1f),
new NormalizedPoint2D(0.1f, 0.9f),
new NormalizedPoint2D(0.9f, 0.1f),
new NormalizedPoint2D(0.9f, 0.9f),
};
// Collect data.
foreach (var point in pointsToCalibrate)
{
// Show an image on screen where you want to calibrate.
Debug.Log(string.Format("Show point on screen at ({0}, {1})", point.X, point.Y));
// Wait a little for user to focus.
yield return new WaitForSeconds(.7f);
// Collect data.
CalibrationStatus status = calibration.CollectData(point);
if (status != CalibrationStatus.Success)
{
// Try again if it didn't go well the first time.
// Not all eye tracker models will fail at this point, but instead fail on ComputeAndApply.
calibration.CollectData(point);
}
}
// Compute and apply the calibration.
CalibrationResult calibrationResult = calibration.ComputeAndApply();
Debug.Log(string.Format("Compute and apply returned {0} and collected at {1} points.",
calibrationResult.Status, calibrationResult.CalibrationPoints.Count));
// Analyze the data and maybe remove points that weren't good.
calibration.DiscardData(new NormalizedPoint2D(0.1f, 0.1f));
// Redo collection at the discarded point.
Debug.Log(string.Format("Show point on screen at ({0}, {1})", 0.1f, 0.1f));
calibration.CollectData(new NormalizedPoint2D(0.1f, 0.1f));
// Compute and apply again.
calibrationResult = calibration.ComputeAndApply();
Debug.Log(string.Format("Second compute and apply returned {0} and collected at {1} points.",
calibrationResult.Status, calibrationResult.CalibrationPoints.Count));
// See that you're happy with the result.
// The calibration is done. Leave calibration mode.
calibration.LeaveCalibrationMode();
}