public TobiiInteractionEngineTracker()
    {
        _host = new EyeXHost();
        _host.Start();
        _lightlyFilteredGazePointDataProvider = _host.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered);
        _lightlyFilteredGazePointDataProvider.Next += NewGazePoint;

        AspectRatio = 16f / 9f;
        IsHeadTracking = false;
    }
        private void setup()
        {
            host_ = new EyeXHost();
            {
                stream_ = host_.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered);
                {
                    host_.Start();

                    stream_.Next += (s, e) => {
                        gazeX_ = e.X;
                        gazeY_ = e.Y;
                    };
                }
            }
        }
        public Gta5EyeTracking()
        {
            Util.Log("Begin Initialize");
            _shutDownRequestedEvent = new ManualResetEvent(false);
            _aspectRatio = 1;
            _host = new EyeXHost();
            _host.Start();
            _lightlyFilteredGazePointDataProvider = _host.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered);
            _lightlyFilteredGazePointDataProvider.Next += NewGazePoint;

            _menuPool = new MenuPool();

            LoadSettings();
            _settingsMenu = new SettingsMenu(_menuPool, _settings);
            _deadzoneEditor = new DeadzoneEditor(_settings,_settingsMenu);

            _settingsMenu.ShutDownRequested += SettingsMenuOnShutDownRequested;

            _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();

            KeyDown += OnKeyDown;

            Tick += OnTick;
            Util.Log("End Initialize");
        }
Example #4
0
        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();
                }
            }
        }
Example #5
0
 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();
         }
     }
 }
        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");
        }
Example #7
0
        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
   
        }
Example #8
0
        public void StartServer()
        {
            this.eyeXHost = new EyeXHost();
            this.eyeXHost.Start();
            this.gazeDataStream = eyeXHost.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered);
            this.gazeDataStream.Next += new System.EventHandler<EyeXFramework.GazePointEventArgs>(this.HandleEyeGazeEvent);

            this.fixationDataStream = eyeXHost.CreateFixationDataStream(FixationDataMode.Slow);
            this.fixationDataStream.Next += new System.EventHandler<EyeXFramework.FixationEventArgs>(this.HandleEyeFixationEvent);

            try
            {
                IPAddress ipAddr = IPAddress.Parse(host);
                tcpServer = new TcpClient();
                tcpServer.Connect(ipAddr, port);
                swSender = new StreamWriter(tcpServer.GetStream());
            }
            catch
            {
                this.StopServer();
            }
        }
Example #9
-1
        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;
        }