Tobii Pro SDK C API
eye_images_as_gif.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 eye_image_as_gif_callback(TobiiResearchEyeImageGif* frame, void* user_data) {
const char* dir_path = (const char*)user_data;
char img_path[256];
FILE* fd;
sprintf(img_path, "%s/eye_image_%" PRId64 ".gif", dir_path, frame->device_time_stamp);
printf("Received image %s\n", img_path);
fd = fopen(img_path, "wb");
fwrite(frame->image_data, frame->image_size, 1, fd);
fclose(fd);
}
void eye_images_as_gif_example(TobiiResearchEyeTracker* eyetracker, const char* dir_path) {
/* Subscribe to eye images */
eyetracker,
eye_image_as_gif_callback, (void*)dir_path);
/* Wait for eye images. */
sleep_ms(2000);
/* Unsubscribe to eye images */
eyetracker,
eye_image_as_gif_callback);
}
TobiiResearchEyeImageGif::image_size
size_t image_size
Definition: tobii_research_streams.h:901
tobii_research_subscribe_to_eye_image_as_gif
TOBII_RESEARCH_API TobiiResearchStatus TOBII_RESEARCH_CALL tobii_research_subscribe_to_eye_image_as_gif(TobiiResearchEyeTracker *eyetracker, tobii_research_eye_image_as_gif_callback callback, void *user_data)
Subscribes to eye image for the eye tracker with the image delivered in gif format.
tobii_research_eyetracker.h
Functionality for an eye tracker.
TobiiResearchEyeImageGif
Definition: tobii_research_streams.h:881
tobii_research_streams.h
Functionality for eye tracker streams.
tobii_research_unsubscribe_from_eye_image_as_gif
TOBII_RESEARCH_API TobiiResearchStatus TOBII_RESEARCH_CALL tobii_research_unsubscribe_from_eye_image_as_gif(TobiiResearchEyeTracker *eyetracker, tobii_research_eye_image_as_gif_callback callback)
Unsubscribes from eye image for the eye tracker.
TobiiResearchEyeTracker
struct TobiiResearchEyeTracker TobiiResearchEyeTracker
Definition: tobii_research.h:310
TobiiResearchEyeImageGif::device_time_stamp
int64_t device_time_stamp
Definition: tobii_research_streams.h:885
TobiiResearchEyeImageGif::image_data
void * image_data
Definition: tobii_research_streams.h:905