Process gaze data and fixations for features using the EMDAT library. EMDAT is written in Python so IronPython is needed to host the Python code.
Inheritance: GazeDataSynchronizedHandler, WindowingHandler
Beispiel #1
0
        /// <summary>
        /// Connects to found eyetrackers, synchronizes CPU and eyetracker clocks, and attaches event handlers.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">Contains found EyetrackerInfo</param>
        private static void EyetrackerFound(object sender, EyetrackerInfoEventArgs e)
        {
            EyetrackerConnector connector = new EyetrackerConnector(e.EyetrackerInfo);

            connector.Connect();

            // sync CPU and Eyetracker clocks
            SyncManager syncManager = new SyncManager(clock, e.EyetrackerInfo, EventThreadingOptions.BackgroundThread);

            // detect fixations
            FixationDetector fixations = new FixationDetector(syncManager);

            connector.Eyetracker.GazeDataReceived += fixations.GazeDataReceived;

            if (Settings.ProcessorDefinitions.ContainsKey(connector.Info.ProductId))
            {
                foreach (EmdatProcessorSettings settings in Settings.ProcessorDefinitions[connector.Info.ProductId])
                {
                    EmdatProcessor processor = new EmdatProcessor(syncManager);
                    processor.CumulativeData = settings.Cumulative;
                    connector.Eyetracker.GazeDataReceived += processor.GazeDataReceived;
                    fixations.FixDetector.FixationEnd     += processor.FixationEnd;
                    Processors.Add(settings.ProcessorId, processor);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Connects to found eyetrackers, synchronizes CPU and eyetracker clocks, and attaches event handlers.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">Contains found EyetrackerInfo</param>
        static void EyetrackerFound(object sender, EyetrackerInfoEventArgs e)
        {
            EyetrackerConnector connector = new EyetrackerConnector(e.EyetrackerInfo);

            connector.Connect();

            // sync CPU and Eyetracker clocks
            SyncManager syncManager = new SyncManager(clock, e.EyetrackerInfo, EventThreadingOptions.BackgroundThread);

            // detect fixations
            FixationDetector fixations = new FixationDetector(syncManager);

            connector.Eyetracker.GazeDataReceived += fixations.GazeDataReceived;

            /*/ 1. print each event to console
             * ConsolePrinter printer = new ConsolePrinter(syncManager);
             * //connector.Eyetracker.GazeDataReceived += printer.GazeDataReceived;
             * fixations.FixDetector.FixationEnd += printer.FixationEnd;//*/

            /*/ 2. windowed print to console
             * WindowingConsolePrinter printer = new WindowingConsolePrinter(syncManager);
             * //connector.Eyetracker.GazeDataReceived += printer.GazeDataReceived;
             * fixations.FixDetector.FixationEnd += printer.FixationEnd;
             *
             * printer.StartWindow();
             * while (true)
             * {
             *  Thread.Sleep(windowDuration);
             *  printer.ProcessWindow(cumulativeWindows);
             * }//*/

            // 3. process windows with EMDAT
            EmdatProcessor processor = new EmdatProcessor(syncManager);

            if (aoiFilePath != null)
            {
                processor.AoiFilePath = aoiFilePath;
            }

            connector.Eyetracker.GazeDataReceived += processor.GazeDataReceived;
            fixations.FixDetector.FixationEnd     += processor.FixationEnd;

            processor.StartWindow();
            while (true)
            {
                Thread.Sleep(windowDuration);
                processor.ProcessWindow(cumulativeWindows);
            }//*/
        }
Beispiel #3
0
        private static int windowDuration = 3000; // ms

        #endregion Fields

        #region Methods

        /// <summary>
        /// Connects to found eyetrackers, synchronizes CPU and eyetracker clocks, and attaches event handlers.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">Contains found EyetrackerInfo</param>
        static void EyetrackerFound(object sender, EyetrackerInfoEventArgs e)
        {
            EyetrackerConnector connector = new EyetrackerConnector(e.EyetrackerInfo);
            connector.Connect();

            // sync CPU and Eyetracker clocks
            SyncManager syncManager = new SyncManager(clock, e.EyetrackerInfo, EventThreadingOptions.BackgroundThread);

            // detect fixations
            FixationDetector fixations = new FixationDetector(syncManager);
            connector.Eyetracker.GazeDataReceived += fixations.GazeDataReceived;

            /*/ 1. print each event to console
            ConsolePrinter printer = new ConsolePrinter(syncManager);
            //connector.Eyetracker.GazeDataReceived += printer.GazeDataReceived;
            fixations.FixDetector.FixationEnd += printer.FixationEnd;//*/

            /*/ 2. windowed print to console
            WindowingConsolePrinter printer = new WindowingConsolePrinter(syncManager);
            //connector.Eyetracker.GazeDataReceived += printer.GazeDataReceived;
            fixations.FixDetector.FixationEnd += printer.FixationEnd;

            printer.StartWindow();
            while (true)
            {
                Thread.Sleep(windowDuration);
                printer.ProcessWindow(cumulativeWindows);
            }//*/

            // 3. process windows with EMDAT
            EmdatProcessor processor = new EmdatProcessor(syncManager);
            if (aoiFilePath != null)
            {
                processor.AoiFilePath = aoiFilePath;
            }

            connector.Eyetracker.GazeDataReceived += processor.GazeDataReceived;
            fixations.FixDetector.FixationEnd += processor.FixationEnd;

            processor.StartWindow();
            while (true)
            {
                Thread.Sleep(windowDuration);
                processor.ProcessWindow(cumulativeWindows);
            }//*/
        }
Beispiel #4
0
        public Stream GetFeatures(string processorId, string callback)
        {
            MemoryStream ms = new MemoryStream();
            StreamWriter sw = new StreamWriter(ms);

            sw.Write(callback + "({");

            if (processorId != null)
            {
                EmdatProcessor processor = Program.Processors[processorId];
                if (processor != null && processor.CollectingData)
                {
                    processor.ProcessWindow();
                    IDictionary <Object, Object> features = processor.Features;

                    // sort by key
                    String[] sortedFeatures = new String[features.Count];
                    features.Keys.CopyTo(sortedFeatures, 0);
                    Array.Sort(sortedFeatures);

                    // convert to JSON
                    StringBuilder sb = new StringBuilder();
                    foreach (String feature in sortedFeatures)
                    {
                        sb.Append("\"" + feature + "\": \"" + features[feature] + "\",");
                    }

                    // remove trailing comma
                    if (sb.Length > 0)
                    {
                        sb.Length--;
                    }
                    sw.Write(sb.ToString());
                }
            }

            sw.Write("})");
            sw.Flush();
            ms.Position = 0;
            return(ms);
        }
Beispiel #5
0
        public Stream Condition(string processorId, string condition, string callback)
        {
            MemoryStream ms = new MemoryStream();
            StreamWriter sw = new StreamWriter(ms);

            sw.Write(callback + "(");
            EmdatProcessor processor = Program.Processors[processorId];

            if (processor != null && processor.CollectingData && processor.Conditions[condition] != null && processor.Conditions[condition].Met)
            {
                recordCondition(condition);
                sw.Write("true");
            }
            else
            {
                sw.Write("false");
            }
            sw.Write(")");
            sw.Flush();
            ms.Position = 0;
            return(ms);
        }
Beispiel #6
0
 public ShowIntervention(EmdatProcessor processor)
 {
     this.processor = processor;
 }
Beispiel #7
0
 public ConditionImp(string id, EmdatProcessor processor)
 {
     this.id = id;
     this.processor = processor;
 }
Beispiel #8
0
        /// <summary>
        /// Connects to found eyetrackers, synchronizes CPU and eyetracker clocks, and attaches event handlers.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">Contains found EyetrackerInfo</param>
        private static void EyetrackerFound(object sender, EyetrackerInfoEventArgs e)
        {
            EyetrackerConnector connector = new EyetrackerConnector(e.EyetrackerInfo);
            connector.Connect();

            // sync CPU and Eyetracker clocks
            SyncManager syncManager = new SyncManager(clock, e.EyetrackerInfo, EventThreadingOptions.BackgroundThread);

            // detect fixations
            FixationDetector fixations = new FixationDetector(syncManager);
            connector.Eyetracker.GazeDataReceived += fixations.GazeDataReceived;

            if (Settings.ProcessorDefinitions.ContainsKey(connector.Info.ProductId))
            {
                foreach (EmdatProcessorSettings settings in Settings.ProcessorDefinitions[connector.Info.ProductId])
                {
                    EmdatProcessor processor = new EmdatProcessor(syncManager);
                    processor.CumulativeData = settings.Cumulative;
                    connector.Eyetracker.GazeDataReceived += processor.GazeDataReceived;
                    fixations.FixDetector.FixationEnd += processor.FixationEnd;
                    Processors.Add(settings.ProcessorId, processor);
                }
            }
        }
Beispiel #9
0
 public ShowIntervention(EmdatProcessor processor)
 {
     this.processor = processor;
 }
Beispiel #10
0
 public ShowText(EmdatProcessor processor)
 {
     this.processor = processor;
 }
Beispiel #11
0
 public ShowText(EmdatProcessor processor)
 {
     this.processor = processor;
 }