Exemplo n.º 1
0
        protected override void StartAutoConnectThread()
        {
            if (_autoConnectThread != null)
            {
                return;
            }

            _autoConnectThread = new Thread(() =>
            {
                AutoConnectThreadRunning = true;

                while (AutoConnectThreadRunning)
                {
                    var eyeTrackers = EyeTrackingOperations.FindAllEyeTrackers();

                    foreach (var eyeTrackerEntry in eyeTrackers)
                    {
                        if (_connectToFirst || eyeTrackerEntry.SerialNumber.StartsWith(_eyeTrackerSerialStart))
                        {
                            FoundEyeTracker          = eyeTrackerEntry;
                            AutoConnectThreadRunning = false;
                            return;
                        }
                    }

                    Thread.Sleep(200);
                }
            });

            _autoConnectThread.IsBackground = true;
            _autoConnectThread.Start();
        }
Exemplo n.º 2
0
        protected override void StartAutoConnectThread()
        {
            if (_autoConnectThread != null)
            {
                return;
            }

            _autoConnectThread = new Thread(() => {
                AutoConnectThreadRunning = true;

                while (AutoConnectThreadRunning)
                {
                    var eyeTrackers = EyeTrackingOperations.FindAllEyeTrackers();

                    foreach (var eyeTrackerEntry in eyeTrackers)
                    {
                        FoundEyeTracker         = eyeTrackerEntry;
                        Settings.eyetrackerName = FoundEyeTracker.SerialNumber.ToString();
                        // Debug.Log (FoundEyeTracker.SerialNumber.ToString ());
                        AutoConnectThreadRunning   = false;
                        Settings.isFoundEyetracker = true;
                        return;
                    }

                    Thread.Sleep(200);
                }
            });

            _autoConnectThread.IsBackground = true;
            _autoConnectThread.Start();
        }
Exemplo n.º 3
0
    // Use this for initialization
    void Awake()
    {
        if (_instance == null)
        {
            _instance = this;

            bool result   = false;
            var  trackers = EyeTrackingOperations.FindAllEyeTrackers();
            EyeTrackerInstance = trackers.FirstOrDefault(s => (s.DeviceCapabilities & Capabilities.HasHMDGazeData) != 0);
            if (EyeTrackerInstance == null)
            {
                result = false;

                Debug.Log("No HMD eye tracker detected!");
            }
            else
            {
                result = true;
                isEyeTrackerConnected = true;
                Debug.Log("Selected eye tracker with serial number {0}" + EyeTrackerInstance.SerialNumber);
            }


            if (result == false)
            {
                Debug.LogError("TobiiPro: Failed to create tracker.");
            }
        }
    }
Exemplo n.º 4
0
        public Task StartAsync(IDialogContext context)
        {
            message_count = 0;
            EyeTrackerCollection ec = EyeTrackingOperations.FindAllEyeTrackers(); // もしくはGetEyeTracker で URI指定できるらしい

            eyeTracker = null;
            int i = ec.Count;

            //Console.WriteLine(
            System.Diagnostics.Debug.WriteLine("FindAllEyeTrackers()... {0} devices found.", i.ToString());
            //label1.Text = i.ToString();
            if (i > 0)
            {
                eyeTracker = ec[0];
            }

            //label2.Text = eyeTracker.Address.ToString();
            //label2.Text = label2.Text + ", " + eyeTracker.DeviceName;
            // return our reply to the user
            if (eyeTracker != null)
            {
                ApplyLicense(eyeTracker, @"c:\tobii\license\license_key_00401181_-_Kyoto_University_IS404-100106332951");
                GazeData(eyeTracker);
            }
            context.Wait(MessageReceivedAsync);

            return(Task.CompletedTask);
        }
