TobiiGlasses2SDK
 All Classes Namespaces Files Functions Variables
Public Member Functions | Static Public Member Functions | Static Public Attributes
Tobii::GlassesSDK Class Reference

GlassesSDK handles Tobii Glasses 2 communications. More...

#include <TobiiGlassesSDK.h>

List of all members.

Public Member Functions

 GlassesSDK (const char *glassesIPAddress="192.168.71.50", unsigned int bufferSize=10)
 Constructor will setup glasses.
 ~GlassesSDK ()
 Destructor will clean and delete every instance.
void setVideoCallback (std::function< void(cv::Mat &, const int64_t) > func)
 setVideoCallback
void setDataCallback (std::function< void(std::string &) >)
 setDataCallback
void setDataFilledCallback (std::function< void(Data &data, unsigned int sizeBuffer, char flag)>)
 setDataCallback
bool discovery (bool setSyncDate)
 discovery
void livestream (int flag)
 livestream
void showServices ()
 showServices
std::string listProjects ()
 listProjects
std::string createParticipant (const char *project_id)
 createParticipant
std::string createCalibration (const char *project_id, const char *participant_id)
 createCalibration
std::string startCalibration (const char *calibration_id)
 startCalibration
std::string stopCalibration (const char *calibration_id)
 stopCalibration
std::string wait_for_status (const std::string &api_action, const std::string &key, const std::vector< std::string > &refvals)
 wait_for_status
bool calibrate (const std::string &calibration_id)
 calibrate
std::string listRecordings ()
 listRecordings
std::string showRecording (const char *recording_id)
 showRecording
std::string createRecording (const char *participant_id)
 createRecording
std::string startRecording (const char *recording_id)
 startRecording
std::string stopRecording (const char *recording_id)
 stopRecording
void stopLiveStream ()
 stopLiveStream

Static Public Member Functions

static uint64_t getTimeStamp ()
 getTimeStamp
static void timestamp2date (uint64_t t, std::string &)
 timestamp2date
static void date2timestamp (const std::string &datestr, uint64_t *t)
 date2timestamp
static void JAULA_traverse (JAULA::Value *val, int level=0)
 JAULA_traverse.

Static Public Attributes

static const char HTTP_HEADER_JSON = 0x01

Detailed Description

GlassesSDK handles Tobii Glasses 2 communications.

It is working with Network API and Streamer API from the same package. This class provide some methods to easily retrieve information from the Tobii Glasses 2 using video callback and data callback functions for the livestream or simply http requests giving json responses from the Tobii.


Constructor & Destructor Documentation

Tobii::GlassesSDK::GlassesSDK ( const char *  glassesIPAddress = "192.168.71.50",
unsigned int  bufferSize = 10 
)

Constructor will setup glasses.

Parameters:
constchar * glasses's IP address.
unsignedint the SDK buffer size.

Member Function Documentation

bool Tobii::GlassesSDK::calibrate ( const std::string &  calibration_id)

calibrate

Start a calibration and return if the calibration succeeded or not.

Parameters:
calibration_idthe calibration we want to start.
Returns:
true if calibration succeed, false if not.
std::string Tobii::GlassesSDK::createCalibration ( const char *  project_id,
const char *  participant_id 
)

createCalibration

Create a calibration for a participant and a project id.

Parameters:
project_idThe calibration will be created within the project with this id.
participant_idThe calibration will be linked with the participant with this id.
Returns:
JSON string with the calibration information.
std::string Tobii::GlassesSDK::createParticipant ( const char *  project_id)

createParticipant

Create a participant on the Tobii Glasses 2

Parameters:
project_idThe participant will be created within the project with this id.
Returns:
JSON string with the participant information.
std::string Tobii::GlassesSDK::createRecording ( const char *  participant_id)

createRecording

Create a recording on the Tobii Glasses 2

Parameters:
participant_idthe recording will be created for this participant.
Returns:
JSON string with the recording information.
void Tobii::GlassesSDK::date2timestamp ( const std::string &  datestr,
uint64_t *  t 
) [static]

date2timestamp

Convert a string date to timestamp.

