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);
}