Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include <iostream>
#include <fstream>
#include <ctime>
#include "GazeConfirmConfig.h"
#include "gazeapi.h"
using namespace std;
class MyGaze : public gtl::IGazeListener
{
public:
MyGaze();
~MyGaze();
private:
// IGazeListener
void on_gaze_data( gtl::GazeData const & gaze_data );
private:
gtl::GazeApi m_api;
ofstream logfile;
};
// --- MyGaze implementation
MyGaze::MyGaze()
{
// Connect to the server in push mode on the default TCP port (6555)
if( m_api.connect( true ) )
{
// Enable GazeData notifications
m_api.add_listener( *this );
time_t t = time(NULL);
char mbstr[100];
strftime(mbstr, sizeof(mbstr), "%F-%T", localtime(&t));
string buf(mbstr);
logfile.open(buf.append(".txt"));
logfile << "timestamp" << "," << "fixation" << ","
<< "left.x" << "," << "left.y" << "," << "left.psize" << ","
<< "right.x" << "," << "right.y" << "," << "right.psize" << "\n";
}
}
MyGaze::~MyGaze()
{
logfile.close();
m_api.remove_listener( *this );
m_api.disconnect();
}
void MyGaze::on_gaze_data( gtl::GazeData const & gaze_data )
{
if( gaze_data.state & gtl::GazeData::GD_STATE_TRACKING_GAZE )
{
gtl::Point2D const & smoothedCoordinates = gaze_data.raw;
int timestamp = gaze_data.time;
gtl::Eye left = gaze_data.lefteye;
gtl::Eye right = gaze_data.righteye;
// Move GUI point, do hit-testing, log coordinates, etc.
logfile << timestamp << "," << gaze_data.fix << ","
<< left.raw.x << "," << left.raw.y << "," << left.psize << ","
<< right.raw.x << "," << right.raw.y << "," << right.psize << "\n";
cout << gaze_data.fix << "\n";
//cout << setw(15) << timestamp << "\t" << gaze_data.fix << "\t" << smoothedCoordinates.x <<
// "\t" << smoothedCoordinates.y << "\t" << left.psize << "\t" << right.psize << "\n";
}
}
int main (int argc, char *argv[])
{
MyGaze gaze;
while(true)
{
}
return 0;
}