ScreenBasedCalibration

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

calib = ScreenBasedCalibration(tracker)

Contents

Enter Calibration Mode

Enters the Calibration Mode and the Eye Tracker is made ready for collecting data and calculating new calibrations.

calib.enter_calibration_mode()

Leave Calibration Mode

Leaves the Calibration Mode.

calib.leave_calibration_mode()

Collect Data

Adds data to the temporary calibration buffer for one calibration point. The argument used is the point the calibration user is assumed to be looking at and is given in the Active Display Area Coordinate System.

Parameters: coordinates (x,y) of the calibration point.

calib.collect_data(coordinates)

Discard Data

Removes the data associated with a specific calibration point from the temporary calibration buffer.

Parameters: coordinates (x,y) of the calibration point.

calib.discard_data(coordinates)

Compute and Apply Calibration

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

Returns: an instance of the class CalibrationResult

calib.compute_and_apply()

Code Example

%% Calibration Sample
clear;

Tobii = EyeTrackingOperations();

eyetracker_address = 'tet-tcp://10.46.32.50';%'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

calib = ScreenBasedCalibration(eyetracker);

try 
    calib.enter_calibration_mode()
catch ME
    if (strcmp(ME.identifier,'EnterCalibrationMode:error210'))
        fprintf('The previous calibration was not completed!\n');
        calib.leave_calibration_mode()
        fprintf('Calibration is restarted\n');
        calib.enter_calibration_mode()
    else
        fprintf('%s\n', ME.identifier);
        return
    end
end
points_to_collect = [[0.1,0.1];[0.1,0.9];[0.5,0.5];[0.9,0.1];[0.9,0.9]];

% When collecting data a point should be presented on the screen in the
% appropriate position.
for i=1:size(points_to_collect,1)
    collect_result = calib.collect_data(points_to_collect(i,:));
    fprintf('Point [%.2f,%.2f] Collect Result: %d\n',points_to_collect(i,:),collect_result.value);
end

calibration_result = calib.compute_and_apply();
fprintf('Calibration Status: %d\n',calibration_result.Status.value.value);

% After analisyng the calibration result one might want to re-calibrate
% some of the points
points_to_collect = [[0.1,0.1];[0.1,0.9];[0.5,0.5];[0.9,0.1];[0.9,0.9]];

% When collecting data a point should be presented on the screen in the
% appropriate position.

points_to_recalibrate = [[0.1,0.1];[0.1,0.9]];

for i=1:size(points_to_recalibrate,1)
    calib.discard_data(points_to_recalibrate(i,:));
    collect_result = calib.collect_data(points_to_recalibrate(i,:));
    fprintf('Point [%.2f,%.2f] Collect Result: %d\n',points_to_recalibrate(i,:),collect_result.value);
end

calibration_result = calib.compute_and_apply();
fprintf('Calibration Status: %d\n',calibration_result.Status.value.value);

if calibration_result.Status == CalibrationStatus.Success
    points = calibration_result.CalibrationPoints;

    number_points = size(points,2);

    for i=1:number_points
        plot(points(i).PositionOnDisplayArea(1),points(i).PositionOnDisplayArea(2),'ok','LineWidth',10);
        mapping_size = size(points(i).RightEye,2);
        set(gca, 'YDir', 'reverse');
        axis([-0.2 1.2 -0.2 1.2])
        hold on;
        for j=1:mapping_size
            if points(i).LeftEye(j).Validity == CalibrationEyeValidity.ValidAndUsed
                plot(points(i).LeftEye(j).PositionOnDisplayArea(1), points(i).LeftEye(j).PositionOnDisplayArea(2),'-xr','LineWidth',3);
            end
            if points(i).RightEye(j).Validity == CalibrationEyeValidity.ValidAndUsed
                plot(points(i).RightEye(j).PositionOnDisplayArea(1),points(i).RightEye(j).PositionOnDisplayArea(2),'xb','LineWidth',3);
            end
        end

    end
end

calib.leave_calibration_mode()

See Also

Eyetracker, CalibrationEyeData, CalibrationEyeValidity, CalibrationPoint, CalibrationResult, CalibrationStatus

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.