EyeTracker

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

Contents

Protected Properties

Name

Gets the name of the eye tracker.

eyetracker.Name

Readonly Properties

Serial Number

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

eyetracker.SerialNumber

Model

Gets the model of the eye tracker.

eyetracker.Model

Firmware Version

Gets the firmware version of the eye tracker.

eyetracker.FirmwareVersion

Address

Gets the address of the eye tracker device

eyetracker.Address

DeviceCapabilities

Gets the capabilities of the device.

eyetracker.DeviceCapabilities

Methods

Set Device Name

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

Parameters: string with new desired device name Returns: instance of the class EyeTracker with the updated device name.

%% Set Device Name
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

new_name = 'new_name';
updated_eyetracker = eyetracker.set_device_name(new_name);

fprintf('New eyetracker name: %s\n', updated_eyetracker.Name);

Get All Gaze Output Frequencies

Gets an array with the available gaze output frequencies.

Returns: array of doubles with the available gaze output frequencies.

%% Get All Gaze Output Frequencies
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

gaze_output_frequencies = eyetracker.get_all_gaze_output_frequencies();

Get Gaze Output Frequency

Gets the current gaze output frequency.

Returns: double with the current gaze output frequency.

%% Get Gaze Output Frequency
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

gaze_output_frequency = eyetracker.get_gaze_output_frequency();

Set Gaze Output Frequency

Sets the current gaze output frequency

Parameters: double with the desired gaze output frequency.

%% Set Gaze Output Frequency
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

available_gaze_output_frequencies = eyetracker.get_all_gaze_output_frequencies();

gaze_output_frequency = available_gaze_output_frequencies(1);

eyetracker.set_gaze_output_frequency(gaze_output_frequency)

Get All Eye Tracking Modes

Gets a cell array with the available eye tracking modes.

Returns: cell of strings with the available eye tracking modes.

%% Get All EyeTracking Modes
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

modes = eyetracker.get_all_eye_tracking_modes();

Get Eye Tracking Mode

Gets the current eye tracking mode.

Returns: string with the current eye tracking mode.

%% Get EyeTracking Mode
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

mode = eyetracker.get_eye_tracking_mode();

Set Eye Tracking Mode

Sets the current eye tracking mode.

Parameters: string with the desired eye tracking modes.

%% Set EyeTracking Mode
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

available_modes = eyetracker.get_all_eye_tracking_modes();

mode = available_modes(1);

eyetracker.set_eye_tracking_mode(mode)

Retreive Calibration Data

Gets the calibration data, which is stored in the active calibration buffer. This data can be saved to a file for later use.

Returns: array of uint8 containing the calibration data.

%% Retrieve Calibration Data
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

data = eyetracker.retrieve_calibration_data();

calibration_path = 'sample.calib';

fid = fopen(calibration_path,'w');

fwrite(fid,data);

fclose(fid);


Apply Calibration Data

Sets the provided calibration, which means copying the data from the calibration to into the active calibration buffer.

Parameters: array of uint8 containing the calibration data.

%% Apply Calibration Data
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

calibration_path = 'sample.calib';

fid = fopen(calibration_path,'r');

data = fread(fid);

fclose(fid);

eyetracker.apply_calibration_data(data);


Get Time Synchronization Data

Provides data for the for time synchronization. Only supports streaming from one eyetracker at a time. If there is the need to use a different eyetracker, use the method stop_time_sync_data first and start a new data stream for the new eyetracker. Returns a class with 3 different time stamps:

SystemRequestTimeStamp: time stamp when the computer sent the request to the eye tracker.

DeviceTimeStamp: time stamp when the eye tracker received the request, according to the eye trackers clock.

SystemResponseTimeStamp: time stamp when the computer received the response from the eye tracker.

If no input is provided an array of TimeSynchronizationReference instances will be returned. If an input 'flat' is provided the function will return a struct with arrays of the collected data for each individual property of the time synchronization data.

If an error occurs durring this stream the data returned will be of the class StreamError.

Returns: array with instances of class TimeSynchronizationReference.

%% Get Tine Synchronization Data
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

% The first call subscribes to the stream and returns either data
% (might be empty if no data has been received yet) or any error that
% happened during the subscription.
result = eyetracker.get_time_sync_data();

if isa(result,'StreamError')
    fprintf('Error: %s\n',char(result.Error));
    fprintf('Source: %s\n',char(result.Source));
    fprintf('SystemTimeStamp: %d\n',result.SystemTimeStamp);
    fprintf('Message: %s\n',result.Message);

