To get started with eye tracking in your application, Download the Stream Engine API.

Extract the archive containing the library and all necessary header files, then follow the steps below to integrate StreamEngine into your application.

1.Create a new project

2.Select the project type(Console App .NET Framework)

3.Configure the new project

4.Right click the project->Add->New Folder

To create a new folder and named “tobii”

5.Copy this three folders of stream engine to “tobii”

6.If the folder turns gray, just right click and select “Include In Project”

7.Copy the sample script below into Program.cs

using System;
using System.Collections.Generic;
using System.Diagnostics;
using Tobii.StreamEngine;

namespace Tobii.StreamEngine.Sample
{
    public static class StreamSample
    {
        private static void OnGazePoint(ref tobii_gaze_point_t gazePoint, IntPtr userData) 
        {
            // Check that the data is valid before using it
            if(gazePoint.validity == tobii_validity_t.TOBII_VALIDITY_VALID) 
            {
                Console.WriteLine($"Gaze point: {gazePoint.position.x}, {gazePoint.position.y}");
            }
        }

        public static void Main()
        {
            // Create API context
            IntPtr apiContext;
            tobii_error_t result = Interop.tobii_api_create(out apiContext, null);
            Debug.Assert(result == tobii_error_t.TOBII_ERROR_NO_ERROR);

            // Enumerate devices to find connected eye trackers
            List<string> urls;
            result = Interop.tobii_enumerate_local_device_urls(apiContext, out urls);
            Debug.Assert(result == tobii_error_t.TOBII_ERROR_NO_ERROR);
            if(urls.Count == 0)
            {
                Console.WriteLine("Error: No device found");
                return;
            }

            // Connect to the first tracker found
            IntPtr deviceContext;
            result = Interop.tobii_device_create(apiContext, urls[0], Interop.tobii_field_of_use_t.TOBII_FIELD_OF_USE_STORE_OR_TRANSFER_FALSE, out deviceContext);
            Debug.Assert(result == tobii_error_t.TOBII_ERROR_NO_ERROR);

            // Subscribe to gaze data
            result = Interop.tobii_gaze_point_subscribe(deviceContext, OnGazePoint);
            Debug.Assert(result == tobii_error_t.TOBII_ERROR_NO_ERROR);

            // This sample will collect 1000 gaze points
            for ( int i=0; i<1000; i++ )
            {
                // Optionally block this thread until data is available. Especially useful if running in a separate thread.
                Interop.tobii_wait_for_callbacks(new [] { deviceContext });
                Debug.Assert(result == tobii_error_t.TOBII_ERROR_NO_ERROR || result == tobii_error_t.TOBII_ERROR_TIMED_OUT);
                
                // Process callbacks on this thread if data is available
                Interop.tobii_device_process_callbacks(deviceContext);
                Debug.Assert(result == tobii_error_t.TOBII_ERROR_NO_ERROR);
            }

            // Cleanup
            result = Interop.tobii_gaze_point_unsubscribe(deviceContext);
            Debug.Assert(result == tobii_error_t.TOBII_ERROR_NO_ERROR);
            result = Interop.tobii_device_destroy(deviceContext);
            Debug.Assert(result == tobii_error_t.TOBII_ERROR_NO_ERROR);
            result = Interop.tobii_api_destroy(apiContext);
            Debug.Assert(result == tobii_error_t.TOBII_ERROR_NO_ERROR);
        }
    }
}

8.Modify Tobii.StreamEngine.Interop.cs, Line 22:  public const string stream_engine_dll = tobii\\lib\\tobii\\tobii_stream_engine;

 

 

9.In VS Solution Explorer, find the tobii_stream_engine.dll and set copy to output directory as “Copy Always”

10.Set Build Target to x64

11.Start and receive the gaze data!

Eye Tracking Data Transparency Policy

This policy applies to solutions that store or transfer Tobii eye tracking data, presence or position data, regardless of the purpose for the storing or transferring. End-users care about their data integrity and privacy. Therefore, as a vendor you must gain end-users’ trust regarding what you do with the end users’s eye tracking data. Being transparent is a good starting point in gaining trust and that is why we created the Tobii Eye Tracking Data Transparency policy.

Linux and MacOS

  • Our gaming eye tracker, Tobii Eye Tracker 5, only supports Windows. Software development kits for the 5 are only available for Windows.
  • If you want to develop a product integrating Tobii Eye Tracking we have other solutions such as the Tobii Eye Tracker 5L, and integration platforms that also support Linux and MacOS. If you are interested in integrating eye tracking in your product please Contact Tobii.