Page 1 of 1

I want to get coordinate data separately. How can I do?

PostPosted: 06 May 2015, 09:27
by tictoc3493
I just simply coded like below for printing out coordinate data.

Actually, it was thanks to someone who commented in this forum.

Code: Select all
#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;

// Move GUI point, do hit-testing, log coordinates, etc.
cout << "x = " << (LeftEyeX+ RightEyeX)/2<< " y = " << (LeftEyeY+RightEyeY)/2 << endl; //center values for left and right eyes, respectively.
}
}

int main()
{

MyGaze test;

while (1)
{

}

return 0;
}


but I want to get coordinate separately.
After getting 5 or some coordinate while I staring at a point, I want to average those data and go to next point.
like this

(5 coordinate data)->(avg1)->(5 coordinate data)->(avg2)->(using avg1 and avg2, make a vector)->(5 coordinate data)->(avg3)->.., so on
so, I want to make 4 vectors.
making vector data is simple procedure but getting coordinate separately is not easy for me.

please help :(