Tobii Pro SDK C API
gaze_data.c
#include <stdio.h>
#include <string.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
void gaze_data_callback(TobiiResearchGazeData* gaze_data, void* user_data) {
memcpy(user_data, gaze_data, sizeof(*gaze_data));
}
void gaze_data_example(TobiiResearchEyeTracker* eyetracker) {
char* serial_number = NULL;
tobii_research_get_serial_number(eyetracker, &serial_number);
printf("Subscribing to gaze data for eye tracker with serial number %s.\n", serial_number);
TobiiResearchStatus status = tobii_research_subscribe_to_gaze_data(eyetracker, gaze_data_callback, &gaze_data);
if (status != TOBII_RESEARCH_STATUS_OK)
return;
/* Wait while some gaze data is collected. */
sleep_ms(2000);
status = tobii_research_unsubscribe_from_gaze_data(eyetracker, gaze_data_callback);
printf("Unsubscribed from gaze data with status %i.\n", status);
printf("Last received gaze package:\n");
printf("System time stamp: %" PRId64 "\n", gaze_data.system_time_stamp);
printf("Device time stamp: %" PRId64 "\n", gaze_data.device_time_stamp);
printf("Left eye 2D gaze point on display area: (%f, %f)\n",
printf("Right eye 3d gaze origin in user coordinates (%f, %f, %f)\n",
/* Wait while some gaze data is collected. */
sleep_ms(2000);
}
TobiiResearchNormalizedPoint2D::y
float y
Definition: tobii_research.h:387
TobiiResearchGazeData::device_time_stamp
int64_t device_time_stamp
Definition: tobii_research_streams.h:131
TobiiResearchPoint3D::y
float y
Definition: tobii_research.h:402
TobiiResearchEyeData::gaze_point
TobiiResearchGazePoint gaze_point
Definition: tobii_research_streams.h:101
tobii_research_unsubscribe_from_gaze_data
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.
TobiiResearchGazeData::system_time_stamp
int64_t system_time_stamp
Definition: tobii_research_streams.h:136
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.
tobii_research_eyetracker.h
Functionality for an eye tracker.
TobiiResearchPoint3D::x
float x
Definition: tobii_research.h:398
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.
TobiiResearchGazeOrigin::position_in_user_coordinates
TobiiResearchPoint3D position_in_user_coordinates
Definition: tobii_research_streams.h:46
tobii_research_streams.h
Functionality for eye tracker streams.
TobiiResearchGazeData::right_eye
TobiiResearchEyeData right_eye
Definition: tobii_research_streams.h:126
TobiiResearchGazeData
Definition: tobii_research_streams.h:117
TobiiResearchEyeTracker
struct TobiiResearchEyeTracker TobiiResearchEyeTracker
Definition: tobii_research.h:310
TobiiResearchNormalizedPoint2D::x
float x
Definition: tobii_research.h:383
TobiiResearchEyeData::gaze_origin
TobiiResearchGazeOrigin gaze_origin
Definition: tobii_research_streams.h:111
TobiiResearchGazePoint::position_on_display_area
TobiiResearchNormalizedPoint2D position_on_display_area
Definition: tobii_research_streams.h:81
TobiiResearchGazeData::left_eye
TobiiResearchEyeData left_eye
Definition: tobii_research_streams.h:121
TobiiResearchPoint3D::z
float z
Definition: tobii_research.h:406
TOBII_RESEARCH_STATUS_OK
@ TOBII_RESEARCH_STATUS_OK
Definition: tobii_research.h:49
tobii_research_subscribe_to_gaze_data
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.
TobiiResearchStatus
TobiiResearchStatus
Definition: tobii_research.h:45