public void StartGazeDataStreams(GazePointCallback gazePointCallback, FixationCallback fixationCallback, EyePositionCallback eyePositionCallback) { if (gazePointCallback != null) { if (gazePointDataStream == null) { gazePointDataStream = eyeXHost.CreateGazePointDataStream(Tobii.EyeX.Framework.GazePointDataMode.Unfiltered); } gazePointDataStream.Next += InvokeGazePointEvent; GazePointEvent += gazePointCallback; GazePointEvent += RecordGazePoint; } if (fixationCallback != null) { if (fixationDataStream == null) { fixationDataStream = eyeXHost.CreateFixationDataStream(FixationDataMode.Sensitive); } fixationDataStream.Next += InvokeFixationEvent; FixationEvent += fixationCallback; FixationEvent += RecordFixation; } if (eyePositionCallback != null) { if (eyePositionDataStream == null) { eyePositionDataStream = eyeXHost.CreateEyePositionDataStream(); } eyePositionDataStream.Next += InvokeEyePositionEvent; EyePositionEvent += eyePositionCallback; EyePositionEvent += RecordEyePosition; } }
public TobiiGazeSource() { EyeXHost = new EyeXHost(); GazePointDataStream = EyeXHost.CreateGazePointDataStream(GazePointDataMode.Unfiltered); GazePointDataStream.Next += GazeData; EyeXHost.Start(); }
private void setupMainWindow() { DataContext = this; InitializeComponent(); eyeXHost = new EyeXHost(); eyeXHost.Start(); var fixationData = eyeXHost.CreateFixationDataStream(FixationDataMode.Sensitive); var gazeData = eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered); fixationData.Next += fixTrack; gazeData.Next += trackDot; if (ReceiverOn) { IPHostEntry ipHostInfo = Dns.GetHostByName(Dns.GetHostName()); IPAddress ipAddress = ipHostInfo.AddressList[0]; Receive_Status_Text.Text = "Receiving Data at\nIP:" + ipAddress.ToString(); Receive_Status_Text.Visibility = Visibility.Visible; } if (SenderOn) { SenderIP = defaultSenderIP; Share_Status_Text.Text = "Sharing Data to\nIP:" + SenderIP.ToString(); Share_Status_Text.Visibility = Visibility.Visible; communication_started_Sender = false; } setupTimer(); //setupTask(); }
public void Start() { Host = new EyeXHost(); DataStream = Host.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered); Host.Start(); DataStream.Next += SimpanPosisiMata; }
public void Start() //menyalakan Eyetracker dan mulai tracking { Host = new EyeXHost(); DataStream = Host.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered); Host.Start(); //mulai tracking mata DataStream.Next += SimpanPosisiMata; //menyimpan data mata }
public bool Initialize() { if (_useFixationStream) { _eyeXHost.CreateFixationDataStream(FixationDataMode.Slow).Next += OnFixationPointNext; } else { _eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered).Next += OnGazePointNext; } _eyeXHost.Start(); // TODO: Initialize needs to be replaced with an InitializeAsync to void // having to do this callback, waiting and semaphore dance. var initialized = false; var initialSemaphore = new SemaphoreSlim(0); void initialCallback(object s, EngineStateValue <EyeTrackingDeviceStatus> e) { switch (e.Value) { case EyeTrackingDeviceStatus.Configuring: case EyeTrackingDeviceStatus.Initializing: case EyeTrackingDeviceStatus.Tracking: case EyeTrackingDeviceStatus.TrackingPaused: initialized = true; initialSemaphore.Release(); break; case EyeTrackingDeviceStatus.DeviceNotConnected: initialSemaphore.Release(); break; } } _eyeXHost.EyeTrackingDeviceStatusChanged += initialCallback; // Wait a bit for the tracking engine to initialize the device status initialSemaphore.Wait(1000); _eyeXHost.EyeTrackingDeviceStatusChanged -= initialCallback; return(initialized); }
/*************************EYE_X_COMPONENT.INIT********************/ /* * Receive method for the EyeX gaze data stream. */ private void ReceiveGazeData(Envelope e) { using (gazeDataStream = host.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered)) { Console.WriteLine("EyeX data stream initiated."); gazePoint.Post(gazeDataStream, e.OriginatingTime); using (eyePositionStream = host.CreateEyePositionDataStream()) { Console.WriteLine("EyeX eye position stream initiated."); eyeData.Post(eyePositionStream, e.OriginatingTime); gazeDataStream.Next += (s, q) => { frameDataX = q.X; frameDataY = q.Y; }; eyePositionStream.Next += (s, q) => { leftEyeX = q.LeftEye.X; leftEyeY = q.LeftEye.Y; leftEyeZ = q.LeftEye.Z; leftEyeNormalizedX = q.LeftEyeNormalized.X; leftEyeNormalizedY = q.LeftEyeNormalized.Y; leftEyeNormalizedZ = q.LeftEyeNormalized.Z; rightEyeX = q.RightEye.X; rightEyeY = q.RightEye.Y; rightEyeZ = q.RightEye.Z; rightEyeNormalizedX = q.RightEyeNormalized.X; rightEyeNormalizedY = q.RightEyeNormalized.Y; rightEyeNormalizedZ = q.RightEyeNormalized.Z; }; Console.WriteLine("Listening for gaze data..."); using (FixationDataStream fixationStream = host.CreateFixationDataStream(FixationDataMode.Sensitive)) { fixationData.Post(fixationStream, e.OriginatingTime); fixationStream.Next += (s, q) => { fixationX = q.X; fixationY = q.Y; }; Console.WriteLine("Recording fixation points..."); Console.In.Read(); } } } }
public Record(bool filteered, string filenameWithoutExtention, bool takeScreenshot) { this.takeScreenshot = takeScreenshot; this.filenameWithoutExtention = filenameWithoutExtention; //Directory.CreateDirectory(filenameWithoutExtention + "_screenshots"); eyeXHost.Start(); if (filtered) { lightlyFilteredGazeDataStream = eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered); gpdm = GazePointDataMode.LightlyFiltered; } else { gpdm = GazePointDataMode.Unfiltered; lightlyFilteredGazeDataStream = eyeXHost.CreateGazePointDataStream(GazePointDataMode.Unfiltered); } eyePosStream = eyeXHost.CreateEyePositionDataStream(); }
private void canvasloaded(object sender, RoutedEventArgs e) { double screenheight = this.ActualHeight - SystemParameters.WindowNonClientFrameThickness.Top - SystemParameters.WindowNonClientFrameThickness.Bottom; double screenwidth = this.ActualWidth - SystemParameters.WindowNonClientFrameThickness.Left - SystemParameters.WindowNonClientFrameThickness.Right; SolidColorBrush blankbg = new SolidColorBrush(Colors.LightGray); SolidColorBrush handle = new SolidColorBrush(Colors.Gray); #region vertical heatmap setup (N/A) List <byte[, ]> colors = new List <byte[, ]>(3); colors.Add(new byte[, ] { { 0, 0, 255 } }); colors.Add(new byte[, ] { { 255, 0, 0 } }); colors.Add(new byte[, ] { { 0, 255, 0 } }); ImageBrush[] verticalheatmaps = new ImageBrush[inputFile.Length]; List <double> freqs = new List <double>(inputFile.Length); /* * if (inputFile.Length > 0) * { * for (int c = 0; c < (inputFile.Length > 3 ? 3 : inputFile.Length); c++) * { * Tuple<int, WriteableBitmap> vert = createVerticalHeatmap(200, 2 * (int)screenheight, yCoords[c], numCoords[c], 4330, 2 * 13, colors[c], 55); * //Tuple<int, WriteableBitmap> vert = createMultiHeatmap(200, 2 * (int)screenheight, yCoords, numCoords, 4330, 2 * 13, colors, 55); * verticalheatmaps[c] = new ImageBrush(vert.Item2); * freqs.Add(vert.Item1); * } * * double maxfreq = freqs.Max(); * for (int c = 0; c < (inputFile.Length > 3 ? 3 : inputFile.Length); c++) * { * freqs[c] = freqs[c] / maxfreq; * } * } */ #endregion scrollbar = new Scrollbar(15, 150, screenheight, screenwidth, 0.9, 100, bg, blankbg, handle, verticalheatmaps, freqs, canv, 1, wb, heatmap, pixels3d, allColors); recorder = new Recorder(20, 5, 100, canv, recordingpath); eyeXHost = new EyeXHost(); eyeXHost.Start(); var gazeData = eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered); gazeData.Next += newGazePoint; /* Set up and start timer for recording gaze every 10 milliseconds */ dispatcherTimer = new System.Windows.Threading.DispatcherTimer(System.Windows.Threading.DispatcherPriority.Render); dispatcherTimer.Tick += new EventHandler(update); dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 10); dispatcherTimer.Start(); }
public webBro() { InitializeComponent(); InitBrowser(); synth.SetOutputToDefaultAudioDevice(); synth.SpeakCompleted += synth_SpeakCompleted; rgx = new Regex(pattern); try { defaultStyle = File.ReadAllText(".\\Data\\style.css"); monochromeStyle = File.ReadAllText(".\\Data\\monochrome.css"); style = defaultStyle; } catch (Exception e) { MessageBox.Show(e.Message); } eyeXHost = new EyeXHost(); eyeXHost.Start(); stream = eyeXHost.CreateGazePointDataStream(Tobii.EyeX.Framework.GazePointDataMode.Unfiltered); stream.Next += (s, e) => { setPos((int)e.X, (int)e.Y); }; position = eyeXHost.CreateEyePositionDataStream(); position.Next += (s, e) => { leftClose = e.LeftEye.X == 0 && e.LeftEye.Y == 0; rightClose = e.RightEye.X == 0 && e.RightEye.Y == 0; }; controller = new Controller(); listener = new LeapEventListener(this); controller.AddListener(listener); if (File.Exists("parameters.cfg")) { StreamReader sr = new StreamReader("parameters.cfg"); fingerMove.Checked = sr.ReadLine() == "1"; keyCheck.Checked = sr.ReadLine() == "1"; borderLeft = float.Parse(sr.ReadLine()); borderUp = float.Parse(sr.ReadLine()); borderRight = float.Parse(sr.ReadLine()); borderDown = float.Parse(sr.ReadLine()); sr.Close(); if (borderLeft != -200) { firstLeap = false; } } }
private void StartEyeStream() { _eyeXHost = new EyeXHost(); _lightlyFilteredGazeDataStream = _eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered); _eyeXHost.Start(); // Write the data to the console. _lightlyFilteredGazeDataStream.Next += gazeDataStreamNext; Console.WriteLine("Eyex setup"); }
private void InitEyeTracker() { // Initialize the EyeX Host _eyeXHost = new EyeXHost(); _eyeXHost.Start(); // Create a data stream object and listen to events. stream = _eyeXHost.CreateGazePointDataStream(GazePointDataMode.Unfiltered); stream.Next += DrawCircleAtGazePoint; stream.Next += StoreGazePoint; }
public Gta5EyeTracking() { _aspectRatio = 1; _host = new EyeXHost(); _host.Start(); _lightlyFilteredGazePointDataProvider = _host.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered); _lightlyFilteredGazePointDataProvider.Next += NewGazePoint; _menuPool = new MenuPool(); LoadSettings(); _settingsMenu = new SettingsMenu(_menuPool, _settings); _settingsMenu.DeadzoneMenu.OnItemSelect += (m, item, indx) => { if (indx == 0) { _isDrawingDeadzone = true; } else { _settings.Deadzones.RemoveAt(indx - 1); _settingsMenu.DeadzoneMenu.RemoveItemAt(indx); _settingsMenu.DeadzoneMenu.RefreshIndex(); } }; _gazeVisualization = new GazeVisualization(); _debugOutput = new DebugOutput(); _aiming = new Aiming(_settings); _mouseEmulation = new MouseEmulation(); _controllerEmulation = new ControllerEmulation(); _controllerEmulation.OnModifyState += OnModifyControllerState; _freelook = new Freelook(_controllerEmulation, _mouseEmulation, _settings); _pedestrianInteraction = new PedestrianInteraction(); _radialMenu = new RadialMenu(_controllerEmulation); _gazeStopwatch = new Stopwatch(); _gazeStopwatch.Restart(); _tickStopwatch = new Stopwatch(); _foregroundWindowWatcher = new ForegroundWindowWatcher(); _foregroundWindowWatcher.ForegroundWindowChanged += ForegroundWindowWatcherOnForegroundWindowChanged; _isWindowForeground = _foregroundWindowWatcher.IsWindowForeground(); View.MenuTransitions = true; KeyDown += OnKeyDown; Tick += OnTick; }
public static void Main(string[] args) { var host = new EyeXHost(); host.Start(); Console.WriteLine("Current scale:" + GetWindowsScaling()); Console.ReadKey(); var gazePointDataStream = host.CreateGazePointDataStream(Tobii.EyeX.Framework.GazePointDataMode.Unfiltered); gazePointDataStream.Next += (s, e) => Console.WriteLine("X: {0} Y:{1}", e.X, e.Y); Console.ReadKey(); }
void StartEyeTracking() { var eyeXHost = new EyeXHost(); eyeXHost.Start(); var stream = eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered); Task.Run(async() => { while (true) { stream.Next += (s, t) => SetXY(t.X, t.Y); await Task.Delay(1000); } }); }
private void Eyetracking() { Console.WriteLine("eyetracking"); using (var eyeXHost = new EyeXHost()) { eyeXHost.Start(); using (var lightlyFilteredGazeDataStream = eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered)) { lightlyFilteredGazeDataStream.Next += (s, e) => { Console.WriteLine("Gaze point at ({0:0.0}, {1:0.0}) @{2:0}", e.X, e.Y, e.Timestamp); eyex = e.X; eyey = e.Y; }; Console.In.Read(); } } }
public override Action Start() { host = new EyeXHost(); host.Start(); host.UserPresenceChanged += HostOnUserPresenceChanged; host.EyeTrackingDeviceStatusChanged += HostOnEyeTrackingDeviceStatusChanged; host.UserProfileNameChanged += HostOnUserProfileNameChanged; host.DisplaySizeChanged += HostOnDisplaySizeChanged; gazeDataStream = host.CreateGazePointDataStream(GazePointDataMode.Unfiltered); eyeDataStream = host.CreateEyePositionDataStream(); gazeDataStream.Next += GazeDataStreamOnNext; eyeDataStream.Next += EyeDataStreamOnNext; return(null); }
public MainWindow() { InitializeComponent(); int num = 0; String currPath = path + name + num.ToString() + ext; while (File.Exists(currPath)) { currPath = path + name + (num++).ToString() + ext; } tw = new StreamWriter(currPath); host = new EyeXHost(); host.Start(); var gazeData = host.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered); gazeData.Next += newPoint; }
const int samplesHistorySize = sampleRate * 5; //keep most recent 5 second of gaze points public EyeXWarpPointer(int threshold) { samples = new Point[samplesArraySize]; samplesHistory = new List <Point>(); warpThreshold = threshold; if (!EyeXHost.IsStarted) { EyeXHost.Start(); // Start the EyeX host } //default is lightly filtered, just making it explicit gazeDataStream = EyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered); if (gazeDataStream != null) { gazeDataStream.Next += UpdateGazePosition; } }
public MainWindow() { InitializeComponent(); if (SenderOn) { SenderIP = defaultSenderIP; Share_Status_Text.Text = "Sharing Data to\nIP:" + SenderIP.ToString(); Share_Status_Text.Visibility = Visibility.Visible; communication_started_Sender = false; } eyeXHost = new EyeXHost(); eyeXHost.Start(); var gazeData = eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered); gazeData.Next += gazePoint; // Set up timer dispatcherTimer = new System.Windows.Threading.DispatcherTimer(System.Windows.Threading.DispatcherPriority.Render); dispatcherTimer.Tick += new EventHandler(update); dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 10); dispatcherTimer.Start(); // Set up indicator of computer number switch (studentNum) { case 0: StudentIndicator.Content = "Student 0"; StudentIndicator.Background = new SolidColorBrush(System.Windows.Media.Colors.Purple); break; case 1: StudentIndicator.Content = "Student 1"; StudentIndicator.Background = new SolidColorBrush(System.Windows.Media.Colors.Red); break; case 2: StudentIndicator.Content = "Student 2"; StudentIndicator.Background = new SolidColorBrush(System.Windows.Media.Colors.CornflowerBlue); break; } }
public static void Main(string[] args) { using (var eyeXHost = new EyeXHost()) { // Create a data stream: lightly filtered gaze point data. // Other choices of data streams include EyePositionDataStream and FixationDataStream. using (var lightlyFilteredGazeDataStream = eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered)) { // Start the EyeX host. eyeXHost.Start(); // Write the data to the console. lightlyFilteredGazeDataStream.Next += (s, e) => Console.WriteLine("Gaze point at ({0:0.0}, {1:0.0}) @{2:0}", e.X, e.Y, e.Timestamp); // Let it run until a key is pressed. Console.WriteLine("Listening for gaze data, press any key to exit..."); Console.In.Read(); } } }
public EyeTracker_Management(MouseManagement mmgt, TimerBlinkManagement tbm, EyeTrackerDataManagement etdm) { this.tbm = tbm; this.mmgt = mmgt; this.etdm = etdm; eyeXHost = new EyeXHost(); eyeXHost.Start(); lightlyFilteredGazeDataStream = eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered); lightlyFilteredGazeDataStream.Next += (s, e) => this.OnGazeDataStream(s, e); eyeXHost.GazeTrackingChanged += (s, e) => etdm.OnGazeTrackingChangedEvent(s, e); etdm.GazeNotTracked += (s, e) => this.OnGazeNotTracked(); etdm.GazeTracked += (s, e) => this.OnGazeTracked(); tbm.AllowingCursorToMove += (s, e) => mmgt.setIsCursorAllowedToMove(true); mmgt.CursorAllowedToMoveChanged += (s, e) => this.OnCursorAllowedToMoveChanged(new CustomEventArgs(e.BooleanValue)); etdm.CursorInBottomMidlleScreen += (s, e) => this.OnCursorInBottomMidlleScreen(new EventArgs()); }
public static void Main(string[] args) { using (var eyeXHost = new EyeXHost()) { // Create a data stream: lightly filtered gaze point data. // Other choices of data streams include EyePositionDataStream and FixationDataStream. using (var lightlyFilteredGazeDataStream = eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered)) { // Start the EyeX host. eyeXHost.Start(); //check if a log file exists and create a new with actal ending if not int x = 0; while (File.Exists(@"..\..\..\logs\log" + x + ".txt")) { x++; } FileStream fs = File.Create(@"..\..\..\logs\log" + x + ".txt"); fs.Close(); sw = new StreamWriter( new System.IO.FileStream( @"..\..\..\logs\log" + x + ".txt", System.IO.FileMode.Append, FileAccess.Write, FileShare.ReadWrite ) ); // Write the data to the console. lightlyFilteredGazeDataStream.Next += gazeCallback;//(s, e) => //Console.WriteLine("Gaze point at ({0:0.0}, {1:0.0}) @{2:0}", e.X, e.Y, e.Timestamp); // Let it run until a key is pressed. Console.WriteLine("Listening for gaze data, press any key to exit..."); Console.In.Read(); sw.Close(); } } }
public MainWindow() { InitializeComponent(); // Set up handler for key press events this.KeyDown += new KeyEventHandler(Main_KeyDown); // Initialize logging initLog(); eyeXHost = new EyeXHost(); eyeXHost.Start(); var gazeData = eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered); gazeData.Next += gazePoint; lineSetup(); if (ReceiverOn) { IPHostEntry ipHostInfo = Dns.GetHostByName(Dns.GetHostName()); IPAddress ipAddress = ipHostInfo.AddressList[0]; //Receive_Status_Text.Text = "Receiving Data at\nIP:" + ipAddress.ToString(); //Receive_Status_Text.Visibility = Visibility.Visible; } if (SenderOn) { SenderIP = defaultSenderIP; //Share_Status_Text.Text = "Sharing Data to\nIP:" + SenderIP.ToString(); //Share_Status_Text.Visibility = Visibility.Visible; communication_started_Sender = false; } System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer(System.Windows.Threading.DispatcherPriority.Render); dispatcherTimer.Tick += new EventHandler(update); dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 10); dispatcherTimer.Start(); }
public static void Main(string[] args) { string datapoint; string time; int recordEveryXTime = 15; //don't need to record every point... int recordEveryXTimeCounter = 0; string path = "C:/Users/ResearchSquad/Documents/TransparentLog/" + "A_" + DateTime.Now.ToString("MM-dd_hh-mm") + ".txt"; using (var eyeXHost = new EyeXHost()) { // Create a data stream: lightly filtered gaze point data. // Other choices of data streams include EyePositionDataStream and FixationDataStream. using (var lightlyFilteredGazeDataStream = eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered)) { eyeXHost.Start(); lightlyFilteredGazeDataStream.Next += (s, e) => { if ((recordEveryXTimeCounter % recordEveryXTime == 0)) { // Convert ms to readable time format time = DateTime.Now.ToString("hh:mm:ss.fff"); Console.WriteLine("Gaze point at ({0:0.00}, {1:0.00}) @ {2:0}", e.X, e.Y, time); datapoint = string.Format("Gaze point at ({0:0.00}, {1:0.00}) @ {2:0}", e.X, e.Y, time) + "\n"; System.IO.StreamWriter file = new System.IO.StreamWriter(path, true); file.WriteLine(datapoint); file.Close(); } recordEveryXTimeCounter++; }; // Let it run until a key is pressed. Console.WriteLine("Listening for gaze data, press any key to exit..."); Console.In.Read(); } } }
public Gta5EyeTracking() { Util.Log("Begin Initialize"); //Disposing _shutDownRequestedEvent = new ManualResetEvent(false); //Settings _settingsStorage = new SettingsStorage(); _settings = _settingsStorage.LoadSettings(); //Statistics var version = Assembly.GetExecutingAssembly().GetName().Version; var versionString = version.Major + "." + version.Minor + "." + version.Build; _googleAnalyticsApi = new GoogleAnalyticsApi("UA-68420530-1", _settings.UserGuid, "GTA V Eye Tracking Mod", "gta5eyetracking", versionString); //Gaze _aspectRatio = 1; _host = new EyeXHost(); _host.Start(); _lightlyFilteredGazePointDataProvider = _host.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered); _lightlyFilteredGazePointDataProvider.Next += NewGazePoint; _lastGazeTime = DateTime.UtcNow; //Menu _menuPool = new MenuPool(); _settingsMenu = new SettingsMenu(_menuPool, _settings); _deadzoneEditor = new DeadzoneEditor(_settings, _settingsMenu); _settingsMenu.ShutDownRequested += SettingsMenuOnShutDownRequested; _introScreen = new IntroScreen(_menuPool, _settings); _introScreen.ShutDownRequested += SettingsMenuOnShutDownRequested; //Debug _debugGazeVisualization = new DotCrosshair(Color.FromArgb(220, 255, 0, 0), Color.FromArgb(220, 0, 255, 255)); _debugOutput = new DebugOutput(); //Hids _mouseEmulation = new MouseEmulation(); _controllerEmulation = new ControllerEmulation(); //Features _animationHelper = new AnimationHelper(); _aiming = new Aiming(_settings, _animationHelper); _freelook = new Freelook(_controllerEmulation, _mouseEmulation, _settings); _radialMenu = new RadialMenu(_controllerEmulation); _pedestrianInteraction = new PedestrianInteraction(_settings); //Window _foregroundWindowWatcher = new ForegroundWindowWatcher(); _foregroundWindowWatcher.ForegroundWindowChanged += ForegroundWindowWatcherOnForegroundWindowChanged; _isWindowForeground = _foregroundWindowWatcher.IsWindowForeground(); //General _gazeProjector = new GazeProjector(_settings); _controlsProcessor = new ControlsProcessor(_settings, _controllerEmulation, _aiming, _freelook, _radialMenu, _settingsMenu, _menuPool, _debugOutput); KeyDown += OnKeyDown; Tick += OnTick; Util.Log("End Initialize"); }
private void buttonStart_Click(object sender, EventArgs e) { int x = this.PointToScreen(new Point(0, 0)).X; int screenWidth = SystemInformation.PrimaryMonitorSize.Width; if (page == null) { return; } defineScenario(); //Start recording and displaying if (!recording) { richTextBox1.Clear(); this.pictureBoxTexte.Image = new Bitmap(this.pictureBoxTexte.ImageLocation); bmpGaze = new Bitmap(pictureBoxGaze.Width, pictureBoxGaze.Height); //Read line by line if (comboBoxStimuli.SelectedItem == comboBoxStimuli.Items[1]) { pixelIdx = page.Lines[scenario[0]].Coords.Rectangle.Left; setTimerPixelLine(page.Lines[scenario[0]]); } //Read word by word else if (comboBoxStimuli.SelectedItem == comboBoxStimuli.Items[0]) { timer.Interval = (int)Math.Round(speed);; } lightlyFilteredGazeDataStream = eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered); lightlyFilteredGazeDataStream.Next += gazeEvent; wordEstimation = new WordsEstimationOnline(page.averageWordWidth, page.averageSpaceLength); //Start to measure the elapsed time sw.Start(); labelRecording.Text = "Recording..."; recording = true; timer.Start(); timeStart = DateTime.Now; } //Stop recording else { stopRecording(); lightlyFilteredGazeDataStream.Next -= gazeEvent; //estimate nb of words and speed of the recording //save temporary the data for the analysis //rec.saveFiles("temp\\save"); //GazeData gd = new GazeData("temp\\save"); //gd.fixationBusher2008(); //gd.lineBreakDetectionSimple(); //float estimatedWordsBasedOnLineLength = gd.TotalLinesLength / (page.averageWordWidth + page.averageSpaceLength); ////I had one word per line in the estimation because the fixation are found at the beggining of the words //estimatedWordsBasedOnLineLength += gd.lines.Count; //textBoxNbWords.Text = estimatedWordsBasedOnLineLength.ToString(); ////The estimated speed is just the nb of estimated words / elapsed time //int speed = (int)(60000 * estimatedWordsBasedOnLineLength / double.Parse(textBoxElapsedTime.Text)); //textBoxEstimatedSpeed.Text = speed.ToString(); //Display the gaze and fixations displayGazeOnPicture(wordEstimation.gazes, Brushes.Red); displayGazeOnPicture(wordEstimation.fixations, Brushes.Blue); //display the tag cloud List <string> readWords = TagCloud.Program.findClosestWords(translateGaze(wordEstimation.fixations), page); Dictionary <string, int> wordCloud = new Dictionary <string, int>(); foreach (var item in readWords) { if (wordCloud.ContainsKey(item)) { wordCloud[item]++; } else { wordCloud.Add(item, 1); } } foreach (var item in wordCloud) { richTextBox1.SelectionFont = new Font("Tahoma", item.Value * 5 + 10); richTextBox1.AppendText(item.Key + " "); } //Not reading readingScore = 0; labelReading.Invalidate(); // = "Not Reading"; timeStop = DateTime.Now; } }
private void canvasloaded(object sender, RoutedEventArgs e) { double screenheight = this.ActualHeight - SystemParameters.WindowNonClientFrameThickness.Top - SystemParameters.WindowNonClientFrameThickness.Bottom; double screenwidth = this.ActualWidth - SystemParameters.WindowNonClientFrameThickness.Left - SystemParameters.WindowNonClientFrameThickness.Right; SolidColorBrush blankbg = new SolidColorBrush(Colors.LightGray); SolidColorBrush handle = new SolidColorBrush(Colors.Gray); #region vertical scrollbar heatmap (not used) /* * List<byte[,]> colors = new List<byte[,]>(3); * colors.Add(new byte[,] { { 255, 0, 0 } }); * colors.Add(new byte[,] { { 0, 255, 0 } }); * colors.Add(new byte[,] { { 0, 0, 255 } }); * * List<byte[]> colors = new List<byte[]>(3); * colors.Add(new byte[] { 255, 0, 0 }); * colors.Add(new byte[] { 0, 255, 0 }); * colors.Add(new byte[] { 0, 0, 255 }); * * ImageBrush[] verticalheatmaps = new ImageBrush[inputFile.Length]; * List<double> freqs = new List<double>(inputFile.Length); * for(int c = 0; c < inputFile.Length; c++) { * Tuple<int, WriteableBitmap> vert = createVerticalHeatmap(200, 2 * (int)screenheight, yCoords[c], numCoords[c], 4330, 2 * 13, colors[c], 55); * //Tuple<int, WriteableBitmap> vert = createMultiHeatmap(200, 2 * (int)screenheight, yCoords, numCoords, 4330, 2 * 13, colors, 55); * verticalheatmaps[c] = new ImageBrush(vert.Item2); * freqs.Add(vert.Item1); * } * * double maxfreq = freqs.Max(); * for (int c = 0; c < inputFile.Length; c++) { * freqs[c] = freqs[c] / maxfreq; * } */ #endregion scrollbar = new Scrollbar(15, screenheight, screenwidth, bg, blankbg, handle, canv, 1); recorder = new Recorder(20, 5, 100, canv, recordingpath, cloudLecture); /* Colors for gaze display for each student in inputFile array */ Color[] colors = /*{ Colors.Red, Colors.DarkOrange, Colors.Gold, Colors.Green, Colors.Teal, * Colors.Blue, Colors.MediumAquamarine, Colors.Indigo, Colors.MediumPurple, Colors.Coral, * Colors.DeepPink, Colors.Chocolate, Colors.DarkOliveGreen, Colors.Magenta, Colors.YellowGreen};*/ { Colors.Green, Colors.Green, Colors.Red, Colors.Red, Colors.Red, Colors.Red, Colors.Green, Colors.Red, Colors.Green, Colors.Red, Colors.Green, Colors.Red, Colors.Green, Colors.Green }; pointvis = new Pointvis(inputFile.Length, 35, colors, canv); meanvis = new Meanvis(inputFile.Length, 20, canv); eyeXHost = new EyeXHost(); eyeXHost.Start(); var gazeData = eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered); gazeData.Next += newGazePoint; /* Set up and start timer for recording gaze every 10 milliseconds */ dispatcherTimer = new System.Windows.Threading.DispatcherTimer(System.Windows.Threading.DispatcherPriority.Render); dispatcherTimer.Tick += new EventHandler(update); dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 10); dispatcherTimer.Start(); }
public static void Main(string[] args) { tcpServer = new JsonTcpServer(6555); frameData = new FrameData(); switch (EyeXHost.EyeXAvailability) { case EyeXAvailability.NotAvailable: Console.WriteLine("This server requires the EyeX Engine, but it isn't available."); Console.WriteLine("Please install the EyeX Engine and try again."); return; case EyeXAvailability.NotRunning: Console.WriteLine("This server requires the EyeX Engine, but it isn't running."); Console.WriteLine("Please make sure that the EyeX Engine is started."); break; } Thread clientUpdateThread = new Thread(new ThreadStart(StartUpdatingToClients)); using (var eyeXHost = new EyeXHost()) { eyeXHost.Start(); Console.WriteLine("SERVER: eyeXHost started"); // Create a data stream: lightly filtered gaze point data. // Other choices of data streams include EyePositionDataStream and FixationDataStream. eyeXHost.ScreenBoundsChanged += (s, e) => { Console.WriteLine("[EVENT] Screen Bounds in pixels (state-changed event): {0}", e); }; eyeXHost.DisplaySizeChanged += (s, e) => { Console.WriteLine("[EVENT] Display Size in millimeters (state-changed event): {0}", e); }; eyeXHost.EyeTrackingDeviceStatusChanged += (s, e) => { Console.WriteLine("[EVENT] Eye tracking device status (state-changed event): {0}", e); EyeXAPIEvent message = new EyeXAPIEvent(); message.eventType = "device_state_changed"; tcpServer.sendToAllClients(message.toJson()); Thread.Sleep(60); }; eyeXHost.UserPresenceChanged += (s, e) => { Console.WriteLine("[EVENT] User presence (state-changed event): {0}", e); //TODO save it to send in frame }; eyeXHost.UserProfileNameChanged += (s, e) => { Console.WriteLine("[EVENT] Active profile name (state-changed event): {0}", e); }; // This state-changed event required EyeX Engine 1.4. eyeXHost.UserProfilesChanged += (s, e) => { Console.WriteLine("[EVENT] User profile names (state-changed event): {0}", e); }; eyeXHost.GazeTrackingChanged += (s, e) => { Console.WriteLine("[EVENT] Gaze tracking (state-changed event): {0}", e); //TODO save it to send in frame }; using (var gazeDataStream = eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered)) { Console.WriteLine("[EYEX]: GazeDataStream started"); using (var eyePositionStream = eyeXHost.CreateEyePositionDataStream()) { Console.WriteLine("[EYEX]: EyePositionStream started"); // Write the data to the console. gazeDataStream.Next += (s, e) => { //Console.WriteLine("Gaze point at ({0:0.0}, {1:0.0}) @{2:0}", e.X, e.Y, e.Timestamp); frameData.Gaze = e; frameData.userPresence = eyeXHost.UserPresence; }; eyePositionStream.Next += (s, e) => { //Console.WriteLine("3D Position: ({0:0.0}, {1:0.0}, {2:0.0}) ", // e.LeftEye.X, e.LeftEye.Y, e.LeftEye.Z); frameData.updateEyePosition(e); frameData.userPresence = eyeXHost.UserPresence; }; tcpServer.ClientMessageReceieved += (TcpClient client, JObject json) => { if (json["type"].ToString() == "request") { int requestId = (int)json["requestId"]; if (json["resource"].ToString() == "calibration" && json["path"].ToString() == "start") { Console.WriteLine("[Client] Calibration requested"); EyeXAPIResponse response = new EyeXAPIResponse(); response.statusCode = 200; response.requestId = requestId; tcpServer.sendToClient(client, response.toJson()); eyeXHost.LaunchGuestCalibration(); } if (json["resource"].ToString() == "tracker") { if (json["path"].ToString() == "get.basic_info") { EyeXAPIResponse response = new EyeXAPIResponse(); response.statusCode = 200; response.requestId = requestId; Dictionary <string, object> result = new Dictionary <string, object>(); result.Add("screen_bounds", eyeXHost.ScreenBounds.Value); result.Add("display_size", eyeXHost.DisplaySize.Value); response.results = result; tcpServer.sendToClient(client, response.toJson()); } else { //TODO return api error: unknown method } } } else if (json["type"].ToString() == "event") { // Client side events is not supported yet } }; clientUpdateThread.Start(); Console.WriteLine("Listening for gaze data, press any key to exit..."); Console.In.Read(); } // using EyePositionDataStream } // using GazeDataStream } // using eyeXHost }