Ejemplo n.º 1
0
        protected override GazePoint Feed(GazePoint aGazePoint)
        {
            if (iCurrentFixation == null)
            {
                iCurrentFixation = aGazePoint;
            }
            else if (iCurrentFixation != null && iBufferedPoint != null)
            {
                double distCF = Dist(iCurrentFixation, aGazePoint);
                double distBP = Dist(iBufferedPoint, aGazePoint);
                if (distCF < distBP)
                {
                    if (distCF < iThreshold)
                    {
                        iCurrentFixation = GetFixation(iOrgGazePoints, aGazePoint);
                        iBufferedPoint = null;
                    }
                    else
                    {
                        iBufferedPoint = aGazePoint;
                        iCurrentFixation = GetFixation(iOrgGazePoints, null);
                    }
                }
                else
                {
                    if (distBP < iThreshold)
                    {
                        iOrgGazePoints.clear();
                        iOrgGazePoints.push(iBufferedPoint);
                        iCurrentFixation = GetFixation(iOrgGazePoints, aGazePoint);
                        iBufferedPoint = null;
                    }
                    else
                    {
                        iCurrentFixation = aGazePoint;//iBufferedPoint;
                        iBufferedPoint = aGazePoint;
                    }
                }
            }
            else
            {
                double distCF = Dist(iCurrentFixation, aGazePoint);
                if (distCF > iThreshold)
                {
                    iBufferedPoint = aGazePoint;
                    iCurrentFixation = GetFixation(iOrgGazePoints, null);
                }
                else
                {
                    iCurrentFixation = GetFixation(iOrgGazePoints, aGazePoint);
                }
            }

            iCurrentFixation.Timestamp = aGazePoint.Timestamp;
            return iCurrentFixation;
        }
Ejemplo n.º 2
0
        public GazePoint GetFixation(GazeBuffer aHistory, GazePoint aNewPoint, int aWindowSize)
        {
            double x = 0.0;
            double y = 0.0;
            double count = 0.0;

            int w = 1;
            if (aHistory != null)
            {
                foreach (GazePoint pt in aHistory)
                {
                    if (aWindowSize > 0)
                    {
                        GazePoint refPoint = aNewPoint != null ? aNewPoint : aHistory.Last;
                        if (refPoint.Timestamp - pt.Timestamp > aWindowSize)
                            continue;
                    }
                    x += w * pt.X;
                    y += w * pt.Y;
                    count += w;
                    w++;
                }
            }
            if (aNewPoint != null)
            {
                x += w * aNewPoint.X;
                y += w * aNewPoint.Y;
                count += w;
            }

            if (count != 0.0)
            {
                x /= count;
                y /= count;
            }

            return new GazePoint((int)x, (int)y, 0);
        }
Ejemplo n.º 3
0
 public override void reset()
 {
     base.reset();
     iCurrentFixation = null;
     iBufferedPoint = null;
 }
Ejemplo n.º 4
0
 /*
 * Assigns gaze result to outGazeResult.
 * Returns true if data and parameters exist, false otherwise.
 */
 public GazePoint QueryGazePoint()
 {
     GazePoint gp = new GazePoint();
     PXCMFaceData_GazeData_QueryGazePoint(instance, gp);
     return gp;
 }
Ejemplo n.º 5
0
 protected GazePoint GetFixation(GazeBuffer aHistory, GazePoint aNewPoint)
 {
     return iProcessor.GetFixation(aHistory, aNewPoint, 0);
 }
Ejemplo n.º 6
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            alarm = new SoundPlayer(Properties.Resources.beep01);
            //alarm.Play();
            loudAlarm = new SoundPlayer(Properties.Resources.loudAlarm);
            //loudAlarm.Play();
            stateTransition = new SoundPlayer(Properties.Resources.flip);
            //stateTransition.Play();
            //stateTransition.PlayLooping();

            sentencesList = new List <string>(); //list of sentences to be written during the test
            try
            {                                    // Open the text file using a stream reader.
                using (StreamReader sr = new StreamReader("sentencas_de_teste.txt"))
                {
                    string line;
                    do
                    {
                        line = sr.ReadLine();
                        sentencesList.Add(line);
                    } while (line != null);

                    //sentencesList has all the test sentences inside of it
                    sentencesList.RemoveAt(sentencesList.Count - 1);

                    sentencesList.Shuffle();
                    //foreach(string x in sentencesList)
                    //{
                    //    Console.WriteLine(x);
                    //}
                }
            }
            catch
            {
                Console.WriteLine("The file could not be read:");
            }

            //initial system values
            composition     = "-";
            isCancelled     = false;
            charToPrint     = "";
            primaryKeyboard = true;
            blockType       = 0;
            isBlocked       = false;
            //suggestionLabel = new Label[4];

            changeObjectsSize();
            //initialize the Suggester
            Suggester.initializeSuggester();
            suggestionsList = new List <string>();
            currentWord     = "";
            //every 2 seconds after the keyboardTimer has started, the changeKeyboard function will be called
            keyboardTimer.Interval = 2000;
            keyboardTimer.Elapsed += new ElapsedEventHandler(changeKeyboard);

            dataTimer.Start();
            dataTimer2.Start();

            startNewSentence(); //first sentence to be written during tests is shown to the user


            if (IS_USING_CAMERA)
            {
                Mouse.OverrideCursor = Cursors.None; //remove mouse
                                                     //EyeTracker data retrieval
                try
                {
                    gp = new GazePoint();
                }
                catch
                {
                    Console.WriteLine("No camera found! Mouse mode! :)");
                }
            }
        }
Ejemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
#if DEBUG
        gazePoint = TobiiAPI.GetGazePoint();
        Debug.Log("X: " + gazePoint.Screen.x + ", Y: " + gazePoint.Screen.y);
#else
        if (initLED)
        {
            // Turn on LED
            emgHelper.setLED(true);
            initLED = false;
        }
        if (finished)
        {
            // Debug.Log("Complete!");

            this.performanceAnalytics.saveData("performance.csv");
            AppHelper.Quit();
        }
        else
        {
            if (newTarget)
            {
                // Enable
                var gameObj = targets[currentTarget];
                gameObj.SetActive(true);

                // Make it visible
                gameObj.GetComponent <TargetLogic>().showTarget();
                newTarget = false;
            }
            else
            {
                // Grab the current target
                string objName = "Target" + currentTarget;
                var    gameObj = GameObject.Find(objName);

                if (gameObj.GetComponent <TargetLogic>().isClicked())
                {
                    // Store data into analytics class

                    performanceAnalytics.addDataPoint(currentTarget, gameObj.GetComponent <TargetLogic>().sw_click.latency());
                    performanceAnalytics.addDataPoint(currentTarget, gameObj.GetComponent <TargetLogic>().sw_gaze.latency());
                    performanceAnalytics.addDataPoint(currentTarget, gameObj.GetComponent <TargetLogic>().distFromGaze);
                    performanceAnalytics.addDataPoint(currentTarget, gameObj.GetComponent <TargetLogic>().getX());
                    performanceAnalytics.addDataPoint(currentTarget, gameObj.GetComponent <TargetLogic>().getY());

                    gameObj.SetActive(false);
                    StartCoroutine(Delay(5.0f));
                    newTarget = true;
                    currentTarget++;
                }
            }

            if (currentTarget >= MAX_TARGETS)
            {
                finished = true;
                // Turn off LED
                emgHelper.setLED(false);
            }
        }
#endif
    }
Ejemplo n.º 8
0
    private void UpdateGazeBubblePosition(GazePoint gazePoint)
    {
        Vector3 gazePointInWorld = ProjectToPlaneInWorld(gazePoint);

        transform.position = Smoothify(gazePointInWorld);
    }
Ejemplo n.º 9
0
 private bool IsNotTooOld(GazePoint gazePoint)
 {
     return((Time.unscaledTime - gazePoint.Timestamp) < MaxVisibleDurationInSeconds);
 }
Ejemplo n.º 10
0
    // Use this for initialization
    void Start()
    {
        words        = new ArrayList();
        pages        = new List <ArrayList>();
        maxRowlength = 120;
        pos          = TobiiAPI.GetGazePoint();
        try
        {
            // Create an instance of StreamReader to read from a file.
            // The using statement also closes the StreamReader.
            using (StreamReader sr = new StreamReader("C:/Users/Djidjelly Siclait/Desktop/Hello.txt"))
            {
                string line;

                // Read and display lines from the file until
                // the end of the file is reached.
                while ((line = sr.ReadLine()) != null)
                {
                    words.AddRange(line.Split(' '));
                }
            }

            fillStatistics();
            print("average Length: " + averageWordLength);
            print("Longest word length: " + longestWord);

            numPages = (int)Math.Ceiling((decimal)words.Count / (decimal)(maxRowlength * maxLines));
            print(words.Count);
            print(numPages);

            int       j       = 0;
            int       counter = 1;
            ArrayList buffer  = new ArrayList();

            foreach (String s in words)
            {
                if (counter < numPages) // first and next pages
                {
                    if (j < (maxRowlength * maxLines) - 1)
                    {
                        buffer.Add(s);
                        j++;
                    }
                    else
                    {
                        buffer.Add(s);
                        print("buffer = " + buffer.Count);
                        pages.Add(buffer);
                        j      = 0; counter++;
                        buffer = new ArrayList();
                    }
                }
                else // last page
                {
                    buffer.Add(s);
                }
            }

            print("buffer = " + buffer.Count);
            pages.Add(buffer);

            print("Pages =" + pages.Count);
            currentpage = 0;
        }
        catch (Exception e)
        {
            // Let the user know what went wrong.
            Console.WriteLine("The file could not be read:");
            Console.WriteLine(e.Message);
        }

        init();
        AddItemToGrid(0);
    }