private static string CoreLibraryVersion() { using (var lib = new EyeTrackerCoreLibrary()) { return(lib.LibraryVersion()); } }
private bool InitializeEyeTracker() { Uri url = new EyeTrackerCoreLibrary().GetConnectedEyeTracker(); if (url == null) { return(false); } _eyeTracker = new EyeTracker(url); if (_eyeTracker == null) { return(false); } _eyeTracker.EyeTrackerError += OnEyeTrackerError; _eyeTracker.GazeData += OnEyeTrackerGazeData; _trackingThread = new Thread(new ThreadStart(EyeTrackerEventLoop)); _trackingThread.Start(); if (!_eyeTracker.Connected) { _eyeTracker.Connect(); _eyeTracker.StartTracking(); } return(true); }
private static EyeTracker GetConnectedEyeTracker() { // Get the URL to the eye tracker. var url = new EyeTrackerCoreLibrary().GetConnectedEyeTracker(); // eye tracker. return(new EyeTracker(url)); }
public void Initialize() { Uri url = new EyeTrackerCoreLibrary().GetConnectedEyeTracker(); if (url == null) { throw new ApplicationException("No eye tracker found, check cable!"); } else { tracker = new EyeTracker(url); eventLoop = CreateAndRunEventLoopThread(tracker); tracker.Connect(); } }
public void Initialize() { Uri url = new EyeTrackerCoreLibrary().GetConnectedEyeTracker(); if (url == null) { throw new ApplicationException("No eye tracker found, check cable!"); } else { tracker = new EyeTracker(url); eventLoop = CreateAndRunEventLoopThread(tracker); tracker.Connect(); } }
/// <summary> /// Initializes a new instance of the <see cref="CalibrationViewModel"/> class. /// </summary> /// <param name="dispatcher">Dispatcher used for marshaling operations to the main thread.</param> /// <param name="eyeTrackerUrl">Eye tracker URL.</param> /// <param name="exitAction">Delegate invoked to exit the application.</param> public CalibrationViewModel(Dispatcher dispatcher, string eyeTrackerUrl, Action exitAction) { _dispatcher = dispatcher; _exitAction = exitAction; Stage = WpfCalibrationSample.Stage.Initializing; ContinueCommand = new ActionCommand(Continue); ExitCommand = new ActionCommand(exitAction); EyePositions = new ObservableCollection <Point>(); Uri url; if (eyeTrackerUrl == "--auto") { url = new EyeTrackerCoreLibrary().GetConnectedEyeTracker(); if (url == null) { Stage = WpfCalibrationSample.Stage.Error; ErrorMessage = "No eye tracker found."; return; } } else { try { url = new Uri(eyeTrackerUrl); } catch (UriFormatException) { Stage = WpfCalibrationSample.Stage.Error; ErrorMessage = "Invalid eye tracker URL."; return; } } InitializeEyeTracker(url); }
public static void Main(string[] args) { Uri url = null; if (args.Length == 1) { if (args[0] == "--auto") { url = new EyeTrackerCoreLibrary().GetConnectedEyeTracker(); if (url == null) { Console.WriteLine("No eye tracker found"); return; } } else if (args[0] == "--list") { ListConnectedEyeTrackers(); return; } else { url = new Uri(args[0]); } } else { Console.WriteLine("usage: MinimalTrackerNet {url|--auto|--list}"); return; } IEyeTracker tracker = null; Thread thread = null; try { Console.WriteLine("TobiiGazeCore DLL version: {0}", CoreLibraryVersion()); Console.WriteLine("Creating eye tracker with url {0}.", url); tracker = new EyeTracker(url); tracker.EyeTrackerError += EyeTrackerError; tracker.GazeData += EyeTrackerGazeData; thread = CreateAndRunEventLoopThread(tracker); Console.WriteLine("Connecting..."); tracker.Connect(); Console.WriteLine("Connected"); // Good habit to start by retrieving device info to check that communication works. PrintDeviceInfo(tracker); Console.WriteLine("Start tracking..."); tracker.StartTracking(); Console.WriteLine("Tracking started"); // Let eye tracker track for 20 s. Thread.Sleep(20000); Console.WriteLine("Stop tracking..."); tracker.StopTracking(); Console.WriteLine("Stopped tracking"); Console.WriteLine("Disconnecting..."); tracker.Disconnect(); Console.WriteLine("Disconnected"); } catch (EyeTrackerException ex) { Console.WriteLine(ex.Message); } finally { if (thread != null) { tracker.BreakEventLoop(); thread.Join(); } if (tracker != null) { tracker.Dispose(); } } }