void FEyetrackerIn_Changed(IDiffSpread <IEyetracker> spread) { if (spread.SliceCount == 0) { if (FEyetracker != null) { FEyetracker = null; FCalibrationRunner.OnTriggerCalibrationPoint -= FCalibrationRunner_OnTriggerCalibrationPoint; FCalibrationRunner.OnCalibrationDone -= FCalibrationRunner_OnCalibrationDone; FCalibrationRunner.OnCalibrationAborted -= FCalibrationRunner_OnCalibrationAborted; FCalibrationRunner.OnLastCalibPointTriggered -= FCalibrationRunner_OnLastCalibPointTriggered; FCalibrationRunner = null; } } else { FEyetracker = spread[0]; FCalibrationRunner = new CalibrationRunner(spread[0], FInterval[0]); // register event listeners FCalibrationRunner.OnTriggerCalibrationPoint += FCalibrationRunner_OnTriggerCalibrationPoint; FCalibrationRunner.OnCalibrationDone += FCalibrationRunner_OnCalibrationDone; FCalibrationRunner.OnCalibrationAborted += FCalibrationRunner_OnCalibrationAborted; FCalibrationRunner.OnLastCalibPointTriggered += FCalibrationRunner_OnLastCalibPointTriggered; } }
// helper private void DisconnectEyetracker(bool DoRescan) { if (FEyetracker != null) { FEyetracker.ConnectionError -= HandleConnectionError; FEyetracker.Dispose(); FEyetracker = null; FConnectionName = string.Empty; FSyncManager.Dispose(); UpdateDeviceStatus(FTrackerInfo.Status); if (!FEyetrackerBrowser.IsStarted) { if (DoRescan) { FEyetrackerBrowser.Start(); } } if (FEyetrackerBrowser.IsStarted) { FEyetrackerBrowser.Stop(); } } }
/// <summary> /// Connects to eyetracker and subscribes to events. Events are received on background thread. /// </summary> public void Connect() { try { eyetracker = EyetrackerFactory.CreateEyetracker(info, EventThreadingOptions.BackgroundThread); // subscribe to eyetracker events eyetracker.ConnectionError += ConnectionError; foreach (EventHandler <FramerateChangedEventArgs> handler in framerateChangedHandlers) { eyetracker.FramerateChanged += handler; } foreach (EventHandler <GazeDataEventArgs> handler in gazeDataHandlers) { eyetracker.GazeDataReceived += handler; } eyetracker.StartTracking(); } catch (EyetrackerException ee) { Disconnect(); if (ee.ErrorCode == 0x20000402) { throw new Exception("Failed to upgrade protocol. Upgrade firmware to version 2.0.0 or higher.", ee); } throw ee; } catch (Exception e) { Disconnect(); throw e; } }
public static Point GetGazePointInScreenPixels(IEyetracker eyetracker) { var w = System.Windows.Forms.Screen.PrimaryScreen; var gx = eyetracker.X * w.Bounds.Width; var gy = eyetracker.Y * w.Bounds.Height; return(new Point(gx, gy)); }
public Eyetracker() { if (!EyetrackerFactory.Default.CanCreateEyetracker) { throw new CannotCreateEyetrackerException(); } _eyetracker = EyetrackerFactory.Default.Create(); }
public GazeCaret(IWpfTextView textView, KeyboardListener keyboard, IEyetracker eyetracker) { _textView = textView; _keyboard = keyboard; _eyetracker = eyetracker; _keyboard.CarretAction += OnCarretAction; }
private void OnLoaded(object sender, RoutedEventArgs e) { _eyetracker = new Eyetracker(); _rootElement = GetVisualChild(0) as FrameworkElement; ImageEffect.Texture2 = new ImageBrush(new BitmapImage(new Uri("./Images/wood.jpg", UriKind.Relative))); CompositionTarget.Rendering += CompositionTargetOnRendering; }
public GazeScroll(IWpfTextView textView, KeyboardListener keyboard, IEyetracker eyetracker) { _textView = textView; _keyboard = keyboard; _gaze = eyetracker; _textView.Closed += OnTextViewClosed; _keyboard.UpdateScroll += OnUpdateScroll; }
// constructor public CalibrationRunner(IEyetracker Eyetracker, float Interval) { FEyetracker = Eyetracker; FEyetracker.ConnectionError += HandleConnectionError; FIntervalTime = Interval; FCalibrationPoints = new Queue <Point2D>(); FSleepTimer = new System.Timers.Timer(); }
// establich connection to eyetracker device private void ConnectToTrackerAndStartTracking(EyetrackerInfo info) { try { if (FEyetracker == null) { // get tracker representation from EyetrackerInfo FEyetracker = EyetrackerFactory.CreateEyetracker(info); } FEyetracker.ConnectionError -= HandleConnectionError; // Trigger device-status-update event for IS1Node UpdateDeviceStatus(FTrackerInfo.Status); FConnectionName = info.ProductId; if (FSyncManager == null) { FSyncManager = new SyncManager(FClock, info); FSyncManager.SyncStateChanged += HandleSyncStateChanged; } SyncState st = FSyncManager.SyncState; if (st.StateFlag == SyncStateFlag.Unsynchronized) { // TODO: handle the case that eyetracker is unsynchronized to make sure that et-status gets OK } // register eventhandlers FEyetracker.ConnectionError += HandleConnectionError; // trigger device-status-update event for IS1Node UpdateDeviceStatus(FTrackerInfo.Status); } catch (EyetrackerException ee) { if (ee.ErrorCode == 0x20000402) { // trigger custom-error event for IS1Node OnCustomError("EyetrackerException occured (errorCode " + ee.ErrorCode.ToString() + ") - Failed to upgrade protocol." + "This probably means that the firmware needs to be upgraded to a version that supports the new sdk."); } else { // trigger custom-error event for IS1Node OnCustomError("EyetrackerException occured (errorCode " + ee.ErrorCode.ToString() + ") - Eyetracker responded with error" + ee); } DisconnectEyetracker(false); } catch (Exception e) { // trigger custom-error event for IS1Node OnCustomError("Could not connect to eyetracker. " + "Connection failed" + "(" + e.Message + ")"); DisconnectEyetracker(false); } }
/// <summary> /// Unsubscribes from events and disconnects eyetracker. /// </summary> public void Disconnect() { if (eyetracker != null) { eyetracker.ConnectionError -= ConnectionError; eyetracker.Dispose(); eyetracker = null; info = null; } }
public static bool IsLookingAt(this IEyetracker eyetracker, EnvDTE.Window window) { var gazePixels = ScreenHelpers.GetGazePointInScreenPixels(eyetracker); ThreadHelper.ThrowIfNotOnUIThread(); var x = gazePixels.X - window.Left; var y = gazePixels.Y - window.Top; return(x > 0 && x < window.Width && y > 0 && y < window.Height); }
/// <summary> /// The disconnect tracker method. /// </summary> private void DisconnectTracker() { if (connectedTracker == null) { return; } connectedTracker.GazeDataReceived -= this.ConnectedTrackerGazeDataReceived; connectedTracker.Dispose(); connectedTracker = null; this.isTracking = false; this.syncManager.Dispose(); }
public static IEyetracker AdaptTo(this IEyetracker eyetracker, FrameworkElement elm) { var elementScreenBounds = new Rect( elm.PointToScreen(new Point(0, 0)), elm.PointToScreen(new Point(elm.ActualWidth, elm.ActualHeight))); var w = System.Windows.Forms.Screen.PrimaryScreen; var gazeInPixels = new Point( eyetracker.X * w.Bounds.Width, eyetracker.Y * w.Bounds.Height); var relativeGaze = Clamp(gazeInPixels - elementScreenBounds.TopLeft, elementScreenBounds.Size); return(new ClampedTracker( (float)(relativeGaze.X / elementScreenBounds.Width), (float)(relativeGaze.Y / elementScreenBounds.Height))); }
void FEyetrackerIn_Changed(IDiffSpread <IEyetracker> spread) { if (spread[0] == null) { if (FEyetracker != null) { FEyetracker.Dispose(); FEyetracker = null; } FPointsOut.SliceCount = 0; } else { FEyetracker = spread[0]; FConnected = true; } }
// start the calibration process on the given Eyetracker public void RunCalibration(IEyetracker tracker, float interval, double threshold) { FCalibrationState = true; FCalibThreshold = threshold; try { FSleepTimer.Interval = interval; FSleepTimer.Elapsed += HandleTimerElapsed; FEyetracker.StartCalibration(); } catch (Exception ee) { FCalibrationState = false; } // begin collecting data for the calibration points StartNextOrFinish(); }
public Calibration RunCalibration(IEyetracker tracker) { CreatePointList(); _tracker = tracker; _tracker.ConnectionError += HandleConnectionError; // Inform the eyetracker that we want to run a calibration _tracker.StartCalibration(); _calibrationForm.ClearCalibrationPoint(); _calibrationForm.ShowDialog(); // Inform the eyetracker that we have finished // the calibration routine _tracker.StopCalibration(); return _calibrationResult; }
/// <summary> /// Unsubscribes from events and disconnects eyetracker. /// </summary> public void Disconnect() { if (eyetracker != null) { eyetracker.ConnectionError -= ConnectionError; foreach (EventHandler <FramerateChangedEventArgs> handler in framerateChangedHandlers) { eyetracker.FramerateChanged -= handler; } foreach (EventHandler <GazeDataEventArgs> handler in gazeDataHandlers) { eyetracker.GazeDataReceived -= handler; } eyetracker.Dispose(); eyetracker = null; info = null; } }
/// <summary> /// The method runs the calibration of the tobii device. /// </summary> /// <param name="givenTracker">The <see cref="IEyetracker"/> tracker</param> /// <returns>A <see cref="Calibration"/> object</returns> public Calibration RunCalibration(IEyetracker givenTracker) { this.CreatePointList(); this.tracker = givenTracker; this.tracker.ConnectionError += this.HandleConnectionError; // Inform the eyetracker that we want to run a calibration this.tracker.StartCalibration(); this.tobiiCalibrationForm.ClearCalibrationPoint(); PresentationScreen.PutFormOnPresentationScreen(this.tobiiCalibrationForm, true); this.tobiiCalibrationForm.ShowDialog(); // Inform the eyetracker that we have finished // the calibration routine this.tracker.StopCalibration(); return this.calibrationResult; }
/// <summary> /// Initializes a new instance of the <see cref="TobiiEyeTracker4C"/> class. /// </summary> /// <param name="updateIntervalms">The update interval, in ms.</param> /// <exception cref="ArgumentOutOfRangeException">The update interval must be >= 10ms</exception> /// <exception cref="Exception">Device not found.</exception> public TobiiEyeTracker4C(int updateIntervalms = 100) { if (updateIntervalms < 10) { throw new ArgumentOutOfRangeException("The update interval must be >= 10ms"); } _updateInterval = updateIntervalms; _eyetracker = new Eyetracker(); if (_eyetracker is null) { throw new Exception("Device not found."); } _uiDispatcher = Dispatcher.CurrentDispatcher; _screenWidth = SystemParameters.PrimaryScreenWidth; _screenHeight = SystemParameters.PrimaryScreenHeight; UpdateAsync(); }
/// <summary> /// The method runs the calibration of the tobii device. /// </summary> /// <param name="givenTracker">The <see cref="IEyetracker"/> tracker</param> /// <returns>A <see cref="Calibration"/> object</returns> public Calibration RunCalibration(IEyetracker givenTracker) { this.CreatePointList(); this.tracker = givenTracker; this.tracker.ConnectionError += this.HandleConnectionError; // Inform the eyetracker that we want to run a calibration this.tracker.StartCalibration(); this.tobiiCalibrationForm.ClearCalibrationPoint(); PresentationScreen.PutFormOnPresentationScreen(this.tobiiCalibrationForm, true); this.tobiiCalibrationForm.ShowDialog(); // Inform the eyetracker that we have finished // the calibration routine this.tracker.StopCalibration(); return(this.calibrationResult); }
/// <summary> /// This methods connects to the tracker. /// </summary> /// <param name="info"> /// A <see cref="EyetrackerInfo"/>with information about the /// eyetracker to connect to. /// </param> private void ConnectToTracker(EyetrackerInfo info) { try { connectedTracker = EyetrackerFactory.CreateEyetracker(info); connectedTracker.ConnectionError += this.HandleConnectionError; this.tobiiSettings.ConnectedTrackerName = connectedTracker.GetUnitName(); this.tobiiClock = new Clock(); this.syncManager = new SyncManager(this.tobiiClock, info); connectedTracker.GazeDataReceived += this.ConnectedTrackerGazeDataReceived; connectedTracker.StartTracking(); } catch (EyetrackerException ee) { if (ee.ErrorCode == 0x20000402) { MessageBox.Show( Resources.TobiiTracker_ConnectToTrackerFailed, "Upgrade Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Eyetracker responded with error " + ee, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.DisconnectTracker(); } catch (Exception) { MessageBox.Show( "Could not connect to eyetracker.", "Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); this.DisconnectTracker(); } }
void FEyetrackerIn_Changed(IDiffSpread <IEyetracker> spread) { if (spread.SliceCount == 0) { if (FEyetracker != null) { FEyetracker.StopTracking(); FEyetracker.Dispose(); FEyetracker = null; } FSliceCount = 0; } else { FEyetracker = spread[0]; // maybe leave this line away?? // FEyetracker.StartTracking(); // FEyetracker.GazeDataReceived += GazeDataReceive; FSliceCount = spread.SliceCount; } FConnectionChanged = true; }
private void ConnectToTracker(EyetrackerInfo info) { try { _connectedTracker = EyetrackerFactory.CreateEyetracker(info); _connectedTracker.ConnectionError += HandleConnectionError; _connectionName = info.ProductId; _syncManager = new SyncManager(_clock, info); _connectedTracker.GazeDataReceived += _connectedTracker_GazeDataReceived; _connectedTracker.FramerateChanged += _connectedTracker_FramerateChanged; } catch (EyetrackerException ee) { if(ee.ErrorCode == 0x20000402) { MessageBox.Show("Failed to upgrade protocol. " + "This probably means that the firmware needs" + " to be upgraded to a version that supports the new sdk.","Upgrade Failed",MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Eyetracker responded with error " + ee, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } DisconnectTracker(); } catch(Exception) { MessageBox.Show("Could not connect to eyetracker.","Connection Failed",MessageBoxButtons.OK,MessageBoxIcon.Error); DisconnectTracker(); } UpdateUIElements(); }
/// <summary> /// Connects to eyetracker and subscribes to events. Events are received on background thread. /// </summary> public void Connect() { try { eyetracker = EyetrackerFactory.CreateEyetracker(info, EventThreadingOptions.BackgroundThread); eyetracker.ConnectionError += ConnectionError; eyetracker.StartTracking(); } catch (EyetrackerException ee) { Disconnect(); if (ee.ErrorCode == 0x20000402) { throw new Exception("Failed to upgrade protocol. Upgrade firmware to version 2.0.0 or higher.", ee); } throw ee; } catch (Exception e) { Disconnect(); throw e; } }
/// <summary> /// Unsubscribes from events and disconnects eyetracker. /// </summary> public void Disconnect() { if (eyetracker != null) { eyetracker.ConnectionError -= ConnectionError; foreach (EventHandler<FramerateChangedEventArgs> handler in framerateChangedHandlers) { eyetracker.FramerateChanged -= handler; } foreach (EventHandler<GazeDataEventArgs> handler in gazeDataHandlers) { eyetracker.GazeDataReceived -= handler; } eyetracker.Dispose(); eyetracker = null; info = null; } }
/// <summary> /// Connects to eyetracker and subscribes to events. Events are received on background thread. /// </summary> public void Connect() { try { eyetracker = EyetrackerFactory.CreateEyetracker(info, EventThreadingOptions.BackgroundThread); // subscribe to eyetracker events eyetracker.ConnectionError += ConnectionError; foreach (EventHandler<FramerateChangedEventArgs> handler in framerateChangedHandlers) { eyetracker.FramerateChanged += handler; } foreach (EventHandler<GazeDataEventArgs> handler in gazeDataHandlers) { eyetracker.GazeDataReceived += handler; } eyetracker.StartTracking(); } catch (EyetrackerException ee) { Disconnect(); if (ee.ErrorCode == 0x20000402) { throw new Exception("Failed to upgrade protocol. Upgrade firmware to version 2.0.0 or higher.", ee); } throw ee; } catch (Exception e) { Disconnect(); throw e; } }
private void DisconnectTracker() { if(_connectedTracker != null) { _connectedTracker.GazeDataReceived -= _connectedTracker_GazeDataReceived; _connectedTracker.Dispose(); _connectedTracker = null; _connectionName = string.Empty; _isTracking = false; _syncManager.Dispose(); } }
/// <summary> /// The disconnect tracker method. /// </summary> private void DisconnectTracker() { if (connectedTracker == null) { return; } connectedTracker.GazeDataReceived -= this.ConnectedTrackerGazeDataReceived; connectedTracker.Dispose(); connectedTracker = null; this.isTracking = false; this.syncManager.Dispose(); }
/// <summary> /// This methods connects to the tracker. /// </summary> /// <param name="info"> /// A <see cref="EyetrackerInfo"/>with information about the /// eyetracker to connect to. /// </param> private void ConnectToTracker(EyetrackerInfo info) { try { connectedTracker = EyetrackerFactory.CreateEyetracker(info); connectedTracker.ConnectionError += this.HandleConnectionError; this.tobiiSettings.ConnectedTrackerName = connectedTracker.GetUnitName(); this.tobiiClock = new Clock(); this.syncManager = new SyncManager(this.tobiiClock, info); connectedTracker.GazeDataReceived += this.ConnectedTrackerGazeDataReceived; connectedTracker.StartTracking(); } catch (EyetrackerException ee) { if (ee.ErrorCode == 0x20000402) { MessageBox.Show( Resources.TobiiTracker_ConnectToTrackerFailed, "Upgrade Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Eyetracker responded with error " + ee, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.DisconnectTracker(); } catch (Exception) { MessageBox.Show( "Could not connect to eyetracker.", "Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); this.DisconnectTracker(); } }
/// <summary> /// Unsubscribes from events and disconnects eyetracker. /// </summary> public void Disconnect() { if (eyetracker != null) { eyetracker.ConnectionError -= ConnectionError; eyetracker.Dispose(); eyetracker = null; info = null; } }
public static Point GetRelativeGazePointForElement(IEyetracker eyetracker, FrameworkElement element) { var screenGazePoint = ScreenHelpers.GetGazePointInScreenPixels(eyetracker); return(element.PointFromScreen(screenGazePoint)); }
private void ConnectToTracker(EyetrackerInfo info) { try { LogEvent.Engine.Write("Tracker: Connecting to " + info.Model); tracker = EyetrackerFactory.CreateEyetracker(info); tracker.ConnectionError += HandleConnectionError; connectionName = info.ProductId; syncManager = new SyncManager(clock, info); tracker.GazeDataReceived += tracker_GazeDataReceived; tracker.FramerateChanged += tracker_FramerateChanged; LogEvent.Engine.Write(string.Format("Connected to {0} FrameRate {1}.", info.Model, tracker.GetFramerate())); tracker.SetFramerate(60); ListFramerates(); IsConnected = true; } catch (EyetrackerException ee) { foreach (TraceListener tl in Trace.Listeners) { tl.Flush(); tl.Dispose(); } if (ee.ErrorCode == 0x20000402) { LogEvent.Engine.Write("Failed to upgrade protocol. " + "This probably means that the firmware needs" + " to be upgraded to a version that supports the new sdk."); } else LogEvent.Engine.Write("Eyetracker responded with error " + ee); DisconnectTracker(); } catch (Exception) { foreach (TraceListener tl in Trace.Listeners) { tl.Flush(); tl.Dispose(); } LogEvent.Engine.Write("Could not connect to eyetracker."); DisconnectTracker(); } }
// called when data for any output pin is requested public void Evaluate(int SpreadMax) { if (FInit) { FEyetrackerInfoIn.Changed += new SpreadChangedEventHander <EyetrackerInfo>(FEyetrackerInfo_Changed); } if (!FXConfigSetToOutput && FUpdateIn.IsChanged && FUpdateIn[0] == true) { ReadAndOutputXConfig(); } // Enabled true if ((FConnectionChanged || FEnable.IsChanged) && FEnable[0] == true) { try { if (FEyetrackerInfo != null) { FEyetrackerOut.SliceCount = FEyetrackerInfoIn.SliceCount; if (FSyncManager == null) { FClock = new Clock(); FSyncManager = new SyncManager(FClock, FEyetrackerInfo); FSyncManager.SyncManagerError += new EventHandler(FSyncManager_SyncManagerError); FSyncManager.SyncStateChanged += new EventHandler <SyncStateChangedEventArgs>(FSyncManager_SyncStateChanged); } if (FEyetracker == null) { // get tracker representation from EyetrackerInfo FEyetracker = EyetrackerFactory.CreateEyetracker(FEyetrackerInfo); FEyetracker.ConnectionError += new EventHandler <ConnectionErrorEventArgs>(FEyetracker_ConnectionError); FEyetracker.XConfigurationChanged += new EventHandler <XConfigurationChangedEventArgs>(FEyetracker_XConfigurationChanged); FEyetracker.FramerateChanged += new EventHandler <FramerateChangedEventArgs>(FEyetracker_FramerateChanged); FEyetrackerOut[0] = FEyetracker; ReadAndOutputXConfig(); } } } catch (EyetrackerException ex) { if (ex.ErrorCode == 0x20000402) { // trigger custom-error event for IS1Node FLogger.Log(LogType.Error, "EyetrackerException occured (errorCode " + ex.ErrorCode.ToString() + ") - Failed to upgrade protocol." + "This probably means that the firmware needs to be upgraded to a version that supports the new sdk."); } else { FLogger.Log(LogType.Error, "Error Code: " + ex.ErrorCode + " Message: " + ex.Message); } } catch (Exception e) { FLogger.Log(LogType.Error, "Could not connect to eyetracker. " + "Connection failed" + "(" + e.Message + ")"); } } // Enabled false else if ((FConnectionChanged || FEnable.IsChanged) && FEnable[0] == false) { // disconnect and stop eye tracker correctly if (FEyetracker != null) { FEyetracker.ConnectionError -= new EventHandler <ConnectionErrorEventArgs>(FEyetracker_ConnectionError); FEyetracker.Dispose(); FEyetracker = null; FEyetrackerOut.SliceCount = 1; } if (FSyncManager != null) { FSyncManager.SyncManagerError -= new EventHandler(FSyncManager_SyncManagerError); FSyncManager.SyncStateChanged -= new EventHandler <SyncStateChangedEventArgs>(FSyncManager_SyncStateChanged); FSyncManager.Dispose(); FSyncManager = null; FClock = null; } frameCount = 0; noXConfCount = 0; } // input params changed if (FSyncManager != null && FEyetracker != null) { if (FFramerateIn.IsChanged) { FEyetracker.SetFramerate(FFramerateIn[0]); } if (FUpdateIn.IsChanged && FUpdateIn[0] == true) { FSerial[0] = FEyetracker.GetUnitInfo().SerialNumber; IList <float> Framerate = FEyetracker.EnumerateFramerates(); FFramerates.SliceCount = Framerate.Count; if (Framerate.Count == 1) { FCurrentFramerate[0] = Framerate[0]; } for (int i = 0; i < Framerate.Count; i++) { FFramerates[i] = Framerate[i]; } try { IList <string> IlluminationModes = FEyetracker.EnumerateIlluminationModes(); FIlluminationMode.SliceCount = IlluminationModes.Count; for (int i = 0; i < IlluminationModes.Count; i++) { FIlluminationMode[i] = IlluminationModes[i]; } } catch (EyetrackerException ex) { FLogger.Log(LogType.Error, "Could not set illumination mode, " + ex.Message); } XConfiguration x = FEyetracker.GetXConfiguration(); FLowerLeft[0] = new Vector3D(x.LowerLeft.X, x.LowerLeft.Y, x.LowerLeft.Z) * 0.1; FUpperLeft[0] = new Vector3D(x.UpperLeft.X, x.UpperLeft.Y, x.UpperLeft.Z) * 0.1; FUpperRight[0] = new Vector3D(x.UpperRight.X, x.UpperRight.Y, x.UpperRight.Z) * 0.1; } if (FXConfigurationIn.IsChanged) { try { if (FXConfigurationIn[0] != null) { FEyetracker.SetXConfiguration(FXConfigurationIn[0]); } } catch (Exception ee) { FLogger.Log(LogType.Error, "Could not set XConfiguration, " + ee.Message); } } } if (FConnectionChanged && FEyetrackerInfo == null) { // Eyetracker has been disconnected, (recognized by error) } if (FEyetrackerInfoIn.IsChanged) { } FConnectionChanged = false; FInit = false; }
public static bool IsLookingAt(this IEyetracker eyetracker, FrameworkElement element) { var wpfGazePoint = WpfHelpers.GetRelativeGazePointForElement(eyetracker, element); return(WpfHelpers.IsLookingAtElement(wpfGazePoint, element)); }
public static Vector ToVector(this IEyetracker eyetracker) { return(new Vector(eyetracker.X, eyetracker.Y)); }
public MainWindow() { _eyeTracker = new Eyetracker(); InitializeComponent(); CompositionTarget.Rendering += delegate { Content = $"X: {_eyeTracker.X} Y: {_eyeTracker.Y}"; }; }
/// <summary> /// Connects to eyetracker and subscribes to events. Events are received on background thread. /// </summary> public void Connect() { try { eyetracker = EyetrackerFactory.CreateEyetracker(info, EventThreadingOptions.BackgroundThread); eyetracker.ConnectionError += ConnectionError; eyetracker.StartTracking(); } catch (EyetrackerException ee) { Disconnect(); if (ee.ErrorCode == 0x20000402) { throw new Exception("Failed to upgrade protocol. Upgrade firmware to version 2.0.0 or higher.", ee); } throw ee; } catch (Exception e) { Disconnect(); throw e; } }
private void _trackButton_Click(object sender, RoutedEventArgs e) { if(_tracking) { _tracker.GazeDataReceived -= _tracker_GazeDataReceived; _tracker.StopTracking(); _tracker.Dispose(); _trackButton.Content = "Track"; _tracking = false; } else { EyetrackerInfo etInfo = _trackerCombo.SelectedItem as EyetrackerInfo; if(etInfo != null) { _tracker = EyetrackerFactory.CreateEyetracker(etInfo); UpdateHeadMovementBox(); UpdateScreen(); _tracker.StartTracking(); _tracker.GazeDataReceived += _tracker_GazeDataReceived; _tracker.HeadMovementBoxChanged += _tracker_HeadMovementBoxChanged; _tracker.XConfigurationChanged += _tracker_XConfigurationChanged; _trackButton.Content = "Stop"; _tracking = true; } } }