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

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

Runtime Version

Gets the runtime version of the eye tracker.

eyetracker.RuntimeVersion

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
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

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
clear;

Tobii = EyeTrackingOperations();

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

try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

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
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

try
    gaze_output_frequency = eyetracker.get_gaze_output_frequency();
catch ME
    fprintf(ME.message);
end
    

Set Gaze Output Frequency

Sets the current gaze output frequency

Parameters: double with the desired gaze output frequency.

%% Set Gaze Output Frequency
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

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
clear;

Tobii = EyeTrackingOperations();

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

try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

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
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

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
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

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
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

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
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

calibration_path = 'sample.calib';

fid = fopen(calibration_path,'r');

data = fread(fid);

fclose(fid);

try
    eyetracker.apply_calibration_data(data);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error214'))
        fprintf('Unable to apply calibration data.\n');
        return
    end
end

Get Time Synchronization Data

Provides data for the 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 during this stream the data returned will be of the class StreamError.

For every call of this method an array of the collected data will be returned. This means that on the first call, if no error has occurred, an empty array will be returned. Note that the returned data will not be the data collected since the first call of this method, only the data collected in between calls will be returned.

Returns: array with instances of class TimeSynchronizationReference.

%% Get Tine Synchronization Data
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
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.
try
    eyetracker.get_time_sync_data();
catch ME
    fprintf(ME.message);
    return
end
pause(1);
result = eyetracker.get_time_sync_data();

if isa(result,'StreamError')
    fprintf('Error: %s\n',string(result.Error.value));
    fprintf('Source: %s\n',string(result.Source.value));
    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
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
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.
try
    eyetracker.get_time_sync_data();
catch ME
    fprintf(ME.message);
    return
end
pause(1);
result = eyetracker.get_time_sync_data();

if isa(result,'StreamError')
    fprintf('Error: %s\n',string(result.Error.value));
    fprintf('Source: %s\n',string(result.Source.value));
    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 during this stream the data returned will be of the class StreamError.

For every call of this method an array of the collected data will be returned. This means that on the first call, if no error has occurred, an empty array will be returned. Note that the returned data will not be the data collected since the first call of this method, only the data collected in between calls will be returned.

Returns: array with instances of class GazeData.

%% Get Gaze Data
clear;

Tobii = EyeTrackingOperations();

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

try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
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.

eyetracker.get_gaze_data();
pause(1);
result = eyetracker.get_gaze_data();

if isa(result,'StreamError')
    fprintf('Error: %s\n',string(result.Error.value));
    fprintf('Source: %s\n',string(result.Source.value));
    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: %d\n',latest_gaze_data.LeftEye.GazePoint.Validity.value);

    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: %d\n',latest_gaze_data.LeftEye.GazeOrigin.Validity.value);

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

    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: %d\n',latest_gaze_data.RightEye.GazePoint.Validity.value);

    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: %d\n',latest_gaze_data.RightEye.GazeOrigin.Validity.value);

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


Stop Gaze Data

Stops the current gaze data stream.

%% Get Gaze Data
clear;

Tobii = EyeTrackingOperations();

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

try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
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.

eyetracker.get_gaze_data();
pause(1);
result = eyetracker.get_gaze_data();

if isa(result,'StreamError')
    fprintf('Error: %s\n',string(result.Error.value));
    fprintf('Source: %s\n',string(result.Source.value));
    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: %d\n',latest_gaze_data.LeftEye.GazePoint.Validity.value);

    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: %d\n',latest_gaze_data.LeftEye.GazeOrigin.Validity.value);

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

    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: %d\n',latest_gaze_data.RightEye.GazePoint.Validity.value);

    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: %d\n',latest_gaze_data.RightEye.GazeOrigin.Validity.value);

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


Get User Position Guide

Provides data for user position guide. Only supports streaming from one eyetracker at a time.

If there is the need to use a different eyetracker, use the method stop_user_position_guide 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 data is available an instance of UserPositionGuide will be returned, otherwise the output will be empty.

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

For every call of this method an array of the collected data will be returned. This means that on the first call, if no error has occurred, an empty array will be returned. Note that the returned data will not be the data collected since the first call of this method, only the data collected in between calls will be returned.

Returns: array with instances of class UserPositionGuide.

%% Get User Position Guide
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
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.
try
    eyetracker.get_user_position_guide();
catch ME
    fprintf(ME.message);
    return
end
pause(1);
result = eyetracker.get_user_position_guide();

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

elseif isa(result,'UserPositionGuide')

    % 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. user_position_guide = eyetracker.get_user_position_guide('flat');
    user_position_guide = eyetracker.get_user_position_guide();

    eyetracker.stop_user_position_guide();

    disp('Left Eye');

    fprintf('UserPositionGuide.Position: %.2f %.2f %.2f\n',user_position_guide.LeftEye.Position);
    fprintf('UserPositionGuide.Validity: %d\n',user_position_guide.LeftEye.Validity.value);

    disp('Right Eye');

    fprintf('UserPositionGuide.Position: %.2f %.2f %.2f\n',user_position_guide.RightEye.Position);
    fprintf('UserPositionGuide.Validity: %d\n',user_position_guide.RightEye.Validity.value);
end


Stop User Position

Stops the current user position guide stream.

%% Get User Position Guide
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
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.
try
    eyetracker.get_user_position_guide();
catch ME
    fprintf(ME.message);
    return
end
pause(1);
result = eyetracker.get_user_position_guide();

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

elseif isa(result,'UserPositionGuide')

    % 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. user_position_guide = eyetracker.get_user_position_guide('flat');
    user_position_guide = eyetracker.get_user_position_guide();

    eyetracker.stop_user_position_guide();

    disp('Left Eye');

    fprintf('UserPositionGuide.Position: %.2f %.2f %.2f\n',user_position_guide.LeftEye.Position);
    fprintf('UserPositionGuide.Validity: %d\n',user_position_guide.LeftEye.Validity.value);

    disp('Right Eye');

    fprintf('UserPositionGuide.Position: %.2f %.2f %.2f\n',user_position_guide.RightEye.Position);
    fprintf('UserPositionGuide.Validity: %d\n',user_position_guide.RightEye.Validity.value);
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 during this stream the data returned will be of the class StreamError.

For every call of this method an array of the collected data will be returned. This means that on the first call, if no error has occurred, an empty array will be returned. Note that the returned data will not be the data collected since the first call of this method, only the data collected in between calls will be returned.

Returns: array with instances of class HMDGazeData.

%% Get HMD Gaze Data
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
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.
try
    eyetracker.get_hmd_gaze_data();
catch ME
    fprintf(ME.message);
    return
end
pause(1);
result = eyetracker.get_hmd_gaze_data();

if isa(result,'StreamError')
    fprintf('Error: %s\n',string(result.Error.value));
    fprintf('Source: %s\n',string(result.Source.value));
    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',latest_hmd_gaze_data.LeftEye.GazeOrigin.Validity.Value);

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

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

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

    disp('Right Eye');

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

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

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

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

Stop HMD Gaze Data

Stops the current HMD gaze data stream.

%% Get HMD Gaze Data
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
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.
try
    eyetracker.get_hmd_gaze_data();
catch ME
    fprintf(ME.message);
    return
end
pause(1);
result = eyetracker.get_hmd_gaze_data();

if isa(result,'StreamError')
    fprintf('Error: %s\n',string(result.Error.value));
    fprintf('Source: %s\n',string(result.Source.value));
    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',latest_hmd_gaze_data.LeftEye.GazeOrigin.Validity.Value);

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

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

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

    disp('Right Eye');

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

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

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

    fprintf('PupilPosition.PositionInTrackingArea: %.2f %.2f\n',latest_hmd_gaze_data.LeftEye.PupilPosition.PositionInTrackingArea);
    fprintf('PupilPosition.Validity: %s\n',string(latest_hmd_gaze_data.LeftEye.PupilPosition.Validity.Value));
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 during this stream the data returned will be of the class StreamError.

