#include <stdio.h>
#include <stdbool.h>
#include <inttypes.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
bool user_looking_at_screen = false;
{
(void)(user_data);
if (user_looking_at_screen)
{
return;
}
bool left_eye_on_screen = false;
bool right_eye_on_screen = false;
{
left_eye_on_screen = true;
}
{
right_eye_on_screen = true;
}
if (left_eye_on_screen && right_eye_on_screen)
{
user_looking_at_screen = true;
}
printf("Left eye gaze point: (%f, %f)\nRight eye gaze point: (%f, %f)\n",
}
{
{
printf("Failed while subscribing to gaze %d", status);
}
char *serial_number = NULL;
printf("Entered calibration mode for eye tracker with serial number %s. \n", serial_number);
printf(
"Show a point on screen at (%f,%f).\n", point_to_calibrate.
x, point_to_calibrate.
y);
printf("Wait for user to look at the screen until we gather calibration data.\n");
while (!user_looking_at_screen)
{
sleep_ms(100);
}
printf(
"Collecting data at (%f,%f).\n", point_to_calibrate.
x, point_to_calibrate.
y);
{
}
printf("Computing and applying calibration.\n");
{
printf(
"Compute and apply returned %i and collected at %zu points.\n", status, calibration_result->
calibration_point_count);
}
else
{
printf("Calibration failed!\n");
}
{
printf("Failed leaving calibration mode %d.\n", status);
}
else
{
printf("Left calibration mode.\n");
}
{
printf("Failed unsubscribing to gaze %d.\n", status);
}
else
{
printf("Unsubscribed to gaze.\n");
}
}
Definition: tobii_research_calibration.h:139
size_t calibration_point_count
Definition: tobii_research_calibration.h:147
TobiiResearchCalibrationStatus status
Definition: tobii_research_calibration.h:151
TobiiResearchGazePoint gaze_point
Definition: tobii_research_streams.h:96
Definition: tobii_research_streams.h:112
TobiiResearchEyeData right_eye
Definition: tobii_research_streams.h:121
TobiiResearchEyeData left_eye
Definition: tobii_research_streams.h:116
TobiiResearchNormalizedPoint2D position_on_display_area
Definition: tobii_research_streams.h:76
Definition: tobii_research.h:384
float x
Definition: tobii_research.h:388
float y
Definition: tobii_research.h:392
TOBII_RESEARCH_API void TOBII_RESEARCH_CALL tobii_research_free_string(char *str)
Free memory allocation for a string allocated by the SDK.
struct TobiiResearchEyeTracker TobiiResearchEyeTracker
Definition: tobii_research.h:315
TobiiResearchStatus
Definition: tobii_research.h:45
@ TOBII_RESEARCH_STATUS_OK
Definition: tobii_research.h:49
Functionality for implementing calibration.
TOBII_RESEARCH_API TobiiResearchStatus TOBII_RESEARCH_CALL tobii_research_screen_based_calibration_collect_data(TobiiResearchEyeTracker *eyetracker, float x, float y)
Starts collecting data for a calibration point.
@ TOBII_RESEARCH_CALIBRATION_SUCCESS
Definition: tobii_research_calibration.h:34
TOBII_RESEARCH_API TobiiResearchStatus TOBII_RESEARCH_CALL tobii_research_screen_based_calibration_enter_calibration_mode(TobiiResearchEyeTracker *eyetracker)
Enters the screen based calibration mode and the eye tracker is made ready for collecting data and ca...
TOBII_RESEARCH_API TobiiResearchStatus TOBII_RESEARCH_CALL tobii_research_screen_based_calibration_compute_and_apply(TobiiResearchEyeTracker *eyetracker, TobiiResearchCalibrationResult **result)
Uses the collected data and tries to compute calibration parameters.
TOBII_RESEARCH_API TobiiResearchStatus TOBII_RESEARCH_CALL tobii_research_screen_based_calibration_leave_calibration_mode(TobiiResearchEyeTracker *eyetracker)
Leaves the screen based calibration mode.
TOBII_RESEARCH_API void TOBII_RESEARCH_CALL tobii_research_free_screen_based_calibration_result(TobiiResearchCalibrationResult *result)
Free memory allocation for the calibration result received via tobii_research_screen_based_calibratio...
Functionality for an eye tracker.
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.
Functionality for eye tracker streams.
TOBII_RESEARCH_API TobiiResearchStatus TOBII_RESEARCH_CALL tobii_research_unsubscribe_from_gaze_data(TobiiResearchEyeTracker *eyetracker, tobii_research_gaze_data_callback callback)
Unsubscribes from gaze data for the eye tracker.
TOBII_RESEARCH_API TobiiResearchStatus TOBII_RESEARCH_CALL tobii_research_subscribe_to_gaze_data(TobiiResearchEyeTracker *eyetracker, tobii_research_gaze_data_callback callback, void *user_data)
Subscribes to gaze data for the eye tracker.