master
holiveros_todova 7 years ago
commit 7973542811

@ -0,0 +1,40 @@
It allows to install the drivers and development libraries to operate devices compatible with IS4 (Tobii 4C).
The deps packages were obtained from the tobii page:
https://developer.tobii.com/consumer-eye-trackers/stream-engine/getting-started
The manager is obtained from:
https://www.tobiipro.com/es/learn--support/downloads/
#### Instalation
bash ./install.sh
#### Configuration
Run the Tobii Pro Eye Tracker Manager:
/opt/TobiiProEyeTrackerManager/TobiiProEyeTrackerManager
Calibrate the device
![Configuration](media/config.gif)
#### Run the example code
cd example
gcc main.cpp -o main -pthread /usr/lib/tobii/libtobii_stream_engine.so
./main
![Example test](media/example_test.gif)
You will see how the tracker captures the position of the screen you are looking at
Test env:
SO: Ubuntu 18.10 x86_64 Cinnamon 4.18.0-17-generic
Tracker: Tobii

Binary file not shown.

Binary file not shown.

@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.13)
project(example)
set(CMAKE_CXX_STANDARD 14)
add_executable(example main.cpp)
target_link_libraries(example /usr/lib/tobii/libtobii_stream_engine.so)
target_link_libraries(example pthread)

@ -0,0 +1,57 @@
#include <tobii/tobii.h>
#include <tobii/tobii_streams.h>
#include <stdio.h>
#include <assert.h>
#include <cstring>
void gaze_point_callback(tobii_gaze_point_t const *gaze_point, void *user_data) {
if (gaze_point->validity == TOBII_VALIDITY_VALID)
printf("Gaze point: %f, %f\n",
gaze_point->position_xy[0],
gaze_point->position_xy[1]);
}
static void url_receiver(char const *url, void *user_data) {
char *buffer = (char *) user_data;
if (*buffer != '\0') return; // only keep first value
if (strlen(url) < 256)
strcpy(buffer, url);
}
int main() {
tobii_api_t *api;
tobii_error_t error = tobii_api_create(&api, NULL, NULL);
assert(error == TOBII_ERROR_NO_ERROR);
char url[256] = {0};
error = tobii_enumerate_local_device_urls(api, url_receiver, url);
assert(error == TOBII_ERROR_NO_ERROR && *url != '\0');
tobii_device_t *device;
error = tobii_device_create(api, url, &device);
assert(error == TOBII_ERROR_NO_ERROR);
error = tobii_gaze_point_subscribe(device, gaze_point_callback, 0);
assert(error == TOBII_ERROR_NO_ERROR);
int is_running = 1000; // in this sample, exit after some iterations
while (--is_running > 0) {
error = tobii_wait_for_callbacks(1, &device);
assert(error == TOBII_ERROR_NO_ERROR || error == TOBII_ERROR_TIMED_OUT);
error = tobii_device_process_callbacks(device);
assert(error == TOBII_ERROR_NO_ERROR);
}
error = tobii_gaze_point_unsubscribe(device);
assert(error == TOBII_ERROR_NO_ERROR);
error = tobii_device_destroy(device);
assert(error == TOBII_ERROR_NO_ERROR);
error = tobii_api_destroy(api);
assert(error == TOBII_ERROR_NO_ERROR);
return 0;
}