elseif isa(result,'TimeSynchronizationReference')
    % Collect data for 1 seconds.
    pause(1);

    % The subsequent calls return the current values in the stream buffer.
    % If a flat structure is prefered just use an extra input 'flat'.
    % i.e. time_sync_data = eyetracker.get_time_sync_data('flat');
    time_sync_data = eyetracker.get_time_sync_data();

    eyetracker.stop_time_sync_data();

    fprintf('Collected %d data points\n',size(time_sync_data,2));

    % To select the most recent data point simply select the last value of the
    % buffer.
    latest_time_sync_data = time_sync_data(end);

    fprintf('SystemRequestTimeStamp: %d\n',latest_time_sync_data.SystemRequestTimeStamp);
    fprintf('DeviceTimeStamp: %d\n',latest_time_sync_data.DeviceTimeStamp);
    fprintf('SystemResponseTimeStamp: %d\n',latest_time_sync_data.SystemResponseTimeStamp);
end

Stop Time Synchronization Data

Stops the current time synchronization stream.

%% Get Tine Synchronization Data
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

% The first call subscribes to the stream and returns either data
% (might be empty if no data has been received yet) or any error that
% happened during the subscription.
result = eyetracker.get_time_sync_data();

if isa(result,'StreamError')
    fprintf('Error: %s\n',char(result.Error));
    fprintf('Source: %s\n',char(result.Source));
    fprintf('SystemTimeStamp: %d\n',result.SystemTimeStamp);
    fprintf('Message: %s\n',result.Message);

elseif isa(result,'TimeSynchronizationReference')
    % Collect data for 1 seconds.
    pause(1);

    % The subsequent calls return the current values in the stream buffer.
    % If a flat structure is prefered just use an extra input 'flat'.
    % i.e. time_sync_data = eyetracker.get_time_sync_data('flat');
    time_sync_data = eyetracker.get_time_sync_data();

    eyetracker.stop_time_sync_data();

    fprintf('Collected %d data points\n',size(time_sync_data,2));

    % To select the most recent data point simply select the last value of the
    % buffer.
    latest_time_sync_data = time_sync_data(end);

    fprintf('SystemRequestTimeStamp: %d\n',latest_time_sync_data.SystemRequestTimeStamp);
    fprintf('DeviceTimeStamp: %d\n',latest_time_sync_data.DeviceTimeStamp);
    fprintf('SystemResponseTimeStamp: %d\n',latest_time_sync_data.SystemResponseTimeStamp);
end

Get Gaze Data

Provides data for gaze. Time synchronized gaze is not supported on all eye trackers, other eye trackers need additional license to activate this feature. Only supports streaming from one eyetracker at a time.

If there is the need to use a different eyetracker, use the method stop_gaze_data first and start a new data stream for the new eyetracker.

It is possible to check the validity of the data received using the validity field. Complementary, if some specific data field is invalid then it will contain nan (Not a number) as its value.

If no input is provided an array of GazeData instances will be returned. If an input 'flat' is provided the function will return a struct with arrays of the collected data for each individual property of the gaze data.

If an error occurs durring this stream the data returned will be of the class StreamError.

Returns: array with instances of class GazeData.

%% Get Gaze Data
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

% The first call subscribes to the stream and returns either data
% (might be empty if no data has been received yet) or any error that
% happened during the subscription.
result = eyetracker.get_gaze_data();

if isa(result,'StreamError')
    fprintf('Error: %s\n',char(result.Error));
    fprintf('Source: %s\n',char(result.Source));
    fprintf('SystemTimeStamp: %d\n',result.SystemTimeStamp);
    fprintf('Message: %s\n',result.Message);