Exemplo n.º 5
0
    // internal methods
    async void SearchEyeTrackers()
    {
        var collection = await EyeTrackingOperations.FindAllEyeTrackersAsync();

        if (collection.Count > 0)
        {
            var tracker = collection[0];

            try
            {
                _eyeTracker = EyeTrackingOperations.GetEyeTracker(tracker.Address);
            }
            catch (Exception ex)
            {
                Error(this, ex.Message);
            }

            if (_eyeTracker != null)
            {
                Ready(this, _eyeTracker.DeviceName);
            }
        }
        else
        {
            Invoke(nameof(SearchEyeTrackers), 5);
        }
    }
Exemplo n.º 6
0
        private void addUser_button_Click(object sender, EventArgs e)
        {
            if (mConfiguration.userNameList.Count == 0)
            {
                DialogResult result = MessageBox.Show("There is allready Profile in system." + "\nDo you want to add a new Profile?",
                                                      "Critical Warning",
                                                      MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question,
                                                      MessageBoxDefaultButton.Button2);

                if (result == DialogResult.Yes)
                {
                    var eyeTracker = EyeTrackingOperations.FindAllEyeTrackers().FirstOrDefault();
                    // EyeTrackerCollection eyeTrackers = EyeTrackingOperations.FindAllEyeTrackers();

                    if (eyeTracker == null)
                    {
                        MessageBox.Show("Cant find the Eye Tracker! \nPlease trye again.",
                                        "Critical Warning",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }


                    if (eyeTracker != null)
                    {
                        //FirstCalibrationWindow firstCalibrationWindow = new FirstCalibrationWindow();
                        // firstCalibrationWindow.Show();

                        CalibrationForm t = new CalibrationForm(eyeTracker);
                    }
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Connects to Tobii Pro Eye-Tracker
        /// </summary>
        /// <returns>Connection Success Message</returns>
        public override async Task <ApiResponseData> ConnectAsync()
        {
            IPAdress = "tet-tcp://" + Settings.Default.EyeTrackerIP + "/";

            try
            {
                EyeTracker = EyeTrackingOperations.GetEyeTracker(IPAdress);
            }
            catch (Exception ex)
            {
                // Likely wrong URI Format
                return(new ApiResponseData {
                    Message = ex.Message
                });
            }

            if (EyeTracker != null)
            {
                // Connection established
                Logger.Debug("Connected to " + EyeTracker.DeviceName + " width IP " + IPAdress);
                Console.WriteLine("Connected to " + EyeTracker.DeviceName + " width IP " + IPAdress);
                SubscribeToGazeDataAsync();
                IsConnected = true;
                return(new ApiResponseData {
                    Success = true
                });
            }
            else
            {
                return(new ApiResponseData {
                    Message = "Unable to connect to EyeTracker with IP " + IPAdress
                });
            }
        }
Exemplo n.º 8
0
        protected override void OnUpdate()
        {
            // Save the current pose for the current time.
            _eyeTrackerOriginPoses.Add(_eyeTrackerOrigin.GetPose(EyeTrackingOperations.GetSystemTimeStamp()));

            base.OnUpdate();
        }
Exemplo n.º 9
0
        public Keyhole(Keys overlayKey)
        {
            m_overlayKey = overlayKey;
            m_Ts         = new ThreadStart(DrawLoop);
            m_DrawThread = new Thread(m_Ts);

            // setup eye tracker
            m_EyeTracker = EyeTrackingOperations.FindAllEyeTrackers().FirstOrDefault();
            m_EyeTracker.GazeDataReceived += GazeDataReceived;

            // init gaze points
            ScreenGaze  = new ScreenGaze();
            GazeTargets = new List <GazeTarget>();

            Screen   = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
            window   = new Form1(this);
            m_Active = false;

            // keyboard / mouse
            m_Events          = Hook.GlobalEvents();
            m_Events.KeyDown += OnKeyDown;
            //m_Events.KeyUp += OnKeyUp;
            //m_Events.KeyPress += HookManager_KeyPress;
            m_Events.MouseMove += OnMouseMove;

            m_DrawThread.Start();
        }
Exemplo n.º 10
0
        protected override void OnUpdate()
        {
#if !USE_OPENVR_BINDINGS
            // Save the current pose for the current time adding estimated pose prediction time offset.
            _eyeTrackerOriginPoses.Add(_eyeTrackerOrigin.GetPose(EyeTrackingOperations.GetSystemTimeStamp() + Mathf.RoundToInt(_hmdPosePredictionOffset * 1000f)));
#endif
            base.OnUpdate();
        }
Exemplo n.º 11
0
        public void InitializeEyetracker()
        {
            var eyeTracker = EyeTrackingOperations.FindAllEyeTrackers().FirstOrDefault();

            getEyetrackerInformation();
            //ApplyLicense(eyeTracker, "C:\\Users\\Eyetracker\\OneDrive\\Eye tracking\\Magnifier Projects\\Experimentssss\\MagnifierLast\\MagnifierLast\\license\\license_key_00454713__-__Karlsruhe_Institute_of_IS404-100108245121");
            Console.WriteLine("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
        }
Exemplo n.º 12
0
        private void OnApplicationQuit()
        {
            if (_tooManyEyeTrackerInstances)
            {
                return;
            }

            EyeTrackingOperations.Terminate();
        }
Exemplo n.º 13
0
 //get 'all' of the eyetrackers (should only be 1) and puts it into array
 private void SetEyeTrackers()
 {
     eyeTrackers = EyeTrackingOperations.FindAllEyeTrackers();
     if (eyeTrackers.Count == 0)
     {
         Console.WriteLine("Eye tracker failed");
         TobiiEyeTrackerProcess.Close();
         Environment.Exit(-1);
     }
 }
Exemplo n.º 14
0
 private void OnApplicationQuit()
 {
     try
     {
         Debug.Log("Terminating eye tracker operation.");
         eyeTracker.GazeDataReceived -= EyeTracker_GazeDataReceived;
         EyeTrackingOperations.Terminate();
     }
     catch {}
 }
Exemplo n.º 15
0
        private void OnApplicationQuit()
        {
            if (_tooManyEyeTrackerInstances)
            {
                return;
            }

            SubscribeToUserPositionGuide = false;

            EyeTrackingOperations.Terminate();
        }
        public void Execute()
        {
            //tobi pro
            EyeTrackerCollection eyeTrackers = EyeTrackingOperations.FindAllEyeTrackers();

            //var eyeTracker = EyeTrackingOperations.FindAllEyeTrackers();
            foreach (IEyeTracker eyeTracker in eyeTrackers)
            {
                Console.WriteLine("xxx" + eyeTracker.Address);
                GazeData(eyeTracker);
            }
        }
Exemplo n.º 17
0
        /* protected void UpdateGazePosition(object s, StreamData<GazePointData> streamData)
         * {
         * sampleCount++;
         * sampleIndex++;
         * if (sampleIndex >= samples.Length)
         *     sampleIndex = 0;
         * samples[sampleIndex] = new Point((int)streamData.Data.X, (int)streamData.Data.Y);
         * }*/

        //############################################################################################

        public void Execute()
        {
            EyeTrackerCollection eyeTrackers = EyeTrackingOperations.FindAllEyeTrackers();

            //var eyeTracker = EyeTrackingOperations.FindAllEyeTrackers();
            foreach (IEyeTracker eyeTracker in eyeTrackers)
            {
                Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}", eyeTracker.Address, eyeTracker.DeviceName, eyeTracker.Model, eyeTracker.SerialNumber, eyeTracker.FirmwareVersion, eyeTracker.RuntimeVersion);

                GazeData(eyeTracker);
            }
        }
Exemplo n.º 18
0
 private void Start()
 {
     try
     {
         eyeTracker = EyeTrackingOperations.FindAllEyeTrackers()[0];
         eyeTracker.GazeDataReceived += EyeTracker_GazeDataReceived;
     }
     catch
     {
         Debug.LogError("Eye tracker not found!");
     }
 }
Exemplo n.º 19
0
        private void Update()
        {
            // Save the current pose for the current time.
            _eyeTrackerOriginPoses.Add(_eyeTrackerOrigin.GetPose(EyeTrackingOperations.GetSystemTimeStamp()));

            // Check for state transitions to or from subscribing.
            UpdateSubscriptions();

            if (_subscribeToGaze)
            {
                ProcessGazeEvents();
            }
        }
Exemplo n.º 20
0
        protected override void ProcessGazeEvents()
        {
            const int maxIterations = 20;

            var gazeData = _latestGazeData;

            for (int i = 0; i < maxIterations; i++)
            {
                var originalGaze = _originalGazeData.Next;

                // Queue empty
                if (originalGaze == null)
                {
                    break;
                }

#if USE_OPENVR_BINDINGS
                var now        = EyeTrackingOperations.GetSystemTimeStamp();
                var backInTime = (originalGaze.SystemTimeStamp - now) / 1000000.0f;

                // Look up OpenVR pose back when the eyetracker looked at the eyes.
                OpenVR.System.GetDeviceToAbsoluteTrackingPose(OpenVR.Compositor.GetTrackingSpace(), backInTime, poseArray);
                if (!poseArray[OpenVR.k_unTrackedDeviceIndex_Hmd].bPoseIsValid)
                {
                    Debug.Log("Failed to get historical pose");
                    continue;
                }

                var bestMatchingPose = HMDPoseToETPose(poseArray[OpenVR.k_unTrackedDeviceIndex_Hmd].mDeviceToAbsoluteTracking, now);
#else
                var bestMatchingPose = _eyeTrackerOriginPoses.GetBestMatchingPose(originalGaze.SystemTimeStamp);
                if (!bestMatchingPose.Valid)
                {
                    Debug.Log("Did not find a matching pose");
                    continue;
                }
#endif

                gazeData            = new VRGazeData(originalGaze, bestMatchingPose);
                _gazeDataQueue.Next = gazeData;
            }

            var queueCount = UnprocessedGazeDataCount;
            if (queueCount > 0)
            {
                Debug.LogWarning("We didn't manage to empty the queue: " + queueCount + " items left...");
            }

            _latestGazeData = gazeData;
        }
Exemplo n.º 21
0
        void Awake()
        {
            var trackers = EyeTrackingOperations.FindAllEyeTrackers();

            _eyeTracker = trackers.FirstOrDefault(s => (s.DeviceCapabilities & Capabilities.HasHMDGazeData) != 0);
            if (_eyeTracker == null)
            {
                Debug.Log("No HMD eye tracker detected!");
            }
            else
            {
                Debug.Log("Selected eye tracker with serial number {0}" + _eyeTracker.SerialNumber);
            }
        }
        private void StartCalibration_button_Click(object sender, EventArgs e)
        {
            //Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);
            var eyeTracker = EyeTrackingOperations.FindAllEyeTrackers().FirstOrDefault();

            // EyeTrackerCollection eyeTrackers = EyeTrackingOperations.FindAllEyeTrackers();

            if (eyeTracker != null)
            {
                Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}",
                                  eyeTracker.Address,
                                  eyeTracker.DeviceName,
                                  eyeTracker.Model,
                                  eyeTracker.SerialNumber,
                                  eyeTracker.FirmwareVersion,
                                  eyeTracker.RuntimeVersion);


                if (eyeTracker != null)
                {
                    if (BothEye_checkBox.Checked)
                    {
                        CalibrationTobii t = new CalibrationTobii(eyeTracker, mConfiguration, "BothEyes");
                        t.Show();
                    }

                    else if (RightEye_checkBox.Checked)
                    {
                        CalibrationTobii t = new CalibrationTobii(eyeTracker, mConfiguration, "RightEye");
                        t.Show();
                    }

                    else if (LeftEye_checkBox.Checked)
                    {
                        CalibrationTobii t = new CalibrationTobii(eyeTracker, mConfiguration, "LeftEye");
                        t.Show();
                    }
                }
            }

            else
            {
                DialogResult result = MessageBox.Show("Please connect the Eye tracker, then try again!",
                                                      "Critical Warning",
                                                      MessageBoxButtons.OK,
                                                      MessageBoxIcon.Error,
                                                      MessageBoxDefaultButton.Button2);
            }
        }
Exemplo n.º 23
0
            internal static EyeTrackerCollection Execute(Form1 formObject)
            {
                // <BeginExample>
                //Console.WriteLine("\nSearching for all eye trackers");
                EyeTrackerCollection eyeTrackers = EyeTrackingOperations.FindAllEyeTrackers();

                foreach (IEyeTracker eyeTracker in eyeTrackers)
                {
                    //Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}", eyeTracker.Address, eyeTracker.DeviceName, eyeTracker.Model, eyeTracker.SerialNumber, eyeTracker.FirmwareVersion, eyeTracker.RuntimeVersion);
                    var t_str = String.Format("{0}, {1}, {2}, {3}, {4}, {5}", eyeTracker.Address, eyeTracker.DeviceName, eyeTracker.Model, eyeTracker.SerialNumber, eyeTracker.FirmwareVersion, eyeTracker.RuntimeVersion);
                    formObject.UpdateLabel2Text(t_str);
                }
                // <EndExample>
                return(eyeTrackers);
            }
        void Awake()
        {
            var trackers = EyeTrackingOperations.FindAllEyeTrackers();

            foreach (IEyeTracker eyeTracker in trackers)
            {
                Debug.Log(string.Format("{0}, {1}, {2}, {3}, {4}", eyeTracker.Address, eyeTracker.DeviceName, eyeTracker.Model, eyeTracker.SerialNumber, eyeTracker.FirmwareVersion));
            }
            _eyeTracker = trackers.FirstOrDefault(s => (s.DeviceCapabilities & Capabilities.HasGazeData) != 0);
            if (_eyeTracker == null)
            {
                Debug.Log("No screen based eye tracker detected!");
            }
            else
            {
                Debug.Log("Selected eye tracker with serial number {0}" + _eyeTracker.SerialNumber);
            }
        }
Exemplo n.º 25
0
        private void ConnectToEyeTracker()
        {
            var eyeTracker = EyeTrackingOperations.FindAllEyeTrackers().FirstOrDefault();

            Console.WriteLine("Found eye tracker {0}", eyeTracker.Address);

            var calibrationValidation = new ScreenBasedCalibrationValidation(eyeTracker);

            var points = new NormalizedPoint2D[] {
                new NormalizedPoint2D(0.1f, 0.1f),
                new NormalizedPoint2D(0.1f, 0.9f),
                new NormalizedPoint2D(0.5f, 0.5f),
                new NormalizedPoint2D(0.9f, 0.1f),
                new NormalizedPoint2D(0.9f, 0.9f)
            };

            calibrationValidation.EnterValidationMode();

            foreach (var point in points)
            {
                Console.WriteLine("Collecting for point {0}, {1}", point.X, point.Y);

                calibrationValidation.StartCollectingData(point);
                while (calibrationValidation.State == ScreenBasedCalibrationValidation.ValidationState.CollectingData)
                {
                    System.Threading.Thread.Sleep(25);
                }
            }

            var result = calibrationValidation.Compute();

            Console.WriteLine(calibrationValidation);
            calibrationValidation.LeaveValidationMode();


            // mogucnost 2

            /*
             * var host = new Host();
             * var gazePointDataStream = host.Streams.CreateGazePointDataStream();
             * gazePointDataStream.GazePoint((gazePointX, gazePointY, _) => Console.WriteLine("X: {0} Y:{1}", gazePointX, gazePointY));
             */
        }
Exemplo n.º 26
0
        static EyeTrackerCollection getEyetrackerInformation()
        {
            // <BeginExample>
            Console.WriteLine("\nSearching for all eye trackers");
            EyeTrackerCollection eyeTrackers = EyeTrackingOperations.FindAllEyeTrackers();

            foreach (IEyeTracker eyeTracker in eyeTrackers)
            {
                Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}",
                                  eyeTracker.Address,
                                  eyeTracker.DeviceName,
                                  eyeTracker.Model,
                                  eyeTracker.SerialNumber,
                                  eyeTracker.FirmwareVersion,
                                  eyeTracker.RuntimeVersion);
            }
            // <EndExample>
            return(eyeTrackers);
        }