@ -0,0 +1,35 @@
#!/usr/bin/env bash
LIB_DIR=./lib
sudo apt --fix-broken install libsqlcipher0 ./deps/libuv0.10_0.10.22-2_amd64.deb libpthread-stubs0-dev build-essential
# Targeted Linux distribution is Ubuntu Linux 16.04 LTS
# Tested on Ubuntu 18.10 x86_64 with Cinnamon. Kernel 4.18.0-16-generic
# Install Tobii USB Host (mandatory) that handles connections to the tracker:
sudo dpkg -i tobiiusbservice_l64U14_2.1.5-28fd4a.deb
# Install Tobii Engine daemon (recommended) that offers extended functionality
sudo dpkg -i tobii_engine_linux-0.1.6.193_rc-Linux.deb
#Install Tobii Config (recommended) to do screen setup and calibration:
sudo dpkg -i tobii_config_0.1.6.111_amd64.deb
#Install Stream Engine Client library to develop for your eye tracker:
if [[ ! -e "${LIB_DIR}" ]]; then
mkdir ${LIB_DIR}
tar -xzvf stream_engine_linux_3.0.4.6031.tar.gz -C ${LIB_DIR}
else
echo "${LIB_DIR} already exist. Continue..."
fi
sudo mkdir /usr/lib/tobii
sudo mkdir /usr/lib32/tobii
sudo cp -pR ${LIB_DIR}/lib/x64/*.so /usr/lib/tobii/
sudo cp -pR ${LIB_DIR}/lib/x86/*.so /usr/lib32/tobii/
sudo cp -R ${LIB_DIR}/include /usr/include
echo "DONE :)"
sudo apt install ./Tobii.Pro.Eye.Tracker.Manager.Linux-1.12.1.deb

Binary file not shown.

Binary file not shown.

@ -0,0 +1,205 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable FieldCanBeMadeReadOnly.Global
namespace Tobii.StreamEngine.Simcontrol
{
public enum simcontrol_error_t
{
NoError,
Internal,
NotAvailable,
InvalidParameter,
AllocationFailed,
ConnectionFailed,
NotSupported,
BufferTooSmall,
OperationFailed,
FirmwareNoResponse,
BadState,
TooManySubscribers,
UnexpectedTransactionId,
UnexpectedMessageType,
Protocol,
Unknown,
AlreadySubscribed,
NotSubscribed,
InsufficientLicense,
TimedOut,
}
[StructLayout(LayoutKind.Sequential)]
public struct point2d
{
public float x;
public float y;
}
[StructLayout(LayoutKind.Sequential)]
public struct point3d
{
public float x;
public float y;
public float z;
}
[StructLayout(LayoutKind.Sequential)]
public struct simcontrol_point2d_t
{
public point2d left_eye_xy;
public point2d right_eye_xy;
}
[StructLayout(LayoutKind.Sequential)]
public struct simcontrol_point3d_t
{
public point3d left_eye_xyz;
public point3d right_eye_xyz;
}
public enum simcontrol_presence_t
{
Unknow,
NotPresent,
Present,
}
public enum simcontrol_validity_t
{
Invalid,
Valid,
}
[StructLayout(LayoutKind.Sequential)]
public struct simcontrol_eye_validity_t
{
public simcontrol_validity_t left;
public simcontrol_validity_t right;
}
public enum simcontrol_notification_type_t
{
SIMCONTROL_NOTIFICATION_TYPE_CALIBRATION_STATE_CHANGED,
SIMCONTROL_NOTIFICATION_TYPE_EXCLUSIVE_MODE_STATE_CHANGED,
SIMCONTROL_NOTIFICATION_TYPE_TRACK_BOX_CHANGED,
SIMCONTROL_NOTIFICATION_TYPE_DISPLAY_AREA_CHANGED,
SIMCONTROL_NOTIFICATION_TYPE_FRAMERATE_CHANGED,
SIMCONTROL_NOTIFICATION_TYPE_POWER_SAVE_STATE_CHANGED,
SIMCONTROL_NOTIFICATION_TYPE_DEVICE_PAUSED_STATE_CHANGED,
SIMCONTROL_NOTIFICATION_TYPE_CALIBRATION_ENABLED_EYE_CHANGED,
SIMCONTROL_NOTIFICATION_TYPE_CALIBRATION_ID_CHANGED,
SIMCONTROL_NOTIFICATION_TYPE_COMBINED_GAZE_EYE_SELECTION_CHANGED,
SIMCONTROL_NOTIFICATION_TYPE_FAULTS_CHANGED,
SIMCONTROL_NOTIFICATION_TYPE_WARNINGS_CHANGED,
}
[StructLayout(LayoutKind.Sequential)]
public struct simcontrol_display_area_t
{
public point3d top_left_mm_xyz;
public point3d top_right_mm_xyz;
public point3d bottom_left_mm_xyz;
}
public enum simcontrol_enabled_eye_t
{
SIMCONTROL_ENABLED_EYE_LEFT,
SIMCONTROL_ENABLED_EYE_RIGHT,
SIMCONTROL_ENABLED_EYE_BOTH,
}
[StructLayout(LayoutKind.Sequential)]
public struct simcontrol_notification_data_t
{
public float float_;
public string string_;
public bool state;
public uint uint_;
public simcontrol_display_area_t display_area;
public simcontrol_enabled_eye_t enabled_eye;
}
[StructLayout(LayoutKind.Sequential)]
public struct simcontrol_notification_t
{
public simcontrol_notification_type_t notification_type;
public simcontrol_notification_data_t data;
}
public static class Interop
{
private const string SimcontrolDll = "simcontrol";
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_context_create_with_license(out IntPtr context, string url, string license_file_path);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_context_destroy(IntPtr context);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_set_gaze_point(IntPtr context, ref simcontrol_point2d_t gaze_point);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_set_gaze_origin(IntPtr context, ref simcontrol_point3d_t gaze_origin);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_set_gaze_origin_mm(IntPtr context, ref simcontrol_point3d_t gaze_origin_mm);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_set_center_of_eye_mm(IntPtr context, ref simcontrol_point3d_t center_of_eye);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_set_gaze_point_cloud_radius(IntPtr context, float radius);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_set_eye_tracked(IntPtr context, simcontrol_eye_validity_t eye_tracked);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_set_eye_detected(IntPtr context, simcontrol_eye_validity_t eye_detected);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_set_presence_state(IntPtr context, simcontrol_presence_t presence_state);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_tracking_activate(IntPtr context);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_tracking_deactivate(IntPtr context);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_presence_activate(IntPtr context);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_presence_deactivate(IntPtr context);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_gaze_point_cloud_activate(IntPtr context);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_gaze_point_cloud_deactivate(IntPtr context);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_set_gaze_direction(IntPtr context, ref simcontrol_point3d_t gaze_direction);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_set_eyeopenness_validity(IntPtr context, simcontrol_eye_validity_t eyeopenness_validity);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_set_eyeopenness(IntPtr context, float eyeopenness);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_set_pupildiameter_validity(IntPtr context, simcontrol_eye_validity_t pupildiameter_validity);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_set_pupildiameter(IntPtr context, float pupildiameter);
[DllImport(SimcontrolDll, CallingConvention = CallingConvention.Cdecl)]
public static extern simcontrol_error_t simcontrol_trigger_notification(IntPtr context, ref simcontrol_notification_t notification);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,774 @@
/*
COPYRIGHT 2015 - PROPERTY OF TOBII AB
-------------------------------------
2015 TOBII AB - KARLSROVAGEN 2D, DANDERYD 182 53, SWEDEN - All Rights Reserved.
NOTICE: All information contained herein is, and remains, the property of Tobii AB and its suppliers, if any.
The intellectual and technical concepts contained herein are proprietary to Tobii AB and its suppliers and may be
covered by U.S.and Foreign Patents, patent applications, and are protected by trade secret or copyright law.
Dissemination of this information or reproduction of this material is strictly forbidden unless prior written
permission is obtained from Tobii AB.
*/
#ifndef tobii_advanced_h_included
#define tobii_advanced_h_included
#include "tobii.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct tobii_gaze_data_eye_t
{
tobii_validity_t gaze_origin_validity;
float gaze_origin_from_eye_tracker_mm_xyz[ 3 ];
float eye_position_in_track_box_normalized_xyz[ 3 ];
tobii_validity_t gaze_point_validity;
float gaze_point_from_eye_tracker_mm_xyz[ 3 ];
float gaze_point_on_display_normalized_xy[ 2 ];
tobii_validity_t eyeball_center_validity;
float eyeball_center_from_eye_tracker_mm_xyz[ 3 ];
tobii_validity_t pupil_validity;
float pupil_diameter_mm;
} tobii_gaze_data_eye_t;
typedef struct tobii_gaze_data_t
{
int64_t timestamp_tracker_us;
int64_t timestamp_system_us;
tobii_gaze_data_eye_t left;
tobii_gaze_data_eye_t right;
} tobii_gaze_data_t;
typedef void (*tobii_gaze_data_callback_t)( tobii_gaze_data_t const* gaze_data, void* user_data );
TOBII_API tobii_error_t TOBII_CALL tobii_gaze_data_subscribe( tobii_device_t* device,
tobii_gaze_data_callback_t callback, void* user_data );
TOBII_API tobii_error_t TOBII_CALL tobii_gaze_data_unsubscribe( tobii_device_t* device );
typedef void (*tobii_digital_syncport_callback_t)( uint32_t signal, int64_t timestamp_tracker_us,
int64_t timestamp_system_us, void* user_data );
TOBII_API tobii_error_t TOBII_CALL tobii_digital_syncport_subscribe( tobii_device_t* device,
tobii_digital_syncport_callback_t callback, void* user_data );
TOBII_API tobii_error_t TOBII_CALL tobii_digital_syncport_unsubscribe( tobii_device_t* device );
typedef struct tobii_timesync_data_t
{
int64_t system_start_us;
int64_t system_end_us;
int64_t tracker_us;
} tobii_timesync_data_t;
TOBII_API tobii_error_t TOBII_CALL tobii_timesync( tobii_device_t* device,
tobii_timesync_data_t* timesync );
typedef char tobii_illumination_mode_t[ 64 ];
typedef void (*tobii_illumination_mode_receiver_t)( const tobii_illumination_mode_t illumination_mode,
void* user_data );
TOBII_API tobii_error_t TOBII_CALL tobii_enumerate_illumination_modes( tobii_device_t* device,
tobii_illumination_mode_receiver_t receiver, void* user_data );
TOBII_API tobii_error_t TOBII_CALL tobii_set_illumination_mode( tobii_device_t* device,
tobii_illumination_mode_t const illumination_mode );
TOBII_API tobii_error_t TOBII_CALL tobii_get_illumination_mode( tobii_device_t* device,
tobii_illumination_mode_t* illumination_mode );
typedef char tobii_face_type_t[ 64 ];
typedef void (*tobii_face_type_receiver_t)( const tobii_face_type_t face_type,
void* user_data );
TOBII_API tobii_error_t TOBII_CALL tobii_enumerate_face_types( tobii_device_t* device,
tobii_face_type_receiver_t receiver, void* user_data );
TOBII_API tobii_error_t TOBII_CALL tobii_set_face_type( tobii_device_t* device,
tobii_face_type_t const face_type );
TOBII_API tobii_error_t TOBII_CALL tobii_get_face_type( tobii_device_t* device,
tobii_face_type_t* face_type );
#ifdef __cplusplus
}
#endif
#endif /* tobii_advanced_h_included */
/**
@defgroup tobii_advanced tobii_advanced.h
tobii_advanced.h
=======
This is the tobii_advanced.h file.
*/
/**
@fn TOBII_API tobii_error_t TOBII_CALL tobii_gaze_data_subscribe( tobii_device_t* device, tobii_gaze_data_callback_t callback, void* user_data );
@ingroup tobii_advanced
tobii_gaze_data_subscribe
-------------------------
### Function
Starts the gaze data stream.
### Syntax
#include <tobii/tobii_advanced.h>
tobii_error_t tobii_gaze_data_subscribe( tobii_device_t* device,
tobii_gaze_data_callback_t callback, void* user_data );
### Remarks
To be able to call this function, the *device* should have been created with a minimum license level of Professional
feature group.
*device* must be a pointer to a valid tobii_device_t as created by calling tobii_device_create.
*callback* is a function pointer to a function with the prototype:
void gaze_data_callback( tobii_gaze_data_t const* gaze_data, void* user_data )
Older devices using the deprecated 0-4 scale to determine validity will have the value map to the new binary scale accordingly:
0 - TOBII_VALIDITY_VALID
1 - TOBII_VALIDITY_VALID
2 - TOBII_VALIDITY_INVALID
3 - TOBII_VALIDITY_INVALID
4 - TOBII_VALIDITY_INVALID
This function will be called when there is new gaze data available. It is called with the following parameters:
- *gaze_data*
This is a pointer to a struct containing the data listed below. Note that it is only valid during the callback. Its data
should be copied if access is necessary at a later stage, from outside the callback.
- *timestamp_tracker_us*
Timestamp value for when the gaze data was captured in microseconds (us). It is generated on the device responsible for capturing the data.
*timestamp_system_us* is generated using this value. The epoch is undefined, so these timestamps are only useful for calculating
the time elapsed between a pair of values.
- *timestamp_system_us*
Timestamp value for when the gaze data was captured, measured in microseconds (us). The epoch is undefined,
so these timestamps are only useful for calculating the time elapsed between a pair of values. The function tobii_system_clock
can be used to retrieve a timestamp using the same clock and same relative values as this timestamp.
- *left*
This is a struct containing the following data, related to the left eye:
- *gaze_origin_validity*
**TOBII_VALIDITY_INVALID** if *gaze_origin_mm_xyz* and *gaze_origin_in_track_box_normalized* are not valid for
this frame, **TOBII_VALIDITY_VALID** if they are.
- *gaze_origin_from_eye_tracker_mm*
An array of three floats, for the x, y and z coordinate of the gaze origin point of the eye of the user, as
measured in millimeters from the center of the device.
- *gaze_origin_in_track_box_normalized*
An array of three floats, for the x, y and z coordinate of the gaze origin point of the eye of the user, as
measured in the normalized distance of the device track box.
- *gaze_point_validity*
**TOBII_VALIDITY_INVALID** if *gaze_point_from_eye_tracker_mm* and *gaze_point_on_display_normalized*
are not valid for this frame, **TOBII_VALIDITY_VALID** if they are.
- *gaze_point_from_eye_tracker_mm*
An array of three floats, for the x, y and z coordinate of the gaze point that the user is currently looking,
as measured in millimeters from the center of the device.
- *gaze_point_on_display_normalized*
The horizontal and vertical screen coordinate of the gaze point. The left edge of the screen is 0.0, and the
right edge is 1.0. The top edge of the screen is 0.0, and the bottom edge is 1.0.
Note that the value might be outside the 0.0 to 1.0 range, if the user looks outside the screen.
- *eyeball_center_validity*
**TOBII_VALIDITY_INVALID** if *eyeball_center_from_eye_tracker_mm* is not valid for this frame,
**TOBII_VALIDITY_VALID** if it is.
- *eyeball_center_from_eye_tracker_mm*
An array of three floats, for the x, y and z coordinate of the center of the eyeball, as
measured in millimeters from the center of the device.
- *pupil_validity*
**TOBII_VALIDITY_INVALID** if *pupil_diameter_mm* is not valid for this frame, **TOBII_VALIDITY_VALID** if it is.
- *pupil_diameter_mm*
A float that represents the approximate diameter of the pupil, expressed in millimeters. Only relative changes
are guaranteed to be accurate.
- *right*
This is another instance of the same struct as in *left*, but which holds data related to the right eye of the user.
- *user_data*
This is the custom pointer sent in when registering the callback.
*user_data* custom pointer which will be passed unmodified to the callback.
### Return value
If the call was successful **TOBII_ERROR_NO_ERROR** will be returned. If the call fails, tobii_gaze_data_subscribe
returns an error code specific to the device.
### See Also
tobii_gaze_data_unsubscribe()
*/
/**
@fn TOBII_API tobii_error_t TOBII_CALL tobii_gaze_data_unsubscribe( tobii_device_t* device );
@ingroup tobii_advanced
tobii_gaze_data_unsubscribe
---------------------------
### Function
Stops the gaze data stream.
### Syntax
#include <tobii/tobii_advanced.h>
tobii_gaze_data_unsubscribe( tobii_device_t* device );
### Remarks
To be able to call this function, the *device* should have been created with a minimum license level of Professional
feature group. *device* must be a pointer to a valid tobii_device_t as created by calling tobii_device_create.
### Return value
If the call was successful **TOBII_ERROR_NO_ERROR** will be returned. If the call fails, tobii_gaze_data_unsubscribe
returns an error code specific to the device.
### See Also
tobii_gaze_data_subscribe()
### Example
@code{.c}
#include "tobii/tobii.h"
#include "tobii/tobii_licensing.h"
#include "tobii/tobii_advanced.h"
#include <stdio.h>
#include <assert.h>
static void tobii_gaze_data_callback( tobii_gaze_data_t const* gaze_data, void* user_data )
{
(void)user_data;
if( gaze_data->right.gaze_point_validity == TOBII_VALIDITY_VALID )
printf( "Gaze point (right): %f, %f\n",
gaze_data->right.gaze_point_on_display_normalized_xy[ 0 ],
gaze_data->right.gaze_point_on_display_normalized_xy[ 1 ] );
else
printf( "Gaze point (right): INVALID\n");
if( gaze_data->left.gaze_point_validity == TOBII_VALIDITY_VALID )
printf( "Gaze point (left): %f, %f\n",
gaze_data->left.gaze_point_on_display_normalized_xy[ 0 ],
gaze_data->left.gaze_point_on_display_normalized_xy[ 1 ] );
else
printf( "Gaze point (left): INVALID\n");
}
int main()
{
tobii_api_t* api;
tobii_error_t error = tobii_api_create( &api, NULL, NULL );
assert( error == TOBII_ERROR_NO_ERROR );
tobii_device_t* device;
char url[ 256 ] = { 0 };
printf( "Enter url to the eye tracker (don't forget prefix tobii-ttp:// or tet-tcp://):\n" );
scanf( "%255s", url );
error = tobii_device_create( api, url, &device ); // if not using a pro tracker use tobii_device_create_ex with Professional license
assert( error == TOBII_ERROR_NO_ERROR );
error = tobii_gaze_data_subscribe( device, tobii_gaze_data_callback, 0 );
assert( error == TOBII_ERROR_NO_ERROR );
int is_running = 10; // in this sample, exit after some iterations
while( --is_running > 0 )
{
error = tobii_wait_for_callbacks( NULL, 1, &device );
assert( error == TOBII_ERROR_NO_ERROR || error == TOBII_ERROR_TIMED_OUT );
error = tobii_device_process_callbacks( device );
assert( error == TOBII_ERROR_NO_ERROR );
}
error = tobii_gaze_data_unsubscribe( device );
assert( error == TOBII_ERROR_NO_ERROR );
tobii_device_destroy( device );
tobii_api_destroy( api );
return 0;
}
@endcode
*/
/**
@fn TOBII_API tobii_error_t TOBII_CALL tobii_digital_syncport_subscribe( tobii_device_t* device, tobii_digital_syncport_callback_t callback, void* user_data );
@ingroup tobii_advanced
tobii_digital_syncport_subscribe
--------------------------------
### Function
The digital syncport data stream subscription provides a sparse stream of the device's external port data in sync with
the device clock. This stream will provide new data when the syncport data value changes. Each change on the port is
timestamped with the same clock as the gaze data.
### Syntax
#include <tobii/tobii_advanced.h>
tobii_error_t tobii_digital_syncport_subscribe( tobii_device_t* device,
tobii_digital_syncport_callback_t callback, void* user_data );
### Remarks
To be able to call this function, the *device* should have been created with a minimum license level of Professional
feature group.
*device* must be a pointer to a valid tobii_device_t as created by calling tobii_device_create.
*callback* is a function pointer to a function with the prototype:
void digital_syncport_callback( uint32_t signal, int64_t timestamp_tracker_us,
int64_t timestamp_system_us, void* user_data )
This function will be called when the syncport data value changes. It is called with the following parameters:
- *signal*
An unsigned integer from the external port. In the Spectrum device, only 8 bits are valid. Please
check the hardware documentation of the relevant device for its valid bits.
- *timestamp_tracker_us*
Timestamp value for when the digital syncport data was captured in microseconds (us). It is generated on the
device responsible for capturing the data. *timestamp_system_us* is generated using this value.
The epoch is undefined, so these timestamps are only useful for calculating the time elapsed between a pair of values.
- *timestamp_system_us*
Timestamp value for when the digital syncport data was captured, measured in microseconds (us). The epoch is undefined,
so these timestamps are only useful for calculating the time elapsed between a pair of values. The function
tobii_system_clock can be used to retrieve a timestamp using the same clock and same relative values as this
timestamp.
- *user_data* the custom pointer sent in when registering the callback.
*user_data* custom pointer which will be passed unmodified to the callback.
### Return value
If the call was successful **TOBII_ERROR_NO_ERROR** will be returned. If the call has failed one of the following error
will be returned:
- **TOBII_ERROR_INVALID_PARAMETER**
The *device* parameter has been passed in as NULL.
- **TOBII_ERROR_INSUFFICIENT_LICENSE**
The provided license was not valid, or has been blacklisted.
- **TOBII_ERROR_ALREADY_SUBSCRIBED**
A subscription for digital syncport data was already made. There can only be one callback registered at a time.
To change to another callback, first call tobii_digital_syncport_unsubscribe().
- **TOBII_ERROR_TOO_MANY_SUBSCRIBERS**
Too many subscribers for the requested stream. Tobii eye trackers can have a limitation on the number of concurrent
subscribers to specific streams due to high bandwidth and/or high frequency of the data stream.
- **TOBII_ERROR_INTERNAL**
Some unexpected internal error occurred. This error should normally not be returned, so if it is, please contact
the support
- **TOBII_ERROR_CALLBACK_IN_PROGRESS**
The function failed because it was called from within a callback triggered from an API call such as
tobii_device_process_callbacks(), tobii_calibration_retrieve(), tobii_enumerate_illumination_modes(),
or tobii_license_key_retrieve().
Calling tobii_digital_syncport_subscribe from within a callback function is not supported.
### See Also
tobii_digital_syncport_unsubscribe()
*/
/**
@fn TOBII_API tobii_error_t TOBII_CALL tobii_digital_syncport_unsubscribe( tobii_device_t* device );
@ingroup tobii_advanced
tobii_digital_syncport_unsubscribe
----------------------------------
### Function
Stops the digital syncport data stream.
### Syntax
#include <tobii/tobii_advanced.h>
tobii_digital_syncport_unsubscribe( tobii_device_t* device );
### Remarks
To be able to call this function, the *device* should have been created with a minimum license level of Professional
feature group. *device* must be a pointer to a valid tobii_device_t as created by calling tobii_device_create.
### Return value
If the call was successful **TOBII_ERROR_NO_ERROR** will be returned. If the call has failed one of the following error
will be returned:
- **TOBII_ERROR_INVALID_PARAMETER**
The *device* parameter has been passed in as NULL.
- **TOBII_ERROR_INSUFFICIENT_LICENSE**
The provided license was not valid, or has been blacklisted.
- **TOBII_ERROR_NOT_SUBSCRIBED**
A subscription for digital syncport data was not made before the call to unsubscribe.
- **TOBII_ERROR_INTERNAL**
Some unexpected internal error occurred. This error should normally not be returned, so if it is, please contact
the support
- **TOBII_ERROR_CALLBACK_IN_PROGRESS**
The function failed because it was called from within a callback triggered from an API call such as
tobii_device_process_callbacks(), tobii_calibration_retrieve(), tobii_enumerate_illumination_modes(),
or tobii_license_key_retrieve().
Calling tobii_digital_syncport_unsubscribe from within a callback function is not supported.
### See Also
tobii_digital_syncport_subscribe()
### Example
@code{.c}
#include "tobii/tobii.h"
#include "tobii/tobii_licensing.h"
#include "tobii/tobii_advanced.h"
#include <stdio.h>
#include <assert.h>
static void tobii_digital_syncport_callback( uint32_t signal, int64_t timestamp_tracker_us,
int64_t timestamp_system_us, void* user_data )
{
(void)timestamp_tracker_us;(void)timestamp_system_us;(void)user_data;
printf( "Digital syncport data is %d .\n", signal & 0xff ); // only 8 bits are valid for spectrum tacker
}
int main()
{
tobii_api_t* api;
tobii_error_t error = tobii_api_create( &api, NULL, NULL );
assert( error == TOBII_ERROR_NO_ERROR );
tobii_device_t* device;
char url[ 256 ] = { 0 };
printf( "Enter url to the eye tracker (don't forget prefix tobii-ttp:// or tet-tcp://):\n" );
scanf( "%255s", url );
error = tobii_device_create( api, url, &device ); // if not using a pro tracker use tobii_device_create_ex with Professional license
assert( error == TOBII_ERROR_NO_ERROR );
error = tobii_digital_syncport_subscribe( device, tobii_digital_syncport_callback, 0 );
assert( error == TOBII_ERROR_NO_ERROR );
int is_running = 10; // in this sample, exit after some iterations
while( --is_running > 0 )
{
error = tobii_wait_for_callbacks( NULL, 1, &device );
assert( error == TOBII_ERROR_NO_ERROR || error == TOBII_ERROR_TIMED_OUT );
error = tobii_device_process_callbacks( device );
assert( error == TOBII_ERROR_NO_ERROR );
}
error = tobii_digital_syncport_unsubscribe( device );
assert( error == TOBII_ERROR_NO_ERROR );
tobii_device_destroy( device );
tobii_api_destroy( api );
return 0;
}
@endcode
*/
/**
@fn TOBII_API tobii_error_t TOBII_CALL tobii_enumerate_face_types( tobii_device_t* device, tobii_face_type_receiver_t receiver, void* user_data )
@ingroup tobii_advanced
tobii_enumerate_face_types
----------------------
### Function
Retreives all supported face types from a specific eye tracker.
### Syntax
#include <tobii/tobii_advanced.h>
tobii_error_t tobii_enumerate_face_types( tobii_device_t* device, tobii_face_type_receiver_t receiver,
void* user_data );
### Remarks
A face type is here understood as a class of appearances of the face itself, such as a group of species (e.g. human or
crocodile), facial features (e.g. moustache or makeup), or worn objects (e.g. glasses or hats). It is only used for
situations were auto detecting such differences is difficult or dangerous.
*device* must be a pointer to a valid tobii_device_t instance as created by calling tobii_device_create.
*receiver* is a function pointer to a function with the prototype:
void face_type_receiver( const tobii_face_type_t face_type, void* user_data );
This function will be called for each face type found during enumeration. It is called with the following parameters:
- *face_type*
A zero terminated string representation of a face type, max 63 characters long. This pointer will be invalid after
returning from the function, so ensure you make a copy of the string rather than storing the pointer directly.
- *user_data*
This is the custom pointer sent in to tobii_enumerate_face_types.
*user_data* custom pointer which will be passed unmodified to the receiver function.
### Return value
If the operation is successful, tobii_enumerate_face_types returns **TOBII_ERROR_NO_ERROR**. If the call fails,
tobii_enumerate_face_types returns one of the following:
- **TOBII_ERROR_INVALID_PARAMETER**
The *device* or *receiver* parameter was passed in as NULL.
- **TOBII_ERROR_CALLBACK_IN_PROGRESS**
The function failed because it was called from within a callback triggered from an API call such as
tobii_device_process_callbacks(), tobii_calibration_retrieve() or tobii_enumerate_illumination_modes().
Calling tobii_enumerate_face_types from within a callback function is not supported.
- **TOBII_ERROR_INSUFFICIENT_LICENSE**
The provided license was not a valid config level license, or has been blacklisted.
- **TOBII_ERROR_CONNECTION_FAILED**
The connection to the device was lost. Call tobii_device_reconnect() to re-establish connection.
- **TOBII_ERROR_NOT_SUPPORTED**
The eye tracker does not support enumeration of face types.
- **TOBII_ERROR_INTERNAL**
Some unexpected internal error occurred. This error should normally not be returned, so if it is, please contact
the support
### See also
tobii_get_face_type() and tobii_set_face_type()
### Example
TBD - example needs to be written.
*/
/**
@fn TOBII_API tobii_error_t TOBII_CALL tobii_set_face_type( tobii_device_t* device, tobii_face_type_t const face_type )
@ingroup tobii_advanced
tobii_set_face_type
----------------------
### Function
Applies the specified face type setting to the device.
### Syntax
#include <tobii/tobii_advanced.h>
tobii_error_t tobii_set_face_type( tobii_device_t* device, tobii_face_type_t const face_type );
### Remarks
Applying a new face type causes the current personal calibration to be discarded and the tracker will revert to the
built-in default calibration for the given face type. A *TOBII_NOTIFICATION_TYPE_FACE_TYPE_CHANGED* will be broadcasted
to all clients notifying them that the face type has changed and that a new calibration has to be set.
*device* must be a pointer to a valid tobii_device_t instance as created by calling tobii_device_create.
*face_type* is a zero-terminated string representation of a specific face type setting, with a maximum length of 63
characters. Supported string values can be queried by calling the tobii_enumerate_face_types() function.
### Return value
If the operation is successful, tobii_set_face_type returns **TOBII_ERROR_NO_ERROR**. If the call fails,
tobii_set_face_type returns one of the following:
- **TOBII_ERROR_INVALID_PARAMETER**
The *device* or *receiver* parameter was passed in as NULL.
- **TOBII_ERROR_CALLBACK_IN_PROGRESS**
The function failed because it was called from within a callback triggered from an API call such as
tobii_device_process_callbacks(), tobii_calibration_retrieve() or tobii_enumerate_illumination_modes().
Calling tobii_set_face_type from within a callback function is not supported.
- **TOBII_ERROR_INSUFFICIENT_LICENSE**
The provided license was not a valid config level license, or has been blacklisted.
- **TOBII_ERROR_CONNECTION_FAILED**
The connection to the device was lost. Call tobii_device_reconnect() to re-establish connection.
- **TOBII_ERROR_OPERATION_FAILED**
The function failed because it was called while the device was in calibration mode.
- **TOBII_ERROR_NOT_SUPPORTED**
The device firmware has no support for setting face type.
- **TOBII_ERROR_INTERNAL**
Some unexpected internal error occurred. This error should normally not be returned, so if it is, please contact
the support
### See also
tobii_get_face_type() and tobii_enumerate_face_types()
### Example
TBD - example needs to be written.
*/
/**
@fn TOBII_API tobii_error_t TOBII_CALL tobii_get_face_type( tobii_device_t* device, tobii_face_type_t* face_type );
@ingroup tobii_advanced
tobii_get_face_type
----------------------
### Function
Retreives the current face type setting of the device.
### Syntax
#include <tobii/tobii_advanced.h>
tobii_error_t tobii_get_face_type( tobii_device_t* device, tobii_face_type_t* face_type );
### Remarks
A face type is here understood as a class of appearances of the face itself, such as a group of species (e.g. human or
crocodile), facial features (e.g. moustache or makeup), or worn objects (e.g. glasses or hats). It is only used for
situations were auto detecting such differences is difficult or dangerous.
*device* must be a pointer to a valid tobii_device_t instance as created by calling tobii_device_create.
*face_type* is a pointer to a zero-terminated string representation of the current face type setting,
with a maximum length of 63 characters.
### Return value
If the operation is successful, tobii_get_face_type returns **TOBII_ERROR_NO_ERROR**. If the call fails,
tobii_get_face_type returns one of the following:
- **TOBII_ERROR_INVALID_PARAMETER**
The *device* or *face_type* parameter was passed in as NULL.
- **TOBII_ERROR_CALLBACK_IN_PROGRESS**
The function failed because it was called from within a callback triggered from an API call such as
tobii_device_process_callbacks(), tobii_calibration_retrieve() or tobii_enumerate_illumination_modes().
Calling tobii_get_face_type from within a callback function is not supported.
- **TOBII_ERROR_INSUFFICIENT_LICENSE**
The provided license was not a valid config level license, or has been blacklisted.
- **TOBII_ERROR_CONNECTION_FAILED**
The connection to the device was lost. Call tobii_device_reconnect() to re-establish connection.
- **TOBII_ERROR_NOT_SUPPORTED**
The device firmware has no support for retreiving the current face type.
- **TOBII_ERROR_INTERNAL**
Some unexpected internal error occurred. This error should normally not be returned, so if it is, please contact
the support
### See also
tobii_set_face_type() and tobii_enumerate_face_types()
### Example
TBD - example needs to be written.
*/

