ATUAV_RT.FixationDetector.GazeDataReceivedSynchronized C# (CSharp) Method

GazeDataReceivedSynchronized() protected method

Forwards 2D gaze points to fixation detector. Gaze points are only forwarded if CPU and Eyetracker clocks are synchronized and validity is < 2. If both eyes are valid gaze point coordinates are averaged, if only one eye is valid, only that eye's gaze point is used.
protected GazeDataReceivedSynchronized ( object sender, GazeDataEventArgs e ) : void
sender object
e GazeDataEventArgs GazeDataItem to process
return void
        protected override void GazeDataReceivedSynchronized(object sender, GazeDataEventArgs e)
        {
            // ignore gaze data with low validity
            if (e.GazeDataItem.LeftValidity < 2 || e.GazeDataItem.RightValidity < 2)
            {
                // convert timestamp
                long microseconds = e.GazeDataItem.TimeStamp;
                int milliseconds = (int)(microseconds / 1000);
                milliseconds -= getTimestampOffset(milliseconds);
                int time = milliseconds;
                if (((microseconds / 100) % 10) >= 5) time++; // round

                // convert normalized screen coordinates (float between [0 - 1]) to pixel coordinates
                // coordinates (0, 0) designate the top left corner
                double leftX = e.GazeDataItem.LeftGazePoint2D.X * SCREEN_WIDTH;
                double leftY = e.GazeDataItem.LeftGazePoint2D.Y * SCREEN_HEIGHT;
                double rightX = e.GazeDataItem.RightGazePoint2D.X * SCREEN_WIDTH;
                double rightY = e.GazeDataItem.RightGazePoint2D.Y * SCREEN_HEIGHT;

                if (e.GazeDataItem.LeftValidity < 2 && e.GazeDataItem.RightValidity < 2)
                {
                    // average left and right eyes
                    int x = (int)((leftX + rightX) / 2);
                    int y = (int)((leftY + rightY) / 2);
                    fixationDetector.addPoint(time, x, y);
                }
                else if (e.GazeDataItem.LeftValidity < 2)
                {
                    // use only left eye
                    fixationDetector.addPoint(time, (int)leftX, (int)leftY);
                }
                else if (e.GazeDataItem.RightValidity < 2)
                {
                    // use only right eye
                    fixationDetector.addPoint(time, (int)rightX, (int)rightY);
                }
            }
        }

Same methods

FixationDetector::GazeDataReceivedSynchronized ( object sender, GazeDataItem gazePoint ) : void