Example #1
0
        private void CalculateGazeCoordinates(TrackData td)
        {
            GTPoint gazedCoordinatesLeft;
            GTPoint gazedCoordinatesRight = new GTPoint();
            GTPoint smoothedCoordinates;

            #region Monocular/Left eye

            calibration.PupilCenterLeft = trackData.PupilDataLeft.Center;

            if (Settings.Instance.Processing.TrackingGlints)
            {
                calibration.GlintConfigLeft = td.GlintDataLeft.Glints;
            }

            gazedCoordinatesLeft = calibration.GetGazeCoordinates(td, EyeEnum.Left);

            #endregion

            #region Binocular/Right eye

            if (Settings.Instance.Processing.TrackingMode == TrackingModeEnum.Binocular)
            {
                calibration.PupilCenterRight = td.PupilDataRight.Center;

                if (Settings.Instance.Processing.TrackingGlints)
                {
                    calibration.GlintConfigRight = td.GlintDataRight.Glints;
                }

                gazedCoordinatesRight = calibration.GetGazeCoordinates(td, EyeEnum.Right);
            }

            #endregion

            #region Smoothing/Eye movement state

            if (Settings.Instance.Processing.EyeMouseSmooth)
            {
                var p = new GTPoint(gazedCoordinatesLeft.X, gazedCoordinatesLeft.Y);

                if (Settings.Instance.Processing.TrackingMode == TrackingModeEnum.Binocular)
                {
                    if (gazedCoordinatesRight.Y != 0 && gazedCoordinatesRight.X != 0)
                    {
                        p.X += gazedCoordinatesRight.X;
                        p.Y += gazedCoordinatesRight.Y;
                        p.X  = p.X / 2;
                        p.Y  = p.Y / 2;
                    }
                }

                this.eyeMovement.CalculateEyeMovement(p);

                smoothedCoordinates = exponentialSmoother.Smooth(p);


                //if (this.eyeMovement.EyeMovementState == Classifier.EyeMovementStateEnum.Fixation)
                //    smoothedCoordinates = exponentialSmoother.Smooth(p);
                //else
                //{
                //    smoothedCoordinates = p;
                //    this.exponentialSmoother.Stop();
                //}
                trackData.EyeMovement = this.eyeMovement.EyeMovementState;
                gazeDataSmoothed.Set(smoothedCoordinates.X, smoothedCoordinates.Y, smoothedCoordinates.X, smoothedCoordinates.Y);
            }

            #endregion

            #region Set values, raise events

            // trigger OnGazeData events
            this.gazeDataRaw.Set(
                gazedCoordinatesLeft.X,
                gazedCoordinatesLeft.Y,
                gazedCoordinatesRight.X,
                gazedCoordinatesRight.Y);

            this.trackData.GazeDataRaw      = this.gazeDataRaw;
            this.trackData.GazeDataSmoothed = this.gazeDataSmoothed;

            // Trigger OnExtendedGazeData events
            this.gazeDazaExtended.Set(
                this.trackData.TimeStamp,
                this.gazeDataRaw.GazePositionX,
                this.gazeDataRaw.GazePositionY,
                this.trackData.PupilDataLeft.Diameter,
                this.trackData.PupilDataRight.Diameter);

            #endregion
        }
Example #2
0
        private void CalculateGazeCoordinates(TrackData td)
        {
            GTPoint gazedCoordinatesLeft;
            GTPoint gazedCoordinatesRight = new GTPoint();
            GTPoint smoothedCoordinates;

            #region Monocular/Left eye

            calibration.PupilCenterLeft = trackData.PupilDataLeft.Center;

            if (GTSettings.Current.Processing.TrackingGlints)
            {
                calibration.GlintConfigLeft = td.GlintDataLeft.Glints;
            }

            gazedCoordinatesLeft = calibration.GetGazeCoordinates(td, EyeEnum.Left);

            #endregion

            #region Binocular/Right eye

            if (GTSettings.Current.Processing.TrackingMode == TrackingModeEnum.Binocular)
            {
                calibration.PupilCenterRight = td.PupilDataRight.Center;

                if (GTSettings.Current.Processing.TrackingGlints)
                {
                    calibration.GlintConfigRight = td.GlintDataRight.Glints;
                }

                gazedCoordinatesRight = calibration.GetGazeCoordinates(td, EyeEnum.Right);
            }

            #endregion

            #region Smoothing/Eye movement state

            if (GTSettings.Current.Processing.EyeMouseSmooth)
            {
                var p = new GTPoint(gazedCoordinatesLeft.X, gazedCoordinatesLeft.Y);

                if (GTSettings.Current.Processing.TrackingMode == TrackingModeEnum.Binocular)
                {
                    if (gazedCoordinatesRight.Y != 0 && gazedCoordinatesRight.X != 0)
                    {
                        p.X += gazedCoordinatesRight.X;
                        p.Y += gazedCoordinatesRight.Y;
                        p.X  = p.X / 2;
                        p.Y  = p.Y / 2;
                    }
                }

                this.eyeMovement.CalculateEyeMovement(p);

                if (this.eyeMovement.EyeMovementState == Classifier.EyeMovementStateEnum.Fixation)
                {
                    smoothedCoordinates = exponentialSmoother.Smooth(p);
                }
                else
                {
                    smoothedCoordinates = p;
                    this.exponentialSmoother.Stop();
                }
                trackData.EyeMovement = this.eyeMovement.EyeMovementState;
                gazeDataSmoothed.Set(smoothedCoordinates.X, smoothedCoordinates.Y, smoothedCoordinates.X, smoothedCoordinates.Y);
            }

            #endregion

            #region Set values, raise events

            // trigger OnGazeData events
            gazeDataRaw.Set(gazedCoordinatesLeft.X, gazedCoordinatesLeft.Y, gazedCoordinatesRight.X, gazedCoordinatesRight.Y);

            // Sends values via the UDP server directly
            if (server.IsStreamingGazeData)
            {
                if (server.SendSmoothedData)
                {
                    server.SendGazeData(gazeDataSmoothed.GazePositionX, gazeDataSmoothed.GazePositionY);
                }
                else
                {
                    // Send avg. value
                    server.SendGazeData(gazeDataRaw.GazePositionX, gazeDataRaw.GazePositionY);
                }
            }

            trackData.GazeDataRaw      = gazeDataRaw;
            trackData.GazeDataSmoothed = gazeDataSmoothed;

            #endregion
        }