File diff suppressed because it is too large Load Diff

@ -0,0 +1,856 @@
/*
COPYRIGHT 2015 - PROPERTY OF TOBII AB
-------------------------------------
2015 TOBII AB - KARLSROVAGEN 2D, DANDERYD 182 53, SWEDEN - All Rights Reserved.
NOTICE: All information contained herein is, and remains, the property of Tobii AB and its suppliers, if any.
The intellectual and technical concepts contained herein are proprietary to Tobii AB and its suppliers and may be
covered by U.S.and Foreign Patents, patent applications, and are protected by trade secret or copyright law.
Dissemination of this information or reproduction of this material is strictly forbidden unless prior written
permission is obtained from Tobii AB.
*/
#ifndef tobii_licensing_h_included
#define tobii_licensing_h_included
#include "tobii.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct tobii_license_key_t
{
uint16_t const* license_key;
size_t size_in_bytes;
} tobii_license_key_t;
typedef enum tobii_license_validation_result_t
{
TOBII_LICENSE_VALIDATION_RESULT_OK,
TOBII_LICENSE_VALIDATION_RESULT_TAMPERED,
TOBII_LICENSE_VALIDATION_RESULT_INVALID_APPLICATION_SIGNATURE,
TOBII_LICENSE_VALIDATION_RESULT_NONSIGNED_APPLICATION,
TOBII_LICENSE_VALIDATION_RESULT_EXPIRED,
TOBII_LICENSE_VALIDATION_RESULT_PREMATURE,
TOBII_LICENSE_VALIDATION_RESULT_INVALID_PROCESS_NAME,
TOBII_LICENSE_VALIDATION_RESULT_INVALID_SERIAL_NUMBER,
TOBII_LICENSE_VALIDATION_RESULT_INVALID_MODEL,
} tobii_license_validation_result_t;
TOBII_API tobii_error_t TOBII_CALL tobii_device_create_ex( tobii_api_t* api, char const* url,
tobii_license_key_t const* license_keys, int license_count, tobii_license_validation_result_t* license_results,
tobii_device_t** device );
TOBII_API tobii_error_t TOBII_CALL tobii_license_key_store( tobii_device_t* device,
void* data, size_t size );
TOBII_API tobii_error_t TOBII_CALL tobii_license_key_retrieve( tobii_device_t* device,
tobii_data_receiver_t receiver, void* user_data );
typedef enum tobii_feature_group_t
{
TOBII_FEATURE_GROUP_BLOCKED,
TOBII_FEATURE_GROUP_CONSUMER,
TOBII_FEATURE_GROUP_CONFIG,
TOBII_FEATURE_GROUP_PROFESSIONAL,
TOBII_FEATURE_GROUP_INTERNAL,
} tobii_feature_group_t;
TOBII_API tobii_error_t TOBII_CALL tobii_get_feature_group( tobii_device_t* device,
tobii_feature_group_t* feature_group );
#ifdef __cplusplus
}
#endif
#endif /* tobii_licensing_h_included */
/**
@defgroup tobii_licensing tobii_licensing.h
tobii_licensing.h
=================
This is the tobii_licensing.h file.
*/
/**
@fn TOBII_API tobii_error_t TOBII_CALL tobii_device_create_ex( tobii_api_t* api, char const* url, tobii_license_key_t const* license_keys, int license_count, tobii_license_validation_result_t* license_results, tobii_device_t** device );
@ingroup tobii_licensing
tobii_device_create_ex
----------------------
### Function
Creates a device instance to be used for communicating with a specific device with a certain license.
### Syntax
#include <tobii/tobii.h>
TOBII_API tobii_error_t TOBII_CALL tobii_device_create_ex( tobii_api_t* api, char const* url, tobii_license_key_t const* license_keys,
int license_count, tobii_license_validation_result_t* license_results, tobii_device_t** device );
### Remarks
In order to communicate with a specific device, stream engine needs to keep track of a lot of internal state.
tobii_device_create_ex allocates and initializes this state, and is needed for all functions which communicates with a
device. Creating a device will establish a connection to the tracker, and can be used to query the device for more
information.
tobii_license_key_t is a basic structure that contains the license key and its size in bytes.
A license key is used for enabling extended functionality of the engine under certain conditions.
Conditions may include time limit, tracker model, tracker serial number, application name and/or application signature.
Every license key have one feature group which gives them a set of features. They may also include additional features
that are not included in their feature group. The device created will have all the features that provided by the valid
licences passed as argument. If there is no valid license, the feature group of the device will be consumer level.
Licenses are provided by Tobii AB.
*api* must be a pointer to a valid tobii_api_t as created by calling tobii_api_create.
*url* must be a valid device url as returned by tobii_enumerate_local_device_urls.
*license_keys* should be provided. It is an array of valid license keys provided by Tobii. At least one license must be
provided. Some API functions requires a different license than the basic consumer license:
*license_results* is optional. It is an array for returning the results of the license validation for each license. It
is adviced the check *license_results* in any case. All the error's is related with licensing will only return by this
array.
- **Professional**
tobii_gaze_data_subscribe(),
tobii_gaze_data_unsubscribe(),
tobii_digital_syncport_subscribe()
tobii_digital_syncport_unsubscribe()
tobii_timesync()
tobii_set_illumination_mode()
- **Config or Professional**
tobii_calibration_start()
tobii_calibration_stop()
tobii_calibration_collect_data_2d()
tobii_calibration_discard_data_2d()
tobii_calibration_clear()
tobii_calibration_compute_and_apply()
tobii_calibration_retrieve()
tobii_calibration_apply()
tobii_set_display_area()
tobii_set_output_frequency()
tobii_set_device_name()
- **Additional Features**
tobii_image_subscribe()
*count* must be provided. It is the number of license keys has provided.
*device* must be a pointer to a variable of the type `tobii_device_t*` that is, a pointer to a tobii_device_t-pointer.
This variable will be filled in with a pointer to the created device. tobii_device_t is an opaque type, and only its
declaration is available in the API, it's definition is internal.
### Return value
If the device is successfully created, tobii_device_create returns **TOBII_ERROR_NO_ERROR**. If the call fails,
tobii_device_create returns one of the following:
- **TOBII_ERROR_INVALID_PARAMETER**
The *api*, *url*, *device* or *license_keys* parameters were passed in as NULL, or the *count* parameter was not
non-zero.
- **TOBII_ERROR_ALLOCATION_FAILED**
The internal call to malloc or to the custom memory allocator (if used) returned NULL, so device creation failed.
- **TOBII_ERROR_CONNECTION_FAILED**
The connection to the device was lost. Call tobii_device_reconnect() to re-establish connection.
- **TOBII_ERROR_INTERNAL**
Some unexpected internal error occurred. This error should normally not be returned, so if it is, please contact
the support.
- **TOBII_ERROR_CALLBACK_IN_PROGRESS**
The function failed because it was called from within a callback triggered from an API call such as
tobii_device_process_callbacks(), tobii_calibration_retrieve(), tobii_enumerate_illumination_modes(),
or tobii_license_key_retrieve().
Calling tobii_device_create_ex from within a callback function is not supported.
### License Errors
- TOBII_LICENSE_VALIDATION_RESULT_OK
The license that has been provided is valid.
- TOBII_LICENSE_VALIDATION_RESULT_TAMPERED
The license file has been tampered.
- TOBII_LICENSE_VALIDATION_RESULT_INVALID_APPLICATION_SIGNATURE
The signature of the application that runs the stream engine is not same with the signature in the license file.
- TOBII_LICENSE_VALIDATION_RESULT_NONSIGNED_APPLICATION
The application that runs the stream engine has not been signed.
- TOBII_LICENSE_VALIDATION_RESULT_EXPIRED
The validity of the license has been expired.
- TOBII_LICENSE_VALIDATION_RESULT_PREMATURE
The license is not valid yet.
- TOBII_LICENSE_VALIDATION_RESULT_INVALID_PROCESS_NAME
The process name of the application that runs the stream engine is not included to the list of process names in the
license file.
- TOBII_LICENSE_VALIDATION_RESULT_INVALID_SERIAL_NUMBER
The serial number of the current eye tracker is not included to the list of serial numbers in the license file.
- TOBII_LICENSE_VALIDATION_RESULT_INVALID_MODEL
The model name of the current eye tracker is not included to the list of model names in the license file.
### See also
tobii_device_destroy(), tobii_enumerate_local_device_urls(), tobii_api_create(), tobii_get_device_info(),
tobii_get_feature_group() tobii_device_create()
### Example
@code{.c}
#include "tobii/tobii.h"
#include "tobii/tobii_licensing.h"
#include <stdio.h>
#include <malloc.h>
#include <memory.h>
#include <assert.h>
static size_t read_license_file( uint16_t* license )
{
FILE *license_file = fopen( "se_license_key_sample", "rb" );
if( !license_file )
{
printf( "License key could not be found!" );
return 0;
}
fseek( license_file, 0, SEEK_END );
long file_size = ftell( license_file );
rewind( license_file );
if( file_size <= 0 )
{
printf( "License file is empty!" );
return 0;
}
if( license )
{
fread( license, sizeof( uint16_t ), file_size / sizeof( uint16_t ), license_file );
}
fclose( license_file );
return ( size_t )file_size;
}
static void url_receiver( char const* url, void* user_data )
{
char* buffer = (char*)user_data;
if( *buffer != '\0' ) return; // only keep first value
if( strlen( url ) < 256 )
strcpy( buffer, url );
}
int main()
{
tobii_api_t* api;
tobii_error_t error = tobii_api_create( &api, NULL, NULL );
assert( error == TOBII_ERROR_NO_ERROR );
size_t license_size = read_license_file( 0 );
assert( license_size > 0 );
uint16_t* license_key = ( uint16_t* )malloc( license_size );
memset( license_key, 0, license_size );
read_license_file( license_key );
tobii_license_key_t license = { license_key, license_size };
tobii_license_validation_result_t validation_result;
char url[ 256 ] = { 0 };
error = tobii_enumerate_local_device_urls( api, url_receiver, url );
assert( error == TOBII_ERROR_NO_ERROR && *url != '\0' );
tobii_device_t* device;
error = tobii_device_create_ex( api, url, &license, 1, &validation_result, &device );
free( license_key );
assert( error == TOBII_ERROR_NO_ERROR );
// --> code to use the device would go here <--
error = tobii_device_destroy( device );
assert( error == TOBII_ERROR_NO_ERROR );
error = tobii_api_destroy( api );
assert( error == TOBII_ERROR_NO_ERROR );
return 0;
}
@endcode
*/
/**
@fn TOBII_API tobii_error_t TOBII_CALL tobii_license_key_store( tobii_device_t* device, void* data, size_t size );
@ingroup tobii_licensing
tobii_license_key_store
-----------------------
### Function
Stores the license key on the tracker
### Syntax
#include <tobii/tobii.h>
tobii_error_t tobii_license_key_store( tobii_device_t* device, void* data, size_t size );
### Remarks
license key can be stored on the device. Only one key will be stored on the device so calling the API will overwrite
the old key. If either data or size is passed as 0 then it will erase the already stored license key.
*device* must be a pointer to a variable of the type `tobii_device_t*` that is, a pointer to a tobii_device_t.
*data* has to be in uint16_t text passed as the void*. It is optional and hence if it is 0 then it will erase already
stored license
*size* is the no of bytes in the data buffer. If it is passed as 0 then it will erase already stored license.
### Return value
If the device is successfully created, tobii_device_create returns **TOBII_ERROR_NO_ERROR**. If the call fails,
tobii_device_create returns one of the following:
- **TOBII_ERROR_INVALID_PARAMETER**
The *device* parameter was passed in as NULL.
- **TOBII_ERROR_ALLOCATION_FAILED**
The internal call to malloc or to the custom memory allocator (if used) returned NULL, so device creation failed.
- **TOBII_ERROR_CONNECTION_FAILED**
The connection to the device was lost. Call tobii_device_reconnect() to re-establish connection.
- **TOBII_ERROR_NOT_SUPPORTED**
The device doesn't support storage APIs. This error is returned if the API is called with an old device which
doesn't support the license device store.
- **TOBII_ERROR_OPERATION_FAILED**
Writting to the the device failed because of unexpected IO error, file not found, storage is full or filename is
invalid.
- **TOBII_ERROR_INTERNAL**
Some unexpected internal error occurred. This error should normally not be returned, so if it is, please contact
the support.
- **TOBII_ERROR_CALLBACK_IN_PROGRESS**
The function failed because it was called from within a callback triggered from an API call such as
tobii_device_process_callbacks(), tobii_calibration_retrieve(), tobii_enumerate_illumination_modes(),
or tobii_license_key_retrieve().
Calling tobii_license_key_store from within a callback function is not supported.
### See also
tobii_license_key_retrieve(), tobii_device_create()
### Example
@code{.c}
#include "tobii/tobii_licensing.h"
#include <stdio.h>
#include <malloc.h>
#include <memory.h>
#include <assert.h>
static size_t read_license_file( uint16_t* license )
{
FILE *license_file = fopen( "se_license_key_sample", "rb" );
if( !license_file )
{
printf( "License key could not be found!" );
return 0;
}
fseek( license_file, 0, SEEK_END );
long file_size = ftell( license_file );
rewind( license_file );
if( file_size <= 0 )
{
printf( "License file is empty!" );
return 0;
}
if( license )
{
fread( license, sizeof( uint16_t ), file_size / sizeof( uint16_t ), license_file );
}
fclose( license_file );
return ( size_t )file_size;
}
void data_receiver( void const* data, size_t size, void* user_data )
{
if ( !data || !size || !user_data ) return; // user_data shouldn't be NULL if passed as Non NULL
// The license is received here,
// --> code to use the device would go here <--
// We will just compare if the store was ok for demo pupose.
tobii_license_key_t* license = ( tobii_license_key_t* )user_data;
if( size != license->size_in_bytes ) return;
if( !memcmp( (void*)license->license_key, data, size ) )
printf("Data Received correctly");
else
printf( "Invalid Data Received" );
}
static void url_receiver( char const* url, void* user_data )
{
char* buffer = (char*)user_data;
if( *buffer != '\0' ) return; // only keep first value
if( strlen( url ) < 256 )
strcpy( buffer, url );
}
int main()
{
tobii_api_t* api;
tobii_error_t error = tobii_api_create( &api, NULL, NULL );
assert( error == TOBII_ERROR_NO_ERROR );
size_t license_size = read_license_file( 0 );
assert( license_size > 0 );
uint16_t* license_key = ( uint16_t* )malloc( license_size );
memset( license_key, 0, license_size );
read_license_file( license_key );
tobii_license_key_t license = { license_key, license_size };
tobii_license_validation_result_t validation_result;
char url[ 256 ] = { 0 };
error = tobii_enumerate_local_device_urls( api, url_receiver, url );
assert( error == TOBII_ERROR_NO_ERROR && *url != '\0' );
tobii_device_t* device;
error = tobii_device_create_ex( api, url, &license, 1, &validation_result, &device );
if ( error != TOBII_ERROR_NO_ERROR ) free( license_key );
assert( error == TOBII_ERROR_NO_ERROR );
// Store The license to the device
error = tobii_license_key_store( device, (void*) license.license_key,
license.size_in_bytes );
if( error != TOBII_ERROR_NO_ERROR ) free( license_key );
assert( error == TOBII_ERROR_NO_ERROR );
// Retrieve the license from the device
error = tobii_license_key_retrieve( device, data_receiver, (void*)&license );
free( license_key );
assert( error == TOBII_ERROR_NO_ERROR );
// Erase the license from the device
error = tobii_license_key_store( device, 0, 0 );
assert( error == TOBII_ERROR_NO_ERROR );
error = tobii_device_destroy( device );
assert( error == TOBII_ERROR_NO_ERROR );
error = tobii_api_destroy( api );
assert( error == TOBII_ERROR_NO_ERROR );
return 0;
}
@endcode
*/
/**
@fn TOBII_API tobii_error_t TOBII_CALL tobii_license_key_retrieve( tobii_device_t* device, tobii_data_receiver_t receiver, void* user_data );
@ingroup tobii_licensing
tobii_license_key_retrieve
--------------------------
### Function
Retreives the already stored license key from the device.
### Syntax
#include <tobii/tobii.h>
tobii_error_t tobii_license_key_retrieve( tobii_device_t* device, tobii_data_receiver_t receiver, void* user_data );
### Remarks
The receiver function passed as the parameter receives the data.
Instead of storing the pointer to data, content of the data should be copied
as the data pointer becomes invalid after the call is over.
*device* must be a pointer to a variable of the type `tobii_device_t*` that is, a pointer to a tobii_device_t-pointer.
the device is obtained by calling tobii_device_create() or by tobii_device_create_ex(). It must be freed by
calling tobii_device_destroy() as clean up operation.
*receiver* is a function pointer to a function with the prototype:
void data_receiver( void const* data, size_t size, void* user_data )
This function will be called with the retrieved license data. It is called with the following parameters:
- *data*
The license data read from device. This pointer will be invalid after returning from the function,
so ensure you make a copy of the data rather than storing the pointer directly.
- *size*
This gives the size of the data buffer read.
- *user_data*
This is the custom pointer sent in to tobii_license_key_retrieve.
*user_data* is optional. Caller can pass any data here as the calling device which could be used in the *receiver*.
### Return value
If the device is successfully created, tobii_device_create returns **TOBII_ERROR_NO_ERROR**. If the call fails,
tobii_device_create returns one of the following:
- **TOBII_ERROR_INVALID_PARAMETER**
The *device* parameter was passed in as NULL.
- **TOBII_ERROR_ALLOCATION_FAILED**
The internal call to malloc or to the custom memory allocator (if used) returned NULL, so device creation failed.
- **TOBII_ERROR_CONNECTION_FAILED**
The connection to the device was lost. Call tobii_device_reconnect() to re-establish connection.
- **TOBII_ERROR_NOT_SUPPORTED**
The device doesn't support storage APIs. This error is returned if the API is called with an old device which
doesn't support the license device store.
- **TOBII_ERROR_OPERATION_FAILED**
Reading from the device failed because of unexpected IO error, file not found, filename is invalid.
- **TOBII_ERROR_INTERNAL**
Some unexpected internal error occurred. This error should normally not be returned, so if it is, please contact
the support.
- **TOBII_ERROR_CALLBACK_IN_PROGRESS**
The function failed because it was called from within a callback triggered from an API call such as
tobii_device_process_callbacks(), tobii_calibration_retrieve(), tobii_enumerate_illumination_modes(),
or tobii_license_key_retrieve().
Calling tobii_license_key_retrieve from within a callback function is not supported.
### See also
tobii_license_key_retrieve(), tobii_device_create()
### Example
@code{.c}
#include "tobii/tobii_licensing.h"
#include <stdio.h>
#include <malloc.h>
#include <memory.h>
#include <assert.h>
static size_t read_license_file( uint16_t* license )
{
FILE *license_file = fopen( "se_license_key_sample", "rb" );
if( !license_file )
{
printf( "License key could not be found!" );
return 0;
}
fseek( license_file, 0, SEEK_END );
long file_size = ftell( license_file );
rewind( license_file );
if( file_size <= 0 )
{
printf( "License file is empty!" );
return 0;
}
if( license )
{
fread( license, sizeof( uint16_t ), file_size / sizeof( uint16_t ), license_file );
}
fclose( license_file );
return ( size_t )file_size;
}
void data_receiver( void const* data, size_t size, void* user_data )
{
if ( !data || !size || !user_data ) return; // user_data shouldn't be NULL if passed as Non NULL
// The license is received here,
// --> code to use the device would go here <--
// We will just compare if the store was ok for demo pupose.
tobii_license_key_t* license = ( tobii_license_key_t* )user_data;
if( size != license->size_in_bytes ) return;
if( !memcmp( (void*)license->license_key, data, size ) )
printf("Data Received correctly");
else
printf( "Invalid Data Received" );
}
static void url_receiver( char const* url, void* user_data )
{
char* buffer = (char*)user_data;
if( *buffer != '\0' ) return; // only keep first value
if( strlen( url ) < 256 )
strcpy( buffer, url );
}
int main()
{
tobii_api_t* api;
tobii_error_t error = tobii_api_create( &api, NULL, NULL );
assert( error == TOBII_ERROR_NO_ERROR );
size_t license_size = read_license_file( 0 );
assert( license_size > 0 );
uint16_t* license_key = ( uint16_t* )malloc( license_size );
memset( license_key, 0, license_size );
read_license_file( license_key );
tobii_license_key_t license = { license_key, license_size };
tobii_license_validation_result_t validation_result;
char url[ 256 ] = { 0 };
error = tobii_enumerate_local_device_urls( api, url_receiver, url );
assert( error == TOBII_ERROR_NO_ERROR && *url != '\0' );
tobii_device_t* device;
error = tobii_device_create_ex( api, url, &license, 1, &validation_result, &device );
if ( error != TOBII_ERROR_NO_ERROR ) free( license_key );
assert( error == TOBII_ERROR_NO_ERROR );
// Store The license to the device
error = tobii_license_key_store( device, (void*) license.license_key,
license.size_in_bytes );
if( error != TOBII_ERROR_NO_ERROR ) free( license_key );
assert( error == TOBII_ERROR_NO_ERROR );
// Retrieve the license from the device
error = tobii_license_key_retrieve( device, data_receiver, (void*)&license );
free( license_key );
assert( error == TOBII_ERROR_NO_ERROR );
// Erase the license from the device
error = tobii_license_key_store( device, 0, 0 );
assert( error == TOBII_ERROR_NO_ERROR );
error = tobii_device_destroy( device );
assert( error == TOBII_ERROR_NO_ERROR );
error = tobii_api_destroy( api );
assert( error == TOBII_ERROR_NO_ERROR );
return 0;
}
@endcode
*/
/**
@fn TOBII_API tobii_error_t TOBII_CALL tobii_get_feature_group( tobii_device_t* device, tobii_feature_group_t* feature_group );
@ingroup tobii_licensing
tobii_get_feature_group
-----------------------
### Function
Retrieves the currently active feature group for a device.
### Syntax
#include <tobii/tobii_advanced.h>
tobii_error_t tobii_get_feature_group( tobii_device_t* device, tobii_feature_group_t* feature_group );
### Remarks
The currently active feature group is determined by tobii_device_create based on the license key passed into it.
tobii_get_feature_group can be used to query the currently active feature group.
*device* must be a pointer to a valid tobii_device_t as created by calling tobii_device_create.
*feature_group* is a pointer to a tobii_feature_group_t to receive the current group, in the form of values from the
following enum:
- **TOBII_FEATURE_GROUP_BLOCKED**
The provided license key was invalid, or the application making the call has been blacklisted. No API functionality
will be available.
- **TOBII_FEATURE_GROUP_CONSUMER**
Default feature group for passing a NULL (default) license key to tobii_device_create. Gives access to all API
functions except those where a higher feature group is specified in the documentation.
- **TOBII_FEATURE_GROUP_CONFIG**
Grants access to functionality that changes configuration of the tracker (mainly in tobii_config.h). This feature
group might be automatically granted for certain devices, like head-mounted displays, even if a default license key
is used.
- **TOBII_FEATURE_GROUP_PROFESSIONAL**
Gives access to the functionality in tobii_advanced.h. This feature group might be automatically granted for
professional level devices, as supplied by Tobii Pro, even if a default license key is used.
- **TOBII_FEATURE_GROUP_INTERNAL**
For internal use by Tobii.
The current feature group controls which API features are available. The documentation will state which functions
require a specific license (if it is not specified, it is assumed that **TOBII_FEATURE_GROUP_CONSUMER** is required).
Each feature group includes all feature groups preceding it (with the exception of **TOBII_FEATURE_GROUP_BLOCKED**,
which indicates that the specified license key was found to be invalid, or the current application has been blacklisted,
in which case no API functions will be available).
### Return value
If the feature group was successfully retrieved, tobii_get_feature_group returns **TOBII_ERROR_NO_ERROR**. If the call
fails, tobii_get_feature_group returns one of the following:
- **TOBII_ERROR_INVALID_PARAMETER**
One or more of the *device* and *feature_group* parameters were passed in as NULL. *device* must be a valid
tobii_device_t pointer as created by tobii_device_create, and *feature_group* must be a valid pointer to a
tobii_feature_group_t variable.
- **TOBII_ERROR_INTERNAL**
Some unexpected internal error occurred. This error should normally not be returned, so if it is, please contact
the support.
- **TOBII_ERROR_CALLBACK_IN_PROGRESS**
The function failed because it was called from within a callback triggered from an API call such as
tobii_device_process_callbacks(), tobii_calibration_retrieve(), tobii_enumerate_illumination_modes(),
or tobii_license_key_retrieve().
Calling tobii_get_feature_group from within a callback function is not supported.
### See also
tobii_device_create()
### Example
@code{.c}
#include <tobii/tobii_licensing.h>
#include <stdio.h>
#include <assert.h>
static void url_receiver( char const* url, void* user_data )
{
char* buffer = (char*)user_data;
if( *buffer != '\0' ) return; // only keep first value
if( strlen( url ) < 256 )
strcpy( buffer, url );
}
int main()
{
tobii_api_t* api;
tobii_error_t error = tobii_api_create( &api, NULL, NULL );
assert( error == TOBII_ERROR_NO_ERROR );
char url[ 256 ] = { 0 };
error = tobii_enumerate_local_device_urls( api, url_receiver, url );
assert( error == TOBII_ERROR_NO_ERROR && *url != '\0' );
tobii_device_t* device;
error = tobii_device_create( api, url, &device );
assert( error == TOBII_ERROR_NO_ERROR );
tobii_feature_group_t feature_group;
error = tobii_get_feature_group( device, &feature_group );
assert( error == TOBII_ERROR_NO_ERROR );
if( feature_group == TOBII_FEATURE_GROUP_CONSUMER )
printf( "Running with 'consumer' feature group.\n" );
error = tobii_device_destroy( device );
assert( error == TOBII_ERROR_NO_ERROR );
error = tobii_api_destroy( api );
assert( error == TOBII_ERROR_NO_ERROR );
return 0;
}
@endcode
*/