elseif isa(result,'GazeData')

    % Collect data for 1 seconds.
    pause(1);

    % The subsequent calls return the current values in the stream buffer.
    % If a flat structure is prefered just use an extra input 'flat'.
    % i.e. gaze_data = eyetracker.get_gaze_data('flat');
    gaze_data = eyetracker.get_gaze_data();

    eyetracker.stop_gaze_data();

    fprintf('Collected %d data points\n',size(gaze_data,2));

    % To select the most recent data point simply select the last value of the
    % buffer.
    latest_gaze_data = gaze_data(end);

    fprintf('SystemRequestTimeStamp: %d\n',latest_gaze_data.SystemTimeStamp);
    fprintf('DeviceTimeStamp: %d\n',latest_gaze_data.DeviceTimeStamp);

    disp('Left Eye');

    fprintf('GazePoint.OnDisplayArea: %.2f %.2f\n',latest_gaze_data.LeftEye.GazePoint.OnDisplayArea);
    fprintf('GazePoint.InUserCoordinateSystem: %.2f %.2f %.2f\n',latest_gaze_data.LeftEye.GazePoint.InUserCoordinateSystem);
    fprintf('GazePoint.Validity: %s\n',char(latest_gaze_data.LeftEye.GazePoint.Validity));

    fprintf('GazeOrigin.InUserCoordinateSystem: %.2f %.2f %.2f\n',latest_gaze_data.LeftEye.GazeOrigin.InUserCoordinateSystem);
    fprintf('GazeOrigin.InTrackBoxCoordinateSystem: %.2f %.2f %.2f\n',latest_gaze_data.LeftEye.GazeOrigin.InTrackBoxCoordinateSystem);
    fprintf('GazeOrigin.Validity: %s\n',char(latest_gaze_data.LeftEye.GazeOrigin.Validity));

    fprintf('Pupil.Diameter: %.2f\n',latest_gaze_data.LeftEye.Pupil.Diameter);
    fprintf('Pupil.Validity: %s\n',char(latest_gaze_data.LeftEye.Pupil.Validity));

    disp('Right Eye');

    fprintf('GazePoint.OnDisplayArea: %.2f %.2f\n',latest_gaze_data.RightEye.GazePoint.OnDisplayArea);
    fprintf('GazePoint.InUserCoordinateSystem: %.2f %.2f %.2f\n',latest_gaze_data.RightEye.GazePoint.InUserCoordinateSystem);
    fprintf('GazePoint.Validity: %s\n',char(latest_gaze_data.RightEye.GazePoint.Validity));

    fprintf('GazeOrigin.InUserCoordinateSystem: %.2f %.2f %.2f\n',latest_gaze_data.RightEye.GazeOrigin.InUserCoordinateSystem);
    fprintf('GazeOrigin.InTrackBoxCoordinateSystem: %.2f %.2f %.2f\n',latest_gaze_data.RightEye.GazeOrigin.InTrackBoxCoordinateSystem);
    fprintf('GazeOrigin.Validity: %s\n',char(latest_gaze_data.RightEye.GazeOrigin.Validity));

    fprintf('Pupil.Diameter: %.2f\n',latest_gaze_data.RightEye.Pupil.Diameter);
    fprintf('Pupil.Validity: %s\n',char(latest_gaze_data.RightEye.Pupil.Validity));
end


Stop Gaze Data

Stops the current gaze data stream.

%% Get Gaze Data
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

% The first call subscribes to the stream and returns either data
% (might be empty if no data has been received yet) or any error that
% happened during the subscription.
result = eyetracker.get_gaze_data();

if isa(result,'StreamError')
    fprintf('Error: %s\n',char(result.Error));
    fprintf('Source: %s\n',char(result.Source));
    fprintf('SystemTimeStamp: %d\n',result.SystemTimeStamp);
    fprintf('Message: %s\n',result.Message);

elseif isa(result,'GazeData')

    % Collect data for 1 seconds.
    pause(1);

    % The subsequent calls return the current values in the stream buffer.
    % If a flat structure is prefered just use an extra input 'flat'.
    % i.e. gaze_data = eyetracker.get_gaze_data('flat');
    gaze_data = eyetracker.get_gaze_data();

    eyetracker.stop_gaze_data();

    fprintf('Collected %d data points\n',size(gaze_data,2));

    % To select the most recent data point simply select the last value of the
    % buffer.
    latest_gaze_data = gaze_data(end);

    fprintf('SystemRequestTimeStamp: %d\n',latest_gaze_data.SystemTimeStamp);
    fprintf('DeviceTimeStamp: %d\n',latest_gaze_data.DeviceTimeStamp);

    disp('Left Eye');

    fprintf('GazePoint.OnDisplayArea: %.2f %.2f\n',latest_gaze_data.LeftEye.GazePoint.OnDisplayArea);
    fprintf('GazePoint.InUserCoordinateSystem: %.2f %.2f %.2f\n',latest_gaze_data.LeftEye.GazePoint.InUserCoordinateSystem);
    fprintf('GazePoint.Validity: %s\n',char(latest_gaze_data.LeftEye.GazePoint.Validity));

    fprintf('GazeOrigin.InUserCoordinateSystem: %.2f %.2f %.2f\n',latest_gaze_data.LeftEye.GazeOrigin.InUserCoordinateSystem);
    fprintf('GazeOrigin.InTrackBoxCoordinateSystem: %.2f %.2f %.2f\n',latest_gaze_data.LeftEye.GazeOrigin.InTrackBoxCoordinateSystem);
    fprintf('GazeOrigin.Validity: %s\n',char(latest_gaze_data.LeftEye.GazeOrigin.Validity));

    fprintf('Pupil.Diameter: %.2f\n',latest_gaze_data.LeftEye.Pupil.Diameter);
    fprintf('Pupil.Validity: %s\n',char(latest_gaze_data.LeftEye.Pupil.Validity));

    disp('Right Eye');

    fprintf('GazePoint.OnDisplayArea: %.2f %.2f\n',latest_gaze_data.RightEye.GazePoint.OnDisplayArea);
    fprintf('GazePoint.InUserCoordinateSystem: %.2f %.2f %.2f\n',latest_gaze_data.RightEye.GazePoint.InUserCoordinateSystem);
    fprintf('GazePoint.Validity: %s\n',char(latest_gaze_data.RightEye.GazePoint.Validity));

    fprintf('GazeOrigin.InUserCoordinateSystem: %.2f %.2f %.2f\n',latest_gaze_data.RightEye.GazeOrigin.InUserCoordinateSystem);
    fprintf('GazeOrigin.InTrackBoxCoordinateSystem: %.2f %.2f %.2f\n',latest_gaze_data.RightEye.GazeOrigin.InTrackBoxCoordinateSystem);
    fprintf('GazeOrigin.Validity: %s\n',char(latest_gaze_data.RightEye.GazeOrigin.Validity));

    fprintf('Pupil.Diameter: %.2f\n',latest_gaze_data.RightEye.Pupil.Diameter);
    fprintf('Pupil.Validity: %s\n',char(latest_gaze_data.RightEye.Pupil.Validity));
end


Get HMD Gaze Data

Provides data for HMD gaze. Only supports streaming from one eyetracker at a time.

If there is the need to use a different eyetracker, use the method stop_hmd_gaze_data first and start a new data stream for the new eyetracker.

It is possible to check the validity of the data received using the validity field. Complementary, if some specific data field is invalid then it will contain nan (Not a number) as its value.

If no input is provided an array of HMDGazeData instances will be returned. If an input 'flat' is provided the function will return a struct with arrays of the collected data for each individual property of the gaze data.

If an error occurs durring this stream the data returned will be of the class StreamError.

Returns: array with instances of class HMDGazeData.

%% Get HMD Gaze Data
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

% The first call subscribes to the stream and returns either data
% (might be empty if no data has been received yet) or any error that
% happened during the subscription.
result = eyetracker.get_hmd_gaze_data();

if isa(result,'StreamError')
    fprintf('Error: %s\n',char(result.Error));
    fprintf('Source: %s\n',char(result.Source));
    fprintf('SystemTimeStamp: %d\n',result.SystemTimeStamp);
    fprintf('Message: %s\n',result.Message);

elseif isa(result,'HMDGazeData')

    % Collect data for 1 seconds.
    pause(1);

    % The subsequent calls return the current values in the stream buffer.
    % If a flat structure is prefered just use an extra input 'flat'.
    % i.e. gaze_data = eyetracker.get_gaze_data('flat');
    hmd_gaze_data = eyetracker.get_hmd_gaze_data();

    eyetracker.stop_hmd_gaze_data();

    fprintf('Collected %d data points\n',size(hmd_gaze_data,2));

    % To select the most recent data point simply select the last value of the
    % buffer.
    latest_hmd_gaze_data = hmd_gaze_data(end);

    fprintf('SystemRequestTimeStamp: %d\n',latest_hmd_gaze_data.SystemTimeStamp);
    fprintf('DeviceTimeStamp: %d\n',latest_hmd_gaze_data.DeviceTimeStamp);

    disp('Left Eye');

    fprintf('GazeDirection.UnitVector: %.2f %.2f %.2f\n',latest_hmd_gaze_data.LeftEye.GazeDirection.UnitVector);
    fprintf('GazeDirection.Validity: %s\n',char(latest_hmd_gaze_data.LeftEye.GazeOrigin.Validity));

    fprintf('GazeOrigin.PositionInHMDCoordinates: %.2f %.2f %.2f\n',latest_hmd_gaze_data.LeftEye.GazeOrigin.PositionInHMDCoordinates);
    fprintf('GazeOrigin.Validity: %s\n',char(latest_hmd_gaze_data.LeftEye.GazeOrigin.Validity));

    fprintf('Pupil.Diameter: %.2f\n',latest_hmd_gaze_data.LeftEye.Pupil.Diameter);
    fprintf('Pupil.Validity: %s\n',char(latest_hmd_gaze_data.LeftEye.Pupil.Validity));

    fprintf('PupilPosition.PositionInTrackingArea: %.2f %.2f\n',latest_hmd_gaze_data.LeftEye.PupilPosition.PositionInTrackingArea);
    fprintf('PupilPosition.Validity: %s\n',char(latest_hmd_gaze_data.LeftEye.PupilPosition.Validity));

    disp('Right Eye');

    fprintf('GazeDirection.UnitVector: %.2f %.2f %.2f\n',latest_hmd_gaze_data.RightEye.GazeDirection.UnitVector);
    fprintf('GazeDirection.Validity: %s\n',char(latest_hmd_gaze_data.RightEye.GazeOrigin.Validity));

    fprintf('GazeOrigin.PositionInHMDCoordinates: %.2f %.2f %.2f\n',latest_hmd_gaze_data.RightEye.GazeOrigin.PositionInHMDCoordinates);
    fprintf('GazeOrigin.Validity: %s\n',char(latest_hmd_gaze_data.RightEye.GazeOrigin.Validity));

    fprintf('Pupil.Diameter: %.2f\n',latest_hmd_gaze_data.RightEye.Pupil.Diameter);
    fprintf('Pupil.Validity: %s\n',char(latest_hmd_gaze_data.RightEye.Pupil.Validity));

    fprintf('PupilPosition.PositionInTrackingArea: %.2f %.2f\n',latest_hmd_gaze_data.LeftEye.PupilPosition.PositionInTrackingArea);
    fprintf('PupilPosition.Validity: %s\n',char(latest_hmd_gaze_data.LeftEye.PupilPosition.Validity));
end

Stop HMD Gaze Data

Stops the current HMD gaze data stream.

%% Get HMD Gaze Data
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

% The first call subscribes to the stream and returns either data
% (might be empty if no data has been received yet) or any error that
% happened during the subscription.
result = eyetracker.get_hmd_gaze_data();

if isa(result,'StreamError')
    fprintf('Error: %s\n',char(result.Error));
    fprintf('Source: %s\n',char(result.Source));
    fprintf('SystemTimeStamp: %d\n',result.SystemTimeStamp);
    fprintf('Message: %s\n',result.Message);

elseif isa(result,'HMDGazeData')

    % Collect data for 1 seconds.
    pause(1);

    % The subsequent calls return the current values in the stream buffer.
    % If a flat structure is prefered just use an extra input 'flat'.
    % i.e. gaze_data = eyetracker.get_gaze_data('flat');
    hmd_gaze_data = eyetracker.get_hmd_gaze_data();

    eyetracker.stop_hmd_gaze_data();

    fprintf('Collected %d data points\n',size(hmd_gaze_data,2));

    % To select the most recent data point simply select the last value of the
    % buffer.
    latest_hmd_gaze_data = hmd_gaze_data(end);

    fprintf('SystemRequestTimeStamp: %d\n',latest_hmd_gaze_data.SystemTimeStamp);
    fprintf('DeviceTimeStamp: %d\n',latest_hmd_gaze_data.DeviceTimeStamp);

    disp('Left Eye');

    fprintf('GazeDirection.UnitVector: %.2f %.2f %.2f\n',latest_hmd_gaze_data.LeftEye.GazeDirection.UnitVector);
    fprintf('GazeDirection.Validity: %s\n',char(latest_hmd_gaze_data.LeftEye.GazeOrigin.Validity));

    fprintf('GazeOrigin.PositionInHMDCoordinates: %.2f %.2f %.2f\n',latest_hmd_gaze_data.LeftEye.GazeOrigin.PositionInHMDCoordinates);
    fprintf('GazeOrigin.Validity: %s\n',char(latest_hmd_gaze_data.LeftEye.GazeOrigin.Validity));

    fprintf('Pupil.Diameter: %.2f\n',latest_hmd_gaze_data.LeftEye.Pupil.Diameter);
    fprintf('Pupil.Validity: %s\n',char(latest_hmd_gaze_data.LeftEye.Pupil.Validity));

    fprintf('PupilPosition.PositionInTrackingArea: %.2f %.2f\n',latest_hmd_gaze_data.LeftEye.PupilPosition.PositionInTrackingArea);
    fprintf('PupilPosition.Validity: %s\n',char(latest_hmd_gaze_data.LeftEye.PupilPosition.Validity));

    disp('Right Eye');

    fprintf('GazeDirection.UnitVector: %.2f %.2f %.2f\n',latest_hmd_gaze_data.RightEye.GazeDirection.UnitVector);
    fprintf('GazeDirection.Validity: %s\n',char(latest_hmd_gaze_data.RightEye.GazeOrigin.Validity));

    fprintf('GazeOrigin.PositionInHMDCoordinates: %.2f %.2f %.2f\n',latest_hmd_gaze_data.RightEye.GazeOrigin.PositionInHMDCoordinates);
    fprintf('GazeOrigin.Validity: %s\n',char(latest_hmd_gaze_data.RightEye.GazeOrigin.Validity));

    fprintf('Pupil.Diameter: %.2f\n',latest_hmd_gaze_data.RightEye.Pupil.Diameter);
    fprintf('Pupil.Validity: %s\n',char(latest_hmd_gaze_data.RightEye.Pupil.Validity));

    fprintf('PupilPosition.PositionInTrackingArea: %.2f %.2f\n',latest_hmd_gaze_data.LeftEye.PupilPosition.PositionInTrackingArea);
    fprintf('PupilPosition.Validity: %s\n',char(latest_hmd_gaze_data.LeftEye.PupilPosition.Validity));
end

Get External Signal Data

Provides data for the ExternalSignal New data is delivered when the value of the external signal port on the eye tracker device changes, otherwise an empty array will be returned. Not all eye trackers have output trigger port. The output feature could be used to synchronize the eye tracker data with other devices data. The output data contains time reference that matches the time reference on the time synchronized gaze data.

If no input is provided an array of ExternalSignal instances will be returned. If an input 'flat' is provided the function will return a struct with arrays of the collected data for each individual property of the external signal data.

If an error occurs durring this stream the data returned will be of the class StreamError.

Returns: array with instances of class ExternalSignal.

%% Get External Signal Data
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.16.101';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

% It is possible to check if the eyetracker supports this stream
if ismember(Capabilities.HasExternalSignal,eyetracker.DeviceCapabilities)
    disp('External Signal Supported');
else
    disp('External Signal Not Supported');
end

% The first call subscribes to the stream and returns either data
% (might be empty if no data has been received yet) or any error that
% happened during the subscription.
% If a flat structure is prefered just use an extra input 'flat'.
% i.e. eyetracker.get_external_signal_data('flat');
result = eyetracker.get_external_signal_data();

if isa(result,'StreamError')
    fprintf('Error: %s\n',char(result.Error));
    fprintf('Source: %s\n',char(result.Source));
    fprintf('SystemTimeStamp: %d\n',result.SystemTimeStamp);
    fprintf('Message: %s\n',result.Message);

elseif isa(result,'ExternalSignal')
   % Collect data for 1 seconds.
    pause(1);

    % The subsequent calls return the current values in the stream buffer.
    external_signal_data = eyetracker.get_external_signal_data();

    eyetracker.stop_external_signal_data();

    fprintf('Collected %d data points\n',size(external_signal_data,2));

    % To select the most recent data point simply select the last value of the
    % buffer.
    latest_external_signal_data = external_signal_data(end);

    fprintf('SystemTimeStamp: %d\n',latest_external_signal_data.SystemTimeStamp);
    fprintf('DeviceTimeStamp: %d\n',latest_external_signal_data.DeviceTimeStamp);
    fprintf('Value: %d\n',latest_external_signal_data.Value);
    fprintf('ChangeType: %s\n',char(latest_external_signal_data.ChangeType));
end

Stop External Signal Data

Stops the current external_signal data stream.

%% Get External Signal Data
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.16.101';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

% It is possible to check if the eyetracker supports this stream
if ismember(Capabilities.HasExternalSignal,eyetracker.DeviceCapabilities)
    disp('External Signal Supported');
else
    disp('External Signal Not Supported');
end

% The first call subscribes to the stream and returns either data
% (might be empty if no data has been received yet) or any error that
% happened during the subscription.
% If a flat structure is prefered just use an extra input 'flat'.
% i.e. eyetracker.get_external_signal_data('flat');
result = eyetracker.get_external_signal_data();

if isa(result,'StreamError')
    fprintf('Error: %s\n',char(result.Error));
    fprintf('Source: %s\n',char(result.Source));
    fprintf('SystemTimeStamp: %d\n',result.SystemTimeStamp);
    fprintf('Message: %s\n',result.Message);

elseif isa(result,'ExternalSignal')
   % Collect data for 1 seconds.
    pause(1);

    % The subsequent calls return the current values in the stream buffer.
    external_signal_data = eyetracker.get_external_signal_data();

    eyetracker.stop_external_signal_data();

    fprintf('Collected %d data points\n',size(external_signal_data,2));

    % To select the most recent data point simply select the last value of the
    % buffer.
    latest_external_signal_data = external_signal_data(end);

    fprintf('SystemTimeStamp: %d\n',latest_external_signal_data.SystemTimeStamp);
    fprintf('DeviceTimeStamp: %d\n',latest_external_signal_data.DeviceTimeStamp);
    fprintf('Value: %d\n',latest_external_signal_data.Value);
    fprintf('ChangeType: %s\n',char(latest_external_signal_data.ChangeType));
end

Get Eye Image

Provides data for the eye_image Only supports streaming from one eyetracker at a time. If there is the need to use a different eyetracker, use the method stop_eye_image first and start a new data stream for the new eyetracker. 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.

If no input is provided an array of EyeImage instances will be returned. If an input 'flat' is provided the function will return a struct with arrays of the collected data for each individual property of the eye image data.

If an error occurs durring this stream the data returned will be of the class StreamError.

Returns: array with instances of class EyeImage.

%% Get Eye Image
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device_with_eye_image';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

% It is possible to check if the eyetracker supports this stream
if ismember(Capabilities.HasEyeImages,eyetracker.DeviceCapabilities)
    disp('Eye Image Supported');
else
    disp('Eye Image Not Supported');
end

% The first call subscribes to the stream and returns either data
% (might be empty if no data has been received yet) or any error that
% happened during the subscription.
result = eyetracker.get_eye_image();

if isa(result,'StreamError')
    fprintf('Error: %s\n',char(result.Error));
    fprintf('Source: %s\n',char(result.Source));
    fprintf('SystemTimeStamp: %d\n',result.SystemTimeStamp);
    fprintf('Message: %s\n',result.Message);

elseif isa(result,'EyeImage')

    % Collect data for 1 seconds.
    pause(1);

    % The subsequent calls return the current values in the stream buffer.
    % If a flat structure is prefered just use an extra input 'flat'.
    % i.e. eye_images = eyetracker.get_eye_image('flat');
    eye_images = eyetracker.get_eye_image();

    eyetracker.stop_eye_image();

    fprintf('Collected %d eye images\n',size(eye_images,2));

    % To select the most recent data point simply select the last value of the
    % buffer.
    latest_eye_image = eye_images(end);

    fprintf('SystemTimeStamp: %d\n',latest_eye_image.SystemTimeStamp);
    fprintf('DeviceTimeStamp: %d\n',latest_eye_image.DeviceTimeStamp);
    fprintf('CameraId: %d\n',latest_eye_image.CameraId);
    fprintf('Type: %s\n',char(latest_eye_image.Type));

    imshow(latest_eye_image.Image);
end

Stop Eye Image

Stops the current eye image stream.

%% Get Eye Image
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device_with_eye_image';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

% It is possible to check if the eyetracker supports this stream
if ismember(Capabilities.HasEyeImages,eyetracker.DeviceCapabilities)
    disp('Eye Image Supported');
else
    disp('Eye Image Not Supported');
end

% The first call subscribes to the stream and returns either data
% (might be empty if no data has been received yet) or any error that
% happened during the subscription.
result = eyetracker.get_eye_image();

if isa(result,'StreamError')
    fprintf('Error: %s\n',char(result.Error));
    fprintf('Source: %s\n',char(result.Source));
    fprintf('SystemTimeStamp: %d\n',result.SystemTimeStamp);
    fprintf('Message: %s\n',result.Message);

elseif isa(result,'EyeImage')

    % Collect data for 1 seconds.
    pause(1);

    % The subsequent calls return the current values in the stream buffer.
    % If a flat structure is prefered just use an extra input 'flat'.
    % i.e. eye_images = eyetracker.get_eye_image('flat');
    eye_images = eyetracker.get_eye_image();

    eyetracker.stop_eye_image();

    fprintf('Collected %d eye images\n',size(eye_images,2));

    % To select the most recent data point simply select the last value of the
    % buffer.
    latest_eye_image = eye_images(end);

    fprintf('SystemTimeStamp: %d\n',latest_eye_image.SystemTimeStamp);
    fprintf('DeviceTimeStamp: %d\n',latest_eye_image.DeviceTimeStamp);
    fprintf('CameraId: %d\n',latest_eye_image.CameraId);
    fprintf('Type: %s\n',char(latest_eye_image.Type));

    imshow(latest_eye_image.Image);
end

Apply Licenses

Sets a key ring of licenses for unlocking features of the eye tracker. Returns a cell array with the failed licenses. If all licenses were succesfully applied the cell array returned will be empty.

Parameters: array or single instance of class LicenseKey. Returns: array with instances of class FailedLicense.

%% Apply Licenses
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tobii-ttp://is405-030106416232';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

licenses_path = {'licenses/se_license_key_IS4BA-00000057'
                'licenses/se_license_key_IS405-030106416232'
                'licenses/se_license_key_IS405-030106416222'
                };

number_of_licenses = size(licenses_path,2);

input_licenses = LicenseKey.empty(number_of_licenses,0);

for i=1:number_of_licenses
    fileID = fopen(file_path,'r');
    input_licenses(i) = LicenseKey(fread(fileID));
    fclose(fileID);
end

% Returns an array with the licenses that were not successfully applied.
% Should return empty if all the licenses were correctly applied.
failed_licenses = eyetracker.apply_licenses(input_licenses);


Clear Applied Licenses

Clears any previously applied licenses

%% Clear Applied Licenses
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

eyetracker.clear_applied_licenses();

Get Display Area

Gets the size and corners of the display area..

Returns: instance of class DisplayArea.

%% Get Display Area
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

display_area = eyetracker.get_display_area();


fprintf('BottomLeft: %.2f %.2f %.2f\n',display_area.BottomLeft);
fprintf('BottomRight: %.2f %.2f %.2f\n',display_area.BottomLeft);
fprintf('TopLeft: %.2f %.2f %.2f\n',display_area.TopLeft);
fprintf('TopRight: %.2f %.2f %.2f\n',display_area.TopRight);
fprintf('Height: %.2f\n',display_area.Height);
fprintf('Width: %.2f\n',display_area.Width);

Get Track Box

Gets the track box of the eye tracker.

Returns: instance of class TrackBox.

%% Get Track Box
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example: 
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

track_box = eyetracker.get_track_box();

fprintf('BackLowerRight: %.2f %.2f %.2f\n',track_box.BackLowerRight);
fprintf('BackUpperLeft: %.2f %.2f %.2f\n',track_box.BackUpperLeft);
fprintf('BackUpperRight: %.2f %.2f %.2f\n',track_box.BackUpperRight);
fprintf('FrontLowerLeft: %.2f %.2f %.2f\n',track_box.FrontLowerLeft);
fprintf('FrontLowerRight: %.2f %.2f %.2f\n',track_box.FrontLowerRight);
fprintf('FrontLowerRight: %.2f %.2f %.2f\n',track_box.FrontLowerRight);
fprintf('FrontUpperLeft: %.2f %.2f %.2f\n',track_box.FrontUpperLeft);
fprintf('FrontUpperRight: %.2f %.2f %.2f\n',track_box.FrontUpperRight);

Enable Notifications

Enables the notifications for the eyetracker.

%% Enable Notifications
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

% First the notifications will be enabled
eyetracker.enable_notifications();

% For example, changing the gaze output frequency will generate a
% notification
available_gaze_output_frequencies = eyetracker.get_all_gaze_output_frequencies();
gaze_output_frequency = available_gaze_output_frequencies(1);
eyetracker.set_gaze_output_frequency(gaze_output_frequency)

% It is possible to catch the notifcation by checking 'lastwarn'
[message,ID] = lastwarn

eyetracker.disable_notifications();

Disable Notifications

Disables the notifications for the eyetracker.

%% Enable Notifications
Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://172.28.195.1';

eyetracker = Tobii.get_eyetracker(eyetracker_address);

% First the notifications will be enabled
eyetracker.enable_notifications();

% For example, changing the gaze output frequency will generate a
% notification
available_gaze_output_frequencies = eyetracker.get_all_gaze_output_frequencies();
gaze_output_frequency = available_gaze_output_frequencies(1);
eyetracker.set_gaze_output_frequency(gaze_output_frequency)

% It is possible to catch the notifcation by checking 'lastwarn'
[message,ID] = lastwarn

eyetracker.disable_notifications();

Get HMD Lens Configuration

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

File 'SampleCode/GetHMDLensConfiguration_publish.m' not found.

Set HMD Lens Configuration

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

File 'SampleCode/SetHMDLensConfiguration_publish.m' not found.

Version

1.1.0.23

Copyright 2017 Tobii Pro