Tobii Pro SDK C API
hmd_calibration.c
#include <stdio.h>
#if _WIN32 || _WIN64
#include <windows.h>
static void sleep_ms(int time) {
Sleep(time);
}
#else
#include <unistd.h>
static void sleep_ms(int time) {
usleep(time * 1000);
}
#endif
void hmd_calibration_example(TobiiResearchEyeTracker* eyetracker) {
/* Enter calibration mode. */
char* serial_number = NULL;
tobii_research_get_serial_number(eyetracker, &serial_number);
printf("Entered calibration mode for eye tracker with serial number %s \n.", serial_number);
/* Define the points we should calibrate at. */
/* The coordinates are in HMD coordinates (x,y,z) */
{
#define NUM_OF_POINTS 3U
TobiiResearchPoint3D points_to_calibrate[NUM_OF_POINTS] = \
{{0.0f, 0.0f, 1000.0f}, {20.0f, 0.0f, 1000.0f}, {0.0f, 20.0f, 1000.0f}};
size_t i = 0;
for(; i < NUM_OF_POINTS; i++) {
TobiiResearchPoint3D* point = &points_to_calibrate[i];
printf("Show a point on screen at (%f,%f).\n", point->x, point->y);
// Wait a little for user to focus.
sleep_ms(700);
printf("Collecting data at (%f,%f,%f).\n", point->x, point->y, point->z);
if (tobii_research_hmd_based_calibration_collect_data(eyetracker, point->x, point->y, point->z) != TOBII_RESEARCH_STATUS_OK) {
/* Try again if it didn't go well the first time. */
/* Not all eye tracker models will fail at this point, but instead fail on ComputeAndApply. */
tobii_research_hmd_based_calibration_collect_data(eyetracker, point->x, point->y, point->z);
}
}
printf("Computing and applying calibration.\n");
status = tobii_research_hmd_based_calibration_compute_and_apply(eyetracker, &calibration_result);
if (status == TOBII_RESEARCH_STATUS_OK) {
if (calibration_result.status == TOBII_RESEARCH_CALIBRATION_SUCCESS)
printf("Calibration was successful!\n");
else if (calibration_result.status == TOBII_RESEARCH_CALIBRATION_FAILURE)
printf("Calibration failed!\n");
}
}
/* The calibration is done. Leave calibration mode. */
printf("Left calibration mode.\n");
}
TobiiResearchHMDCalibrationResult::status
TobiiResearchCalibrationStatus status
Definition: tobii_research_calibration.h:162
tobii_research_hmd_based_calibration_leave_calibration_mode
TOBII_RESEARCH_API TobiiResearchStatus TOBII_RESEARCH_CALL tobii_research_hmd_based_calibration_leave_calibration_mode(TobiiResearchEyeTracker *eyetracker)
Leaves the hmd based calibration mode.
TobiiResearchPoint3D::y
float y
Definition: tobii_research.h:402
TobiiResearchHMDCalibrationResult
Definition: tobii_research_calibration.h:158
tobii_research_get_serial_number
TOBII_RESEARCH_API TobiiResearchStatus TOBII_RESEARCH_CALL tobii_research_get_serial_number(TobiiResearchEyeTracker *eyetracker, char **serial_number)
Gets the serial number of the eye tracker. All physical eye trackers have a unique serial number.
TobiiResearchPoint3D
Definition: tobii_research.h:394
tobii_research_calibration.h
Functionality for implementing calibration.
tobii_research_eyetracker.h
Functionality for an eye tracker.
TobiiResearchPoint3D::x
float x
Definition: tobii_research.h:398
tobii_research_hmd_based_calibration_collect_data
TOBII_RESEARCH_API TobiiResearchStatus TOBII_RESEARCH_CALL tobii_research_hmd_based_calibration_collect_data(TobiiResearchEyeTracker *eyetracker, float x, float y, float z)
Starts collecting data for a calibration point.
tobii_research_free_string
TOBII_RESEARCH_API void TOBII_RESEARCH_CALL tobii_research_free_string(char *str)
Free memory allocation for a string allocated by the SDK.
tobii_research_hmd_based_calibration_enter_calibration_mode
TOBII_RESEARCH_API TobiiResearchStatus TOBII_RESEARCH_CALL tobii_research_hmd_based_calibration_enter_calibration_mode(TobiiResearchEyeTracker *eyetracker)
Enters the hmd based calibration mode and the eye tracker is made ready for collecting data and calcu...
TOBII_RESEARCH_CALIBRATION_SUCCESS
@ TOBII_RESEARCH_CALIBRATION_SUCCESS
Definition: tobii_research_calibration.h:34
TobiiResearchEyeTracker
struct TobiiResearchEyeTracker TobiiResearchEyeTracker
Definition: tobii_research.h:310
TOBII_RESEARCH_CALIBRATION_FAILURE
@ TOBII_RESEARCH_CALIBRATION_FAILURE
Definition: tobii_research_calibration.h:30
TobiiResearchPoint3D::z
float z
Definition: tobii_research.h:406
TOBII_RESEARCH_STATUS_OK
@ TOBII_RESEARCH_STATUS_OK
Definition: tobii_research.h:49
tobii_research_hmd_based_calibration_compute_and_apply
TOBII_RESEARCH_API TobiiResearchStatus TOBII_RESEARCH_CALL tobii_research_hmd_based_calibration_compute_and_apply(TobiiResearchEyeTracker *eyetracker, TobiiResearchHMDCalibrationResult *result)
Uses the collected data and tries to compute calibration parameters.
TobiiResearchStatus
TobiiResearchStatus
Definition: tobii_research.h:45