File diff suppressed because it is too large Load Diff

@ -0,0 +1,782 @@
/*
COPYRIGHT 2015 - PROPERTY OF TOBII AB
-------------------------------------
2015 TOBII AB - KARLSROVAGEN 2D, DANDERYD 182 53, SWEDEN - All Rights Reserved.
NOTICE: All information contained herein is, and remains, the property of Tobii AB and its suppliers, if any.
The intellectual and technical concepts contained herein are proprietary to Tobii AB and its suppliers and may be
covered by U.S.and Foreign Patents, patent applications, and are protected by trade secret or copyright law.
Dissemination of this information or reproduction of this material is strictly forbidden unless prior written
permission is obtained from Tobii AB.
*/
#ifndef tobii_wearable_h_included
#define tobii_wearable_h_included
#include "tobii.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum tobii_wearable_tracking_improvement_t
{
TOBII_WEARABLE_TRACKING_IMPROVEMENT_USER_POSITION_HMD,
TOBII_WEARABLE_TRACKING_IMPROVEMENT_CALIBRATION_CONTAINS_POOR_DATA,
TOBII_WEARABLE_TRACKING_IMPROVEMENT_CALIBRATION_DIFFERENT_BRIGHTNESS,
TOBII_WEARABLE_TRACKING_IMPROVEMENT_IMAGE_QUALITY,
TOBII_WEARABLE_TRACKING_IMPROVEMENT_INCREASE_EYE_RELIEF,
} tobii_wearable_tracking_improvement_t;
typedef struct tobii_wearable_eye_t
{
tobii_validity_t gaze_origin_validity;
float gaze_origin_mm_xyz[ 3 ];
tobii_validity_t gaze_direction_validity;
float gaze_direction_normalized_xyz[ 3 ];
tobii_validity_t pupil_diameter_validity;
float pupil_diameter_mm;
tobii_validity_t eye_openness_validity;
float eye_openness;
tobii_validity_t pupil_position_in_sensor_area_validity;
float pupil_position_in_sensor_area_xy[ 2 ];
tobii_validity_t position_guide_validity;
float position_guide_xy[ 2 ];
} tobii_wearable_eye_t;
typedef struct tobii_wearable_data_t
{
int64_t timestamp_tracker_us;
int64_t timestamp_system_us;
uint32_t frame_counter;
uint32_t led_mode;
tobii_wearable_eye_t left;
tobii_wearable_eye_t right;
tobii_validity_t gaze_origin_combined_validity;
float gaze_origin_combined_mm_xyz[ 3 ];
tobii_validity_t gaze_direction_combined_validity;
float gaze_direction_combined_normalized_xyz[ 3 ];
tobii_validity_t convergence_distance_validity;
float convergence_distance_mm;
int tracking_improvements_count;
tobii_wearable_tracking_improvement_t tracking_improvements[ 10 ];
} tobii_wearable_data_t;
typedef void (*tobii_wearable_data_callback_t)( tobii_wearable_data_t const* data, void* user_data );
TOBII_API tobii_error_t TOBII_CALL tobii_wearable_data_subscribe( tobii_device_t* device,
tobii_wearable_data_callback_t callback, void* user_data );
TOBII_API tobii_error_t TOBII_CALL tobii_wearable_data_unsubscribe( tobii_device_t* device );
typedef struct tobii_lens_configuration_t
{
float left_xyz[ 3 ];
float right_xyz[ 3 ];
} tobii_lens_configuration_t;
TOBII_API tobii_error_t TOBII_CALL tobii_get_lens_configuration( tobii_device_t* device,
tobii_lens_configuration_t* lens_config );
TOBII_API tobii_error_t TOBII_CALL tobii_set_lens_configuration( tobii_device_t* device,
tobii_lens_configuration_t const* lens_config );
typedef enum tobii_lens_configuration_writable_t
{
TOBII_LENS_CONFIGURATION_NOT_WRITABLE,
TOBII_LENS_CONFIGURATION_WRITABLE,
} tobii_lens_configuration_writable_t;
TOBII_API tobii_error_t TOBII_CALL tobii_lens_configuration_writable( tobii_device_t* device,
tobii_lens_configuration_writable_t* writable );
#ifdef __cplusplus
}
#endif
#endif /* tobii_wearable_h_included */
/**
@defgroup tobii_wearable tobii_wearable.h
tobii_wearable.h
===============
tobii_wearable.h contains functions relating to wearable devices, such as VR headsets. It contains a specialized data
stream with different data from the regular streams, as well as functions to retrieve and modify the lens configuration
of the device.
*/
/**
@fn TOBII_API tobii_error_t TOBII_CALL tobii_wearable_data_subscribe( tobii_device_t* device, tobii_wearable_data_callback_t callback, void* user_data );
@ingroup tobii_wearable
tobii_wearable_data_subscribe
-----------------------------
### Function
Start listening for eye tracking data from wearable device, such as VR headsets.
### Syntax
#include <tobii/tobii_wearable.h>
tobii_error_t tobii_wearable_data_subscribe( tobii_device_t* device,
tobii_wearable_data_callback_t callback, void* user_data );
### Remarks
All coordinates are expressed in a right-handed Cartesian system.
*device* must be a pointer to a valid tobii_device_t instance as created by calling tobii_device_create or
tobii_device_create_ex.
*callback* is a function pointer to a function with the prototype:
void wearable_callback( tobii_wearable_data_t const* data, void* user_data )
This function will be called when there is new data available. It is called with the following parameters:
- *data*
This is a pointer to a struct containing the data listed below. Note that it is only valid during the callback. Its data
should be copied if access is necessary at a later stage, from outside the callback.
- *timestamp_tracker_us*
Timestamp value for when the data was captured, measured in microseconds (us). It is generated on the
device responsible for capturing the data. The epoch is undefined, so these timestamps are only useful for
calculating the time elapsed between a pair of values. The value returned in *timestamp_system_us* is
calculated from this value.
- *timestamp_system_us*
Timestamp value for when the data was captured, measured in microseconds (us), and synchronized with the clock of
the computer. The function tobii_system_clock can be used to retrieve a timestamp (at the time of the call) using
the same clock and same relative values as this timestamp. The epoch is undefined, so these timestamps are only
useful for calculating the time elapsed between a pair of values.
- *frame_counter*
A counter that increments by one each frame. There is no guarantee on its initial value. Will eventually wrap
around and restart at 0, which may be necessary to detect and handle if comparing the values between frames.
- *led_mode*
A bitmask where each bit (starting from the least significant bit) represents a LED group and whether it is active
or not, with a value of 1 being active and 0 inactive.
- *left*
This is a struct containing the following data, related to the left eye:
- *gaze_origin_validity*
**TOBII_VALIDITY_INVALID** if *gaze_origin_mm_xyz* is not valid for this frame, **TOBII_VALIDITY_VALID** if it is.
- *gaze_origin_mm_xyz*
An array of three floats, for the x, y and z coordinate of the point in the user's eye from which the calculated
gaze ray originates, expressed in a right-handed Cartesian coordinate system. See the wearable hardware specification
for its origin.
- *gaze_direction_validity*
**TOBII_VALIDITY_INVALID** if *gaze_direction_normalized_xyz* for the eye is not valid for this frame,
**TOBII_VALIDITY_VALID** if it is.
- *gaze_direction_normalized_xyz*
An array of three floats, for the x, y and z coordinate of the gaze direction of the eye of the user, expressed
as a unit vector in a right-handed Cartesian coordinate system.
- *pupil_diameter_validity*
**TOBII_VALIDITY_INVALID** if *pupil_diameter_mm* is not valid for this frame, **TOBII_VALIDITY_VALID** if it is.
- *pupil_diameter_mm*
A float that represents the approximate diameter of the pupil, expressed in millimeters. Only relative changes
are guaranteed to be accurate.
- *eye_openness_validity*
**TOBII_VALIDITY_INVALID** if *eye_openess* for the eye is not valid for this frame, **TOBII_VALIDITY_VALID**
if it is.
- *eye_openness*
A float that represents how open the user's eye is, where 1.0 means the eye is fully open and 0.0 the eye is fully closed.
Some devices are only be able to report fully open and fully closed.
- *pupil_position_in_sensor_area_validity*
**TOBII_VALIDITY_INVALID** if *pupil_position_in_sensor_area_xy* is not valid for this frame,
**TOBII_VALIDITY_VALID** if it is.
- *pupil_position_in_sensor_area_xy*
An array of two floats, for the x and y of the position of the pupil normalized to the sensor area where
(0, 0): is the top left of sensor area, from the sensor's perspective
(1, 1): is the bottom right of sensor area, from the sensor's perspective
In systems where multiple cameras observe both eyes, this signal gives the pupil position in the primary sensor.
Useful for detecting and visualizing how well the eyes are centered in the sensor images.
- *position_guide_validity*
**TOBII_VALIDITY_INVALID** if *position_guide_xy* is not valid for this frame,
**TOBII_VALIDITY_VALID** if it is.
- *position_guide_xy*
An array of two floats, for the x and y normalized positions per eye.
The position should be compensated with the offset between lens and camera optical axis.
0.5: is the optimal position
0.3-0.7: is when the position is ok and all gaze use cases are supported (green eyes in the position guide app)
0-0.3 and 0.7-1: is when the system might still output gaze but performance is degraded (yellow eyes)
<0 and >1: is when any gaze values are not reliable. No gaze use cases are supported (red eyes)
- *right*
This is another instance of the same struct as in *left*, but which holds data related to the right eye of the user.
- *gaze_origin_combined_validity*
**TOBII_VALIDITY_INVALID** if *gaze_origin_combined_mm_xyz* is not valid for this frame, **TOBII_VALIDITY_VALID** if it is.
This field will only be set if you have the capability TOBII_CAPABILITY_COMBINED_GAZE_VR. See tobii_capability_supported().
- *gaze_origin_combined_mm_xyz*
An array of three floats, for the x, y and z coordinate of the point in from which the combined gaze ray originates, expressed
in a right-handed Cartesian coordinate system.
This field will only be set if you have the capability TOBII_CAPABILITY_COMBINED_GAZE_VR. See tobii_capability_supported().
- *gaze_direction_combined_validity*
**TOBII_VALIDITY_INVALID** if *gaze_direction_combined_normalized_xyz* is not valid for this frame, **TOBII_VALIDITY_VALID** if it is.
This field will only be set if you have the capability TOBII_CAPABILITY_COMBINED_GAZE_VR. See tobii_capability_supported().
- *gaze_direction_combined_normalized_xyz*
An array of three floats, for the x, y and z coordinate of the combined gaze direction of the left and right eye of the user, expressed
as a unit vector in a right-handed Cartesian coordinate system.
This field will only be set if you have the capability TOBII_CAPABILITY_COMBINED_GAZE_VR. See tobii_capability_supported().
- *tracking_improvements_count*
The count gives the no of tracking improvements available in the array of **tracking_improvements**. If the count is 0 meaning there is no imrovement available.
- *tracking_improvements*
This is an array containing the available tracking improvements. The array elements could be among the following enum values
**TOBII_WEARABLE_TRACKING_IMPROVEMENT_USER_POSITION_HMD** if the HMD position needs adjustment.
**TOBII_WEARABLE_TRACKING_IMPROVEMENT_CALIBRATION_CONTAINS_POOR_DATA** if the recalibration is required due to calibration contains poor data.
**TOBII_WEARABLE_TRACKING_IMPROVEMENT_CALIBRATION_DIFFERENT_BRIGHTNESS** if the recalibration is required with different brightness level.
**TOBII_WEARABLE_TRACKING_IMPROVEMENT_IMAGE_QUALITY** if the image quality needs to be improved.
**TOBII_WEARABLE_TRACKING_IMPROVEMENT_INCREASE_EYE_RELIEF** if the eye relief is required to be increased.
- *convergence_distance_validity*
**TOBII_VALIDITY_INVALID** if *convergence_distance_mm* is not valid for this frame, **TOBII_VALIDITY_VALID** if it is.
- *convergence_distance_mm*
convergence distance in mm. It is the distance from the midpoint between both left and right cornea position and the intersection point.
- *user_data*
This is the custom pointer sent in when registering the callback.
*user_data* custom pointer which will be passed unmodified to the callback function.
### Return value
If the operation is successful, tobii_wearable_data_subscribe() returns **TOBII_ERROR_NO_ERROR**. If the call
fails, tobii_wearable_data_subscribe returns one of the following:
- **TOBII_ERROR_INVALID_PARAMETER**
One or more of the *device* and *callback* parameters were passed in as NULL.
- **TOBII_ERROR_ALREADY_SUBSCRIBED**
A subscription for wearable data were already made. There can only be one callback registered at a time.
To change to another callback, first call tobii_wearable_data_unsubscribe().
- **TOBII_ERROR_NOT_SUPPORTED**
The device doesn't support the stream. This error is returned if the API is called with a non-VR device.
- **TOBII_ERROR_TOO_MANY_SUBSCRIBERS**
Too many subscribers for the requested stream. Tobii eye trackers can have a limitation on the number of concurrent
subscribers to specific streams due to high bandwidth and/or high frequency of the data stream.
- **TOBII_ERROR_INTERNAL**
Some unexpected internal error occurred. This error should normally not be returned, so if it is, please contact
the support.
- **TOBII_ERROR_CALLBACK_IN_PROGRESS**
The function failed because it was called from within a callback triggered from an API call such as
tobii_device_process_callbacks(), tobii_calibration_retrieve(), tobii_enumerate_illumination_modes(),
or tobii_license_key_retrieve().
Calling tobii_wearable_data_subscribe from within a callback function is not supported.
### See also
tobii_wearable_data_unsubscribe(), tobii_device_process_callbacks(), tobii_capability_supported()
### Example
@code{.c}
#include <tobii/tobii_wearable.h>
#include <stdio.h>
#include <assert.h>
void wearable_callback( tobii_wearable_data_t const* wearable,
void* user_data )
{
if( wearable->left.gaze_direction_validity )
{
printf( "Left gaze direction: (%f, %f, %f)\n",
wearable->left.gaze_direction_normalized_xyz[ 0 ],
wearable->left.gaze_direction_normalized_xyz[ 1 ],
wearable->left.gaze_direction_normalized_xyz[ 2 ] );
}
else
printf( "Left gaze direction: INVALID\n" );
if( wearable->right.gaze_direction_validity )
{
printf( "Right gaze direction: (%f, %f, %f)\n",
wearable->right.gaze_direction_normalized_xyz[ 0 ],
wearable->right.gaze_direction_normalized_xyz[ 1 ],
wearable->right.gaze_direction_normalized_xyz[ 2 ] );
}
else
printf( "Right gaze direction: INVALID\n" );
}
static void url_receiver( char const* url, void* user_data )
{
char* buffer = (char*)user_data;
if( *buffer != '\0' ) return; // only keep first value
if( strlen( url ) < 256 )
strcpy( buffer, url );
}
int main()
{
tobii_api_t* api;
tobii_error_t error = tobii_api_create( &api, NULL, NULL );
assert( error == TOBII_ERROR_NO_ERROR );
char url[ 256 ] = { 0 };
error = tobii_enumerate_local_device_urls( api, url_receiver, url );
assert( error == TOBII_ERROR_NO_ERROR && *url != '\0' );
tobii_device_t* device;
error = tobii_device_create( api, url, &device );
assert( error == TOBII_ERROR_NO_ERROR );
error = tobii_wearable_data_subscribe( device, wearable_callback, 0 );
assert( error == TOBII_ERROR_NO_ERROR );
int is_running = 1000; // in this sample, exit after some iterations
while( --is_running > 0 )
{
error = tobii_wait_for_callbacks( NULL, 1, &device );
assert( error == TOBII_ERROR_NO_ERROR || error == TOBII_ERROR_TIMED_OUT );
error = tobii_device_process_callbacks( device );
assert( error == TOBII_ERROR_NO_ERROR );
}
error = tobii_wearable_data_unsubscribe( device );
assert( error == TOBII_ERROR_NO_ERROR );
error = tobii_device_destroy( device );
assert( error == TOBII_ERROR_NO_ERROR );
error = tobii_api_destroy( api );
assert( error == TOBII_ERROR_NO_ERROR );
return 0;
}
@endcode
*/
/**
@fn TOBII_API tobii_error_t TOBII_CALL tobii_wearable_data_unsubscribe( tobii_device_t* device );
@ingroup tobii_wearable
tobii_wearable_data_unsubscribe
-------------------------------
### Function
Stops listening to the wearable data stream that was subscribed to by a call to tobii_wearable_data_subscribe().
### Syntax
#include <tobii/tobii_wearable.h>
tobii_error_t TOBII_CALL tobii_wearable_data_unsubscribe( tobii_device_t* device );
### Remarks
*device* must be a pointer to a valid tobii_device_t instance as created by calling tobii_device_create or
tobii_device_create_ex.
### Return value
If the operation is successful, tobii_wearable_data_unsubscribe() returns **TOBII_ERROR_NO_ERROR**. If the call
fails, tobii_wearable_data_unsubscribe returns one of the following:
- **TOBII_ERROR_INVALID_PARAMETER**
The *device* parameter was passed in as NULL.
- **TOBII_ERROR_NOT_SUBSCRIBED**
There was no subscription for wearable data. It is only valid to call tobii_wearable_data_unsubscribe()
after first successfully calling tobii_wearable_data_subscribe().
- **TOBII_ERROR_NOT_SUPPORTED**
The device doesn't support the stream. This error is returned if the API is called with an old device and/or that is
running outdated firmware.
- **TOBII_ERROR_INTERNAL**
Some unexpected internal error occurred. This error should normally not be returned, so if it is, please contact
the support
- **TOBII_ERROR_CALLBACK_IN_PROGRESS**
The function failed because it was called from within a callback triggered from an API call such as
tobii_device_process_callbacks(), tobii_calibration_retrieve(), tobii_enumerate_illumination_modes(),
or tobii_license_key_retrieve().
Calling tobii_wearable_data_unsubscribe from within a callback function is not supported.
### See also
tobii_wearable_data_subscribe()
*/
/**
@fn TOBII_API tobii_error_t TOBII_CALL tobii_get_lens_configuration( tobii_device_t* device, tobii_lens_configuration_t* lens_config );
@ingroup tobii_wearable
tobii_get_lens_configuration
----------------------------
### Function
Retrieves the current lens configuration in the tracker.
### Syntax
#include <tobii/tobii_wearable.h>
tobii_error_t TOBII_CALL tobii_get_lens_configuration( tobii_device_t* device,
tobii_lens_configuration_t* lens_config );
### Remarks
*device* must be a pointer to a valid tobii_device_t instance as created by calling tobii_device_create or
tobii_device_create_ex.
*lens_config* must be a pointer to a valid tobii_lens_configuration_t. Upon success, it will be populated with the
relevant data. It will remain unmodified upon failure. It is a pointer to a struct containing the following data:
- *left*
An array of three floats, for the x, y and z offset of the left lens in the headset, given in millimeters.
- *right*
An array of three floats, for the x, y and z offset of the right lens in the headset, given in millimeters.
### Return value
If the operation is successful, tobii_get_lens_configuration() returns **TOBII_ERROR_NO_ERROR**. If the call
fails, tobii_get_lens_configuration returns one of the following:
- **TOBII_ERROR_INVALID_PARAMETER**
The *device* or *lens_config* parameter was passed in as NULL.
- **TOBII_ERROR_CONNECTION_FAILED**
The connection to the device was lost. Call tobii_device_reconnect() to re-establish connection.
- **TOBII_ERROR_NOT_SUPPORTED**
The device doesn't support this functionality. This error is returned if the API is called with a non-VR device.
- **TOBII_ERROR_INTERNAL**
Some unexpected internal error occurred. This error should normally not be returned, so if it is, please contact
the support.
- **TOBII_ERROR_CALLBACK_IN_PROGRESS**
The function failed because it was called from within a callback triggered from an API call such as
tobii_device_process_callbacks(), tobii_calibration_retrieve(), tobii_enumerate_illumination_modes(),
or tobii_license_key_retrieve().
Calling tobii_get_lens_configuration from within a callback function is not supported.
### See also
tobii_set_lens_configuration()
### Example
@code{.c}
#include <tobii/tobii_wearable.h>
#include <stdio.h>
#include <assert.h>
static void url_receiver( char const* url, void* user_data )
{
char* buffer = (char*)user_data;
if( *buffer != '\0' ) return; // only keep first value
if( strlen( url ) < 256 )
strcpy( buffer, url );
}
int main()
{
tobii_api_t* api;
tobii_error_t error = tobii_api_create( &api, NULL, NULL );
assert( error == TOBII_ERROR_NO_ERROR );
char url[ 256 ] = { 0 };
error = tobii_enumerate_local_device_urls( api, url_receiver, url );
assert( error == TOBII_ERROR_NO_ERROR && *url != '\0' );
tobii_device_t* device;
error = tobii_device_create( api, url, &device );
assert( error == TOBII_ERROR_NO_ERROR );
tobii_lens_configuration_t lens_config;
error = tobii_get_lens_configuration( device, &lens_config );
assert( error == TOBII_ERROR_NO_ERROR );
printf( "VR lens offset (left): (%f, %f, %f)\n",
lens_config.left_xyz[ 0 ],
lens_config.left_xyz[ 1 ],
lens_config.left_xyz[ 2 ] );
printf( "VR lens offset (right): (%f, %f, %f)\n",
lens_config.right_xyz[ 0 ],
lens_config.right_xyz[ 1 ],
lens_config.right_xyz[ 2 ] );
error = tobii_device_destroy( device );
assert( error == TOBII_ERROR_NO_ERROR );
error = tobii_api_destroy( api );
assert( error == TOBII_ERROR_NO_ERROR );
return 0;
}
@endcode
*/
/**
@fn TOBII_API tobii_error_t TOBII_CALL tobii_set_lens_configuration( tobii_device_t* device, tobii_lens_configuration_t const* lens_config );
@ingroup tobii_wearable
tobii_set_lens_configuration
----------------------------
### Function
Sets the current lens configuration in the tracker.
### Syntax
#include <tobii/tobii_wearable.h>
tobii_error_t TOBII_CALL tobii_set_lens_configuration( tobii_device_t* device,
tobii_lens_configuration_t const* lens_config );
### Remarks
*device* must be a pointer to a valid tobii_device_t instance as created by calling tobii_device_create or
tobii_device_create_ex.
*lens_config* must be a pointer to a valid tobii_lens_configuration_t. Upon success, the values have been written to the
tracker. They should correspond to the physical attributes of the headset that they represent.
- *left*
An array of three floats, for the x, y and z offset of the left lens in the headset, given in millimeters.
- *right*
An array of three floats, for the x, y and z offset of the right lens in the headset, given in millimeters.
### Return value
If the operation is successful, tobii_get_lens_configuration() returns **TOBII_ERROR_NO_ERROR**. If the call
fails, tobii_get_lens_configuration returns one of the following:
- **TOBII_ERROR_INVALID_PARAMETER**
The *device* or *lens_config* parameter was passed in as NULL.
- **TOBII_ERROR_INSUFFICIENT_LICENSE**
The provided license does not permit this operation.
- **TOBII_ERROR_NOT_SUPPORTED**
The device doesn't support this functionality. This error is returned if the API is called with a non-VR device.
- **TOBII_ERROR_CONNECTION_FAILED**
The connection to the device was lost. Call tobii_device_reconnect() to re-establish connection.
- **TOBII_ERROR_INTERNAL**
Some unexpected internal error occurred. This error should normally not be returned, so if it is, please contact
the support.
- **TOBII_ERROR_CALLBACK_IN_PROGRESS**
The function failed because it was called from within a callback triggered from an API call such as
tobii_device_process_callbacks(), tobii_calibration_retrieve(), tobii_enumerate_illumination_modes(),
or tobii_license_key_retrieve().
Calling tobii_set_lens_configuration from within a callback function is not supported.
### See also
tobii_get_lens_configuration()
### Example
@code{.c}
#include <tobii/tobii_wearable.h>
#include <stdio.h>
#include <assert.h>
static void url_receiver( char const* url, void* user_data )
{
char* buffer = (char*)user_data;
if( *buffer != '\0' ) return; // only keep first value
if( strlen( url ) < 256 )
strcpy( buffer, url );
}
int main()
{
tobii_api_t* api;
tobii_error_t error = tobii_api_create( &api, NULL, NULL );
assert( error == TOBII_ERROR_NO_ERROR );
char url[ 256 ] = { 0 };
error = tobii_enumerate_local_device_urls( api, url_receiver, url );
assert( error == TOBII_ERROR_NO_ERROR && *url != '\0' );
tobii_device_t* device;
error = tobii_device_create( api, url, &device );
assert( error == TOBII_ERROR_NO_ERROR );
tobii_lens_configuration_writable_t writable;
error = tobii_lens_configuration_writable( device, &writable );
assert( error == TOBII_ERROR_NO_ERROR );
if( writable == TOBII_LENS_CONFIGURATION_WRITABLE )
{
tobii_lens_configuration_t lens_config;
//Add 32 mm offset for each lens on the X-axis
lens_config.left_xyz[ 0 ] = 32.0;
lens_config.right_xyz[ 0 ] = -32.0;
lens_config.left_xyz[ 1 ] = 0.0;
lens_config.right_xyz[ 1 ] = 0.0;
lens_config.left_xyz[ 2 ] = 0.0;
lens_config.right_xyz[ 2 ] = 0.0;
error = tobii_set_lens_configuration( device, &lens_config );
assert( error == TOBII_ERROR_NO_ERROR );
}
else
printf( "Unable to write lens configuration to tracker\n" );
error = tobii_device_destroy( device );
assert( error == TOBII_ERROR_NO_ERROR );
error = tobii_api_destroy( api );
assert( error == TOBII_ERROR_NO_ERROR );
return 0;
}
@endcode
*/
/**
@fn TOBII_API tobii_error_t TOBII_CALL tobii_lens_configuration_writable( tobii_device_t* device, tobii_lens_configuration_writable_t* writable );
@ingroup tobii_wearable
tobii_lens_configuration_writable
---------------------------------
### Function
Query the tracker whether it is possible to write a new lens configuration to it or not.
### Syntax
#include <tobii/tobii_wearable.h>
tobii_error_t TOBII_CALL tobii_lens_configuration_writable( tobii_device_t* device,
tobii_lens_configuration_writable_t* writable );
### Remarks
*device* must be a pointer to a valid tobii_device_t instance as created by calling tobii_device_create or
tobii_device_create_ex.
*writable* must be a pointer to a valid tobii_lens_configuration_writable_t.
On success, *writable* will be assigned a value that tells whether the tracker can write a new lens configuration.
**TOBII_LENS_CONFIGURATION_WRITABLE** if it is writable and **TOBII_LENS_CONFIGURATION_NOT_WRITABLE** if not.
### Return value
If the operation is successful, tobii_lens_configuration_writable() returns **TOBII_ERROR_NO_ERROR**. If the call
fails, tobii_lens_configuration_writable returns one of the following:
- **TOBII_ERROR_INVALID_PARAMETER**
The *device* or *writable* parameter was passed in as NULL.
- **TOBII_ERROR_CONNECTION_FAILED**
The connection to the device was lost. Call tobii_device_reconnect() to re-establish connection.
- **TOBII_ERROR_INTERNAL**
Some unexpected internal error occurred. This error should normally not be returned, so if it is, please contact
the support.
- **TOBII_ERROR_CALLBACK_IN_PROGRESS**
The function failed because it was called from within a callback triggered from an API call such as
tobii_device_process_callbacks(), tobii_calibration_retrieve(), tobii_enumerate_illumination_modes(),
or tobii_license_key_retrieve().
Calling tobii_lens_configuration_writable from within a callback function is not supported.
### See also
tobii_get_lens_configuration(), tobii_set_lens_configuration()
*/

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 KiB

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save