예제 #1
0
        // Adds every point obtained from the EyeTracker to the list 'points' regardful of the page's offsets.
        static void lightlyFilteredGazeDataStream_Next(object sender, FixationEventArgs e)
        {
            if (!(double.IsNaN(e.X) && double.IsNaN(e.Y)))
            {
                // "Convert" the driver to be able to use javascript.
                IJavaScriptExecutor jsc = driver as IJavaScriptExecutor;

                if (driver != null)
                {
                    try
                    {
                        // Gets offset values using javascript.
                        int offsetY = Convert.ToInt32(jsc.ExecuteScript("return window.scrollY"));
                        int offsetX = Convert.ToInt32(jsc.ExecuteScript("return window.scrollX"));

                        // Adds offset values to each point obtained from Eyetracker.
                        points.Add(new PointF(Convert.ToSingle(e.X + offsetX), Convert.ToSingle(e.Y + offsetY)));
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex);
                        // If case of unexpected closure of the browser window.
                        DisposeAll();
                    }
                }
            }
        }
예제 #2
0
 private void RecordFixation(object s, FixationEventArgs e)
 {
     if (isFixationDataRecording)
     {
         fixations.Enqueue(new FixationEventArgs(e.EventType, e.X, e.Y, e.Timestamp));
     }
 }
예제 #3
0
        private void EyeXHost_FixationDataStream(object sender, FixationEventArgs args)
        {
            Point fixationPoint = new Point(args.X, args.Y);

            RunOnMainThread(() =>
            {
                FixationPoint = fixationPoint;
            });
        }
예제 #4
0
        public void HandleEyeFixationEvent(object sender, FixationEventArgs e)
        {
            //Console.WriteLine("Fixation ({3})point at\t{0:0.0}\t{1:0}\t\t{2}", e.X, e.Y, e.Timestamp, e.EventType);

            if (this.tcpServer.Connected && this.isFixationDataActive )
            {

                SendGaze((int)e.X, (int)e.Y, 0, TobiiGazeHandler.METHOD_FIXATION, new string[]{""+e.EventType});
            }
        }
예제 #5
0
        private void fixationEventHandler(object sender, FixationEventArgs e)
        {
            if (!double.IsNaN(e.X) && !double.IsNaN(e.Y))
            {
                eyeGazeAbsolute.X = (int)e.X;
                eyeGazeAbsolute.Y = (int)e.Y;
            }

            //this.pictureBox1.Invalidate();
            //this.pictureBox2.Invalidate();
            //this.pictureBox3.Invalidate();
        }
예제 #6
0
        private void fixationEventHandler(object sender, FixationEventArgs e)
        {
            if (!double.IsNaN(e.X) && !double.IsNaN(e.Y))
            {
                absoluteX = (int)e.X;
                absoluteY = (int)e.Y;

                //Find the closest word
                int squaredDist = 0;
                readWord = closestWord(relativeX, relativeY, out squaredDist);
                int thresholdMinDistSquare = 80 * 80;
                if (squaredDist < thresholdMinDistSquare)
                {
                    //If mode == tag cloud
                    if (mode == Mode.TagCLoud)
                    {
                        if (wordFrequency.ContainsKey(readWord.Text))
                        {
                            wordFrequency[readWord.Text]++;
                        }
                        else
                        {
                            wordFrequency.Add(readWord.Text, 1);
                        }
                        //sort the dictionary
                        //wordFrequency = wordFrequency.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);
                        //Invalidate the picturebox for calling pictureBox1_Paint again
                        this.pictureBoxWordle.Invalidate();
                    }
                    //Else if mode == Speech Synthesize
                    else
                    {
                        //Read the word only if the previous fixation is near the current one
                        if (Math.Abs(previousX - absoluteX) < 5 && Math.Abs(previousY - absoluteY) < 5 && readWord.Text != previousWord)
                        {
                            s.Speak(readWord.Text);
                            previousWord = readWord.Text;
                        }
                        previousX = absoluteX;
                        previousY = absoluteY;
                    }
                }
                else
                {
                    readWord = null;
                }
                this.labelRead.Invalidate();
                this.pictureBoxText.Invalidate();
            }
        }
예제 #7
0
파일: Gaze.cs 프로젝트: feugy/alfred
        /// <summary>
        /// Invoked when EyeX engine detect a gaze change
        /// </summary>
        /// <param name="source">EyeX original stream publishing this event</param>
        /// <param name="evt">Gaze event details, including current time and gaze position</param>
        protected void OnGazeChange(Object source, FixationEventArgs evt)
        {
            if (evt.Timestamp - last > duration)
            {
                var end = new Point((int)evt.X, (int)evt.Y);
                last = evt.Timestamp;
                positions.Clear();

                // compute straight formula for interpolation
                var a = (double)(end.Y - Position.Y) / (end.X - Position.X);
                var b = Position.Y - a * Position.X;
                if (a == double.PositiveInfinity || a == double.NegativeInfinity)
                {
                    // vertical straight
                    var step = (double)(end.Y - Position.Y) / interpolated;
                    foreach (var i in Enumerable.Range(1, interpolated))
                    {
                        // interpolate enought points for the next interval
                        double y     = Position.Y + step * i;
                        var    added = new Point(Position.X, (int)y);
                        positions.Enqueue(cropToDisplay(added));
                    }
                }
                else
                {
                    // classical straight
                    var step = (double)(end.X - Position.X) / interpolated;
                    foreach (var i in Enumerable.Range(1, interpolated))
                    {
                        // interpolate enought points for the next interval
                        double x     = Position.X + step * i;
                        var    added = new Point((int)x, (int)(a * x + b));
                        positions.Enqueue(cropToDisplay(added));
                    }
                }
            }
        }
예제 #8
0
 void OnFixationPointNext(object sender, FixationEventArgs e)
 {
     RaiseGazeEvent(e.X, e.Y, e.Timestamp);
 }
예제 #9
0
 private void FixationDataStream_Next(object sender, FixationEventArgs e)
 {
     lock (fixation)
         fixation = e;
 }
예제 #10
0
 private void InvokeFixationEvent(object s, FixationEventArgs e)
 {
     FixationEvent.Invoke(s, e);
 }