Page 2 of 2

Re: C++ EXAMPLE FOR EYE TRACKING

PostPosted: 28 Feb 2014, 18:22
by uril
Hi Mingxin,

Thank you very much for your help.
I have tested your new method of using average of the right and the left eye and it works perfectly for me.
I work for the research.


Uril.

Re: C++ EXAMPLE FOR EYE TRACKING

PostPosted: 28 Feb 2014, 18:26
by uril
Hi Mingxin,

Thank you very much for your help.
I have tested your new method of using average of the right and the left eye and it works perfectly for me.
I work for the research.


Uril.

Re: C++ EXAMPLE FOR EYE TRACKING

PostPosted: 28 Feb 2014, 19:53
by mingxinbit
Hi Uril,

It is my pleasure.

Maybe we can further communication about your and my research.

Currently, I plan to use the eye gaze to control robot movement. What about you?

My E-mail: mingxinbit@gmail.com, we can discuss something through E-mail.

I am now studying in Northeastern University at Boston.

Thank you!

MIngxin

Re: C++ EXAMPLE FOR EYE TRACKING

PostPosted: 24 Apr 2014, 05:16
by ryklin
What is the name of the .lib file to link to? Where is it located?

Re: C++ EXAMPLE FOR EYE TRACKING

PostPosted: 22 Sep 2014, 09:05
by Tingjie1005
Hi,

I have followed the above steps.

Code: Select all
/******  MyGaze.h  ******/
#ifndef _MY_GAZE_
#define _MY_GAZE_

#include <gazeapi.h>
#include <windows.h>
#include <iostream>

using namespace std;

class MyGaze : public gtl::IGazeListener
{
public:
   MyGaze();
   ~MyGaze();

   void on_gaze_data( gtl::GazeData const &gazeData );

private:
   gtl::GazeApi mApi;
};

#endif

/******MyGaze.cpp******/
#include "MyGaze.h"
MyGaze::MyGaze()
{
   // Connect to the server in push mode on the default TCP port (6555)
   if( mApi.connect( true ) )
   {
      // Enable GazeData notifications
      mApi.add_listener( *this );
      if ( mApi.is_connected() )
      {
         printf("Connected!!\n");

                        // Set screen
         gtl::Screen screen;
         screen.set( 1, 1920, 1080, 0.5003, 0.2814 );
         mApi.set_screen( screen );
      }
   }
}

MyGaze::~MyGaze()
{
   mApi.remove_listener( *this );
   mApi.disconnect();
}

void MyGaze::on_gaze_data( gtl::GazeData const & gazeData )
{
   printf( "state = %d\n", gazeData.state );

   if( gazeData.state & gtl::GazeData::GD_STATE_TRACKING_GAZE )
   {
      gtl::Point2D const & smoothedCoordinates = gazeData.avg;
   
                // Move GUI point, do hit-testing, log coordinates, etc.

      Sleep(1000);
      gtl::Point2D const & smoothedCoordinatesLeftEye = gazeData.lefteye.avg; // smoothed data from left eye
      gtl::Point2D const & smoothedCoordinatesRightEye=gazeData.righteye.avg; // smoothed data from right eye

      //center values for left and right eyes, respectively.
      cout << "x = " << (smoothedCoordinatesLeftEye.x+ smoothedCoordinatesRightEye.x)/2<< " y = " << (smoothedCoordinatesLeftEye.y+smoothedCoordinatesRightEye.y)/2 << endl;

      printf( "\n" );
   }
}

/******  Main.cpp  ******/
#include <stdio.h>
#include "MyGaze.h"

int main()
{
   MyGaze myGaze;
   gtl::GazeData gazeData;

   while (true)
   {
      Sleep(2000);
      //here you also can write the output function e.g. cout <<  or printf, of course, under the precondition of predefined coordinates variable in your class
      printf( "\n-----------------------------------------------------\n" );
   }

   getchar();
   return 0;
}


I have some questions.

1. Why the state of gazeData always becomes 4,6,8 or 16 suddenly and never returns to 7( there is GD_STATE_TRACKING_GAZE = 1 << 0) ? When it happened, I have to run your UI or your C# sample simultaniously to do "recalibration" so that the console can output from value of coordinates again.

2. When my project is running, does it have any problem that your EyeTribe UI or C# sample runs as well?

3. Why the EyeTribe UI often stops suddenly? The figure of the eyes stays in the same place without moving ( the EyeTribe Server still connected ) and the values of coordinates are 0. I need to restart both of them and recalibrate the eye tribe.

Re: C++ EXAMPLE FOR EYE TRACKING

PostPosted: 16 Mar 2015, 10:27
by 8484hui
Hi everyone,

i have a question to ask, how and what application you all program the eyetribe tracker using c++ coding? I am doing a project that requires track eye positioning on the computer screen, to know how long the eye stay at which part of the screen. So don't mind somebody can help me out.