Parameters:
date: string date formatted.
[out]timestamp: a timestamp in microseconds.
bool Tobii::GlassesSDK::discovery ( bool  setSyncDate)

discovery

Will launch a discovery over the network and will try to find a single Tobii Glasses.

Parameters:
setSyncDate: if true, will give the actual computer timestamp to the Tobii for synchronization.
Returns:
true if a Tobii Glasses 2 is discovered.
uint64_t Tobii::GlassesSDK::getTimeStamp ( ) [static]

getTimeStamp

Give the timestamp since System Epoch.

Returns:
timestamp in microseconds
void Tobii::GlassesSDK::JAULA_traverse ( JAULA::Value *  val,
int  level = 0 
) [static]

JAULA_traverse.

Will print to the stdout the content of the JAULA::Value which is json parsed with the JAULA parser.

listProjects

Will list the projects on the Tobii Glasses 2

Returns:
JSON string with the projects list.

listRecordings

Will list the recordings on the Tobii Glasses 2

Returns:
JSON string with the recordings list.
void Tobii::GlassesSDK::livestream ( int  flag)

livestream

Will livestream the glasses, this method will retrieve information from Tobii Glasses on livestream until the end.

Parameters:
flag: TOBII_LIVE_ON_WINDOW will call Streamer::run function, TOBII_LIVE_ON_OPENCV will call Streamer::runCV which is necessary to use the videoCallback for video frame retrieval.
void Tobii::GlassesSDK::setDataCallback ( std::function< void(std::string &) >  func)

setDataCallback

Will set the data callback.

Parameters:
func: the function address.
void Tobii::GlassesSDK::setDataFilledCallback ( std::function< void(Data &data, unsigned int sizeBuffer, char flag)>  func)

setDataCallback

Will set the data callback. This callback is called each time the buffer is filled with a complete data.

Parameters:
func: the function address.
void Tobii::GlassesSDK::setVideoCallback ( std::function< void(cv::Mat &, const int64_t) >  func)

setVideoCallback

Will set the video callback by calling the setter of Streamer API instance.

Parameters:
func: the function address.
std::string Tobii::GlassesSDK::showRecording ( const char *  recording_id)

showRecording

Will give the recording information.

Parameters:
recording_idthe recording id.
Returns:
JSON string with the recording information.

showServices

This method will print on the standard output the html document that will give the list of Tobii services.

std::string Tobii::GlassesSDK::startCalibration ( const char *  calibration_id)

startCalibration

Start the calibration

Parameters:
calibration_idThe calibration with this id will be started.
Returns:
JSON string with the calibration information.
std::string Tobii::GlassesSDK::startRecording ( const char *  recording_id)

startRecording

Start a recording on the Tobii Glasses 2

Parameters:
participant_idthe recording that will be started.
Returns:
JSON string with the recording start information.
std::string Tobii::GlassesSDK::stopCalibration ( const char *  calibration_id)

stopCalibration

Stop the calibration

Parameters:
calibration_idThe calibration with this id will be stopped.
Returns:
JSON string with the calibration information.

stopLiveStream

Will stop the Tobii Glasses 2 SDK livestream. This one is highly recommended.

std::string Tobii::GlassesSDK::stopRecording ( const char *  recording_id)

stopRecording

Stop a recording on the Tobii Glasses 2

Parameters:
participant_idthe recording that will be stopped.
Returns:
JSON string with the recording stop information.
void Tobii::GlassesSDK::timestamp2date ( uint64_t  t,
std::string &  date 
) [static]

timestamp2date

Convert a timestamp to string date format.

Parameters:
timestamp: a timestamp in microseconds.
[out]date: string date formatted.
std::string Tobii::GlassesSDK::wait_for_status ( const std::string &  api_action,
const std::string &  key,
const std::vector< std::string > &  refvals 
)

wait_for_status

Will launch requests until the values of field key in the response matches the refvals.

Parameters:
api_actionthe url for the post request (the service uri).
keythe key element to test in the JSON answer.
refvalsthe reference values to match.
Returns:
the value matched.

Member Data Documentation

const char Tobii::GlassesSDK::HTTP_HEADER_JSON = 0x01 [static]

flag to set the application/json HTTP Header.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables