/// <summary> /// Checks input data from variance calculation and raises appropriate event depending on this data and the CustomfixationDetectionStreams current state /// </summary> /// <param name="gazeVariation"></param> /// <param name="timestamp"></param> private void generateFixationState(GazePoint gazeVariation, double timestamp) { //Set pointer to next fixation data bucket. CustomFixationEventArgs cpe = null; //Check gaze data variation, current state and create appropriate event. Then set the CustomfixationDetectionStreams state. if (fixationState == EFixationStreamEventType.Waiting && gazeVariation.x < xFixationThreashold && gazeVariation.y < yFixationThreashold) { cpe = new CustomFixationEventArgs(EFixationStreamEventType.Start, timestamp, gPAverage.x, gPAverage.y); fixationState = EFixationStreamEventType.Middle; } else if (fixationState == EFixationStreamEventType.Middle && gazeVariation.x > xFixationThreashold && gazeVariation.y > yFixationThreashold) { cpe = new CustomFixationEventArgs(EFixationStreamEventType.End, timestamp, gPAverage.x, gPAverage.y); fixationState = EFixationStreamEventType.Waiting; } else if (fixationState == EFixationStreamEventType.Middle) { cpe = new CustomFixationEventArgs(EFixationStreamEventType.Middle, timestamp, gPAverage.x, gPAverage.y); } //raise the event. if (cpe != null) { onFixationStateChange(cpe); } }
//Method that raises fixation event. private void onFixationStateChange(CustomFixationEventArgs newFixation) { if (next != null) { next(this, newFixation); } }
/// <summary> /// Checks input data from variance calculation and raises appropriate event depending on this data and the CustomfixationDetectionStreams current state /// </summary> /// <param name="gazeVariation"></param> /// <param name="timestamp"></param> private void generateFixationState(GazePoint gazeVariation, double timestamp) { //Set pointer to next fixation data bucket. CustomFixationEventArgs cpe = null; //check where users gaze is, if it is less than yFixationScreenBoundary set yAdjustedThreashold to yFixationCutOffThreasholdWhenGazeAtTopOfScreen //To compensate for EyeX's poor accuracy when gazing near top edge of screen. double yAdjustedThreashold = gPAverage.Y < yFixationScreenBoundary && !ZoomerFixation ? yFixationCutOffThreasholdWhenGazeAtTopOfScreen : yFixationThreashold; //Check gaze data variation, current state and create appropriate event. Then set the CustomfixationDetectionStreams state. if (fixationState == EFixationStreamEventType.Waiting && gazeVariation.X < xFixationThreashold && gazeVariation.Y < yAdjustedThreashold) { cpe = new CustomFixationEventArgs(EFixationStreamEventType.Start, timestamp, gPAverage.X, gPAverage.Y); fixationState = EFixationStreamEventType.Middle; } else if (fixationState == EFixationStreamEventType.Middle && gazeVariation.X > xFixationThreashold && gazeVariation.Y > yAdjustedThreashold) { cpe = new CustomFixationEventArgs(EFixationStreamEventType.End, timestamp, gPAverage.X, gPAverage.Y); fixationState = EFixationStreamEventType.Waiting; } else if (fixationState == EFixationStreamEventType.Middle) { cpe = new CustomFixationEventArgs(EFixationStreamEventType.Middle, timestamp, gPAverage.X, gPAverage.Y); } //raise the event. if (cpe != null) { onFixationStateChange(cpe); } }
/// <summary> /// This method of is run on gaze events, checks if it is the beginning or end of a fixation and runs appropriate code. /// </summary> /// <param name="o"></param> /// <param name="fixationDataBucket"></param> private void detectFixation(object o, CustomFixationEventArgs fixationDataBucket) { //Check if FixationDetection needs to be monitoring CustomFixation data stream. if (fixationState == EFixationState.DetectingFixation) { GazePoint currentSmoothPoint; //If databucket state is the start of a fixation if (fixationDataBucket.Status == EFixationStreamEventType.Start) { fixationTimer.Start(); //increment timeout interval so a fixation doesn't get cut off. timeOutTimer.Interval += FixationDetectionTimeLength + FixationExtensionBuffer;; Console.WriteLine(timeOutTimer.Interval); fixationProgressStartTimeStamp = fixationDataBucket.TimeStamp; //Instantiate new point smoother, this clears out and previous in the ring buffer. pointSmootherWorker = new PointSmoother(pointSmootherBufferSize); Console.WriteLine("Fixation Begin X" + fixationDataBucket.X + " Y" + fixationDataBucket.Y); } //if fixation data is in the middle of a fixation, use the data returned to highlight progress and draw users current gaze location to the screen. if (fixationDataBucket.Status == EFixationStreamEventType.Middle) { //Check if point smoothing is required. if (usePointSmoother) { //Data smoothing being done in CustomFixationDectection, currentSmoothPoint = pointSmootherWorker.UpdateAndGetSmoothPoint(fixationDataBucket.X, fixationDataBucket.Y); xPosFixation = (int)Math.Floor(currentSmoothPoint.x); yPosFixation = (int)Math.Floor(currentSmoothPoint.y); } else { //Slightly smoothed data from the Customfixation data stream xPosFixation = (int)Math.Floor(fixationDataBucket.X); yPosFixation = (int)Math.Floor(fixationDataBucket.Y); } // calculateFixationProgressPercent(fixationDataBucket.TimeStamp); onFixationProgressEvent(fixationDataBucket.TimeStamp, xPosFixation, yPosFixation); } //if the fixation ends before the fixation timer completes, reset the fixation timer. if (fixationDataBucket.Status == EFixationStreamEventType.End) { fixationTimer.Stop(); //customfixStream.ResetFixationDetectionState(); //Debug Console.WriteLine("Fixation Stopped due to end datatype"); } } }