Home Forums Software Development dev Need to release latest gaze data? Pro SDK

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  Grant [Tobii] 4 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #11429

    Evan Carter
    Participant

    Hi Tobii Developers!

    I’m only just getting started with the SDK and I’m really stuck on something that must be simple 🙁

    I’m able to connect to my X3-120 through a C script I wrote on my Ubuntu 18.04 machine, and I can collect gaze data… but the problem is that the gaze data never changes, it simply outputs the same coordinates (first coordinates) over and over again, same time stamp and everything. Do I need to release the latest gaze data to get new gaze data?

    I’m really hoping for some help here, I’ve read through the whole SDK documentation and I can’t find the solution.

    Here is my code:

    #include <stdio.h>
    #include <string.h>
    #include <inttypes.h>
    #include “tobii_research.h”
    #include “tobii_research_eyetracker.h”
    #include “tobii_research_streams.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

    TobiiResearchEyeTrackers* eyetrackers = NULL;
    TobiiResearchStatus result;
    TobiiResearchEyeTracker* my_eyetracker;

    TobiiResearchStatus find_all_eyetrackers_example() {

    size_t i = 0;
    result = tobii_research_find_all_eyetrackers(&eyetrackers);
    if (result != TOBII_RESEARCH_STATUS_OK) {
    printf(“Finding trackers failed. Error: %d\n”, result);
    return result;
    }

    my_eyetracker = eyetrackers->eyetrackers[0];

    for (i = 0; i < eyetrackers->count; i++) {
    TobiiResearchEyeTracker* eyetracker = eyetrackers->eyetrackers[i];
    char* address;
    char* serial_number;
    char* device_name;
    tobii_research_get_address(eyetracker, &address);
    tobii_research_get_serial_number(eyetracker, &serial_number);
    tobii_research_get_device_name(eyetracker, &device_name);
    printf(“%s\t%s\t%s\n”, address, serial_number, device_name);
    tobii_research_free_string(address);
    tobii_research_free_string(serial_number);
    tobii_research_free_string(device_name);
    }
    printf(“Found %d Eye Trackers \n\n”, (int)eyetrackers->count);
    tobii_research_free_eyetrackers(eyetrackers);
    return result;
    }

    void gaze_data_callback(TobiiResearchGazeData* gaze_data, void* user_data) {
    memcpy(user_data, gaze_data, sizeof(*gaze_data));
    }

    void main() {

    find_all_eyetrackers_example();

    TobiiResearchGazeData gaze_data;
    char* serial_number;

    while(1) {
    tobii_research_get_serial_number(my_eyetracker, &serial_number);
    printf(“Subscribing to gaze data for eye tracker with serial number %s.\n”, serial_number);
    tobii_research_free_string(serial_number);
    TobiiResearchStatus status = tobii_research_subscribe_to_gaze_data(my_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(my_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”,
    gaze_data.left_eye.gaze_point.position_on_display_area.x,
    gaze_data.left_eye.gaze_point.position_on_display_area.y);
    printf(“Right eye 3d gaze origin in user coordinates (%f, %f, %f)\n”,
    gaze_data.right_eye.gaze_origin.position_in_user_coordinates.x,
    gaze_data.right_eye.gaze_origin.position_in_user_coordinates.y,
    gaze_data.right_eye.gaze_origin.position_in_user_coordinates.z);
    /* Wait while some gaze data is collected. */
    sleep_ms(2000);
    }
    }

    Thank you for reading!
    Evan

    #11483

    Grant [Tobii]
    Moderator

    Hi @evancyvision The Tobii Pro Research SDK is part of the Tobii Pro business department.

    This forum is principally intended for support with the Tobii 4C & EyeX Tracker’s and their associated SDK’s.

    Please get in touch with Tobii Pro Support team directly @ http://www.tobiipro.com/contact/contact-support/ for an
    answer to your query.

    Apologies for the inconvenience and thanks for your understanding.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.