Exemplo n.º 27
0
        private void Calibration_Button_Click(object sender, EventArgs e)
        {
            var eyeTracker = EyeTrackingOperations.FindAllEyeTrackers().FirstOrDefault();

            // EyeTrackerCollection eyeTrackers = EyeTrackingOperations.FindAllEyeTrackers();

            if (eyeTracker != null)
            {
                Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}",
                                  eyeTracker.Address,
                                  eyeTracker.DeviceName,
                                  eyeTracker.Model,
                                  eyeTracker.SerialNumber,
                                  eyeTracker.FirmwareVersion,
                                  eyeTracker.RuntimeVersion);

                CalibrationForm t = new CalibrationForm(eyeTracker);
                t.Show();
                //CalibrationWindow cal = new CalibrationWindow(eyeTracker);
                //cal.Show();
            }
        }
Exemplo n.º 28
0
        static void Main(string[] args)
        {
            Console.WriteLine("\nSearching for all eye trackers");
            EyeTrackerCollection eyeTrackers = EyeTrackingOperations.FindAllEyeTrackers();

            foreach (IEyeTracker eyeTracker in eyeTrackers)
            {
                Console.WriteLine("{0}, {1}, {2}, {3}, {4}", eyeTracker.Address, eyeTracker.DeviceName, eyeTracker.Model, eyeTracker.SerialNumber, eyeTracker.FirmwareVersion);
            }
            var    myEyeTracker = eyeTrackers.First();
            string license      = @"license_key_IS404-100106240232";

            ApplyLicense(myEyeTracker, license);

            Console.WriteLine("\nWrite the output file name (without extension): ");
            string filenameWithoutExtention = Console.ReadLine();

            Record record = new Record(filenameWithoutExtention, myEyeTracker);

            Console.WriteLine("Listening for gaze data, press 'q' to quit or any key to start/stop the recording...");
            // Let it run until a key is pressed.
            record.recordLoop();

            //Save the files
            record.saveFiles();

            //Dispose
            record.Dispose();

            string screenShot = filenameWithoutExtention + ".png";

            record.screenshot(screenShot);
            //Process the fix file
            string fileOutput = AnalazingEyeGaze.Program.processOneFile(filenameWithoutExtention, screenShot);

            ModelUtpal.Program.processOnefile(fileOutput);
        }
Exemplo n.º 29
0
        private void FillInAvailableTrackers()
        {
            try
            {
                AvailableTrackers = EyeTrackingOperations.FindAllEyeTrackers();
                foreach (IEyeTracker eyeTracker in AvailableTrackers)
                {
                    if (!TrackerListComboBox.Items.Contains(eyeTracker.SerialNumber))
                    {
                        TrackerListComboBox.Items.Add(eyeTracker.SerialNumber);
                    }
                }
                TrackerListComboBox.SelectedIndex = 0;

                CalibrationPanel.Enabled = (AvailableTrackers.Count > 0);
                WAMPPanel.Enabled        = (AvailableTrackers.Count > 0);
                SelectedTracker          = AvailableTrackers.ElementAt(TrackerListComboBox.SelectedIndex);
            }
            catch (Exception exp)
            {
                SelectedTracker = null;
                Console.Write(exp);
            }
        }
Exemplo n.º 30
0
 void OnDestroy()
 {
     EyeTrackingOperations.Terminate();
 }