How to get xy coordinates from eye tracker...???

Forum for development in the C++ programming language.

How to get xy coordinates from eye tracker...???

Postby innoraj » 22 Sep 2015, 17:25

Hi,

Could any one suggest how to obtain x y coordinates from eye tracker...???
innoraj
 
Posts: 2
Joined: 23 Feb 2015, 17:26

Re: How to get xy coordinates from eye tracker...???

Postby innoraj » 22 Sep 2015, 17:43

#include "gazeapi.h"
#include "iostream"

float LeftEyeX, LeftEyeY, RightEyeX, RightEyeY;

using namespace std;

// --- MyGaze definition
class MyGaze : public gtl::IGazeListener
{
public:
MyGaze();
~MyGaze();
private:
// IGazeListener
void on_gaze_data( gtl::GazeData const & gaze_data );
private:
gtl::GazeApi m_api;
};

// --- 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 );
}
}

MyGaze::~MyGaze()
{
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 & smoothedCoordinatesLeftEye = gaze_data.lefteye.avg; // smoothed data from left eye
gtl::Point2D const & smoothedCoordinatesRightEye= gaze_data.righteye.avg; // smoothed data from right eye

LeftEyeX=smoothedCoordinatesLeftEye.x;
LeftEyeY=smoothedCoordinatesLeftEye.y;

RightEyeX=smoothedCoordinatesRightEye.x;
RightEyeY=smoothedCoordinatesRightEye.y;
//cout << "x = " << (LeftEyeX+ RightEyeX)/2<< " y = " << (LeftEyeY+RightEyeY)/2 << endl;
}
}

int main()
{

MyGaze on_gaze_data ;

while (1)
{
cout << "x = " << (LeftEyeX+ RightEyeX)/2<< " y = " << (LeftEyeY+RightEyeY)/2 << endl;
}

return 0;
}
innoraj
 
Posts: 2
Joined: 23 Feb 2015, 17:26


Return to C++