For every call of this method an array of the collected data will be returned. This means that on the first call, if no error has occurred, an empty array will be return. Note that the returned data will not be the data collected since the first call of this method, only the data collected in between calls will be returned.

Returns: array with instances of class ExternalSignal.

%% Get External Signal Data
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

% It is possible to check if the eyetracker supports this stream
if ismember(EyeTrackerCapabilities.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');
eyetracker.get_external_signal_data();
pause(1);
result = eyetracker.get_external_signal_data();

if isa(result,'StreamError')
    fprintf('Error: %s\n',string(result.Error.value));
    fprintf('Source: %s\n',string(result.Source.value));
    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',string(latest_external_signal_data.ChangeType.value));
end

Stop External Signal Data

Stops the current external_signal data stream.

%% Get External Signal Data
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

% It is possible to check if the eyetracker supports this stream
if ismember(EyeTrackerCapabilities.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');
eyetracker.get_external_signal_data();
pause(1);
result = eyetracker.get_external_signal_data();

if isa(result,'StreamError')
    fprintf('Error: %s\n',string(result.Error.value));
    fprintf('Source: %s\n',string(result.Source.value));
    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',string(latest_external_signal_data.ChangeType.value));
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 during this stream the data returned will be of the class StreamError.

For every call of this method an array of the collected data will be returned. This means that on the first call, if no error has occurred, an empty array will be return. Note that the returned data will not be the data collected since the first call of this method, only the data collected in between calls will be returned.

Returns: array with instances of class EyeImage.

%% Get Eye Image
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device_with_eye_image';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

% It is possible to check if the eyetracker supports this stream
if ismember(EyeTrackerCapabilities.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.
eyetracker.get_eye_image();
pause(1);
result = eyetracker.get_eye_image();

if isa(result,'StreamError')
    fprintf('Error: %s\n',string(result.Error.value));
    fprintf('Source: %s\n',string(result.Source.value));
    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: %d\n',latest_eye_image.Type.value);

    imshow(latest_eye_image.Image);
end

Stop Eye Image

Stops the current eye image stream.

%% Get Eye Image
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device_with_eye_image';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

% It is possible to check if the eyetracker supports this stream
if ismember(EyeTrackerCapabilities.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.
eyetracker.get_eye_image();
pause(1);
result = eyetracker.get_eye_image();

if isa(result,'StreamError')
    fprintf('Error: %s\n',string(result.Error.value));
    fprintf('Source: %s\n',string(result.Source.value));
    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: %d\n',latest_eye_image.Type.value);

    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
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

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(number_of_licenses) = LicenseKey;

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
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

try
    eyetracker.clear_applied_licenses();
catch ME
    fprintf(ME.message);
end

Get Display Area

Gets the size and corners of the display area..

Returns: instance of class DisplayArea.

%% Get And Set Display Area
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

try
    display_area = eyetracker.get_display_area();
catch ME
    fprintf(ME.message);
    return
end

fprintf('BottomLeft: %.2f %.2f %.2f\n',display_area.BottomLeft);
fprintf('BottomRight: %.2f %.2f %.2f\n',display_area.BottomRight);
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);

eyetracker = Tobii.get_eyetracker(eyetracker_address);

display_area_struct.bottom_left = display_area.BottomLeft;
display_area_struct.top_left = display_area.TopLeft;
display_area_struct.top_right = display_area.TopRight;

display_area = DisplayArea(display_area_struct);

eyetracker.set_display_area(display_area);

Set Display Area

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: The eye tracker's desired display area as an instance of class DisplayArea.

%% Get And Set Display Area
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

try
    display_area = eyetracker.get_display_area();
catch ME
    fprintf(ME.message);
    return
end

fprintf('BottomLeft: %.2f %.2f %.2f\n',display_area.BottomLeft);
fprintf('BottomRight: %.2f %.2f %.2f\n',display_area.BottomRight);
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);

eyetracker = Tobii.get_eyetracker(eyetracker_address);

display_area_struct.bottom_left = display_area.BottomLeft;
display_area_struct.top_left = display_area.TopLeft;
display_area_struct.top_right = display_area.TopRight;

display_area = DisplayArea(display_area_struct);

eyetracker.set_display_area(display_area);

Get Track Box

Gets the track box of the eye tracker.

Returns: instance of class TrackBox.

%% Get Track Box
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

try
    track_box = eyetracker.get_track_box();
catch ME
    fprintf(ME.identifier);
    return
end

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
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

% 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
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

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

%% Get Lens Configuration
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

try
    lens_config = eyetracker.get_hmd_lens_configuration();
catch ME
    fprintf(ME.message);
    return
end
fprintf('Right: %.2f %.2f %.2f\n',lens_config.Right);
fprintf('Left: %.2f %.2f %.2f\n',lens_config.Left);

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.

%% Set Lens Configuration
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'Address of the desired device';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
end

left = [-32.0 0.0 0.0];
right = [32.0 0.0 0.0];

lens_config = HMDLensConfiguration(left,right);

try
    eyetracker.set_hmd_lens_configuration(lens_config);
catch ME
    fprintf(ME.message);
end

Get Eye Openness Data

Get Eye Openness Data for the Eye Tracker Returns: array with instances of class EyeOpennessData.

%%% Example Start %%%
%% Get Eye Openness Data
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = '!trackers_with_eyes';
% Example:
% eyetracker_address = 'tet-tcp://10.46.32.51';
try
    eyetracker = Tobii.get_eyetracker(eyetracker_address);
catch ME
    if (strcmp(ME.identifier,'EyeTrackerGet:error204'))
        fprintf('Unable to connect eye tracker.\n');
        return
    end
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.

eyetracker.get_eye_openness_data();
fake_pause(1);
result = eyetracker.get_eye_openness_data();

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

elseif isa(result,'EyeOpennessData')
    % Collect data for 1 seconds.
    fake_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_eye_openness_data('flat');
    eye_openness_data = eyetracker.get_eye_openness_data();

    eyetracker.stop_eye_openness_data();
    Left_EyeOpennessStream = 0;
    Right_EyeOpennessStream = 0;
    for i = 1: size (eye_openness_data)
        Right_EyeOpennessStream(i) = eye_openness_data(i).RightEyeOpennessValue;
        Left_EyeOpennessStream(i) = eye_openness_data(i).LeftEyeOpennessValue;
    end
    
    fprintf('Collected %d data points\n',size(eye_openness_data,1));

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

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


    fprintf('Left eye openness value:  %.2f\n',latest_eye_openness_data.LeftEyeOpennessValue);
    fprintf('Left eye openness validity: %d\n',latest_eye_openness_data.LeftEyeValidity);

    fprintf('Right eye openness value:  %.2f\n',latest_eye_openness_data.RightEyeOpennessValue);
    fprintf('Right eye openness validity: %d\n',latest_eye_openness_data.RightEyeValidity);
end

%%% Example End %%%

Stop Eye Openness Data

Stops the current eye_openness data stream.

Version

1.10.1.31

COPYRIGHT 2022 - PROPERTY OF TOBII PRO AB Copyright 2022 TOBII PRO AB - KARLSROVAGEN 2D, DANDERYD 182 53, SWEDEN - All Rights Reserved.

Copyright NOTICE: All information contained herein is, and remains, the property of Tobii Pro AB and its suppliers, if any. The intellectual and technical concepts contained herein are proprietary to Tobii Pro AB and its suppliers and may be covered by U.S.and Foreign Patents, patent applications, and are protected by trade secret or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from Tobii Pro AB.