Exemplo n.º 1
0
        private void EyeXHost_UserPresenceChanged(object sender, EngineStateValue <UserPresence> value)
        {
            //ignore any user presence change during calibration
            if (_isCalibrating)
            {
                return;
            }

            //!!With the above checking, below isn't necesary
            //check state and see if in calibration, then ignore this event
            //EngineStateValue<EyeTrackingDeviceStatus> deviceState = _eyeXHost.EyeTrackingDeviceStatus;
            //if (deviceState.IsValid && (deviceState.Value == EyeTrackingDeviceStatus.Configuring || deviceState.Value == EyeTrackingDeviceStatus.Initializing))
            //    return;

            bool isUserPresent = value.IsValid && value.Value == UserPresence.Present;

            //add delay , only call when present for 2s

            SetDelayedUserPresentAsync(isUserPresent);

            // State-changed events are received on a background thread.
            // But operations that affect the GUI must be executed on the main thread.
            RunOnMainThread(() =>
            {
                Console.WriteLine("User Presenence changed: " + value.IsValid + " " + value.Value);
                IsUserPresent = isUserPresent;
            });
        }
Exemplo n.º 2
0
 void DeviceStatusHandler(object sender, EngineStateValue <EyeTrackingDeviceStatus> e)
 {
     _dispatcher.Invoke(() =>
     {
         _deviceStatus = GetDeviceStatus(e);
         _semaphore.Release();
     });
 }
Exemplo n.º 3
0
 void ConfigurationStatusHandler(object sender, EngineStateValue <EyeTrackingConfigurationStatus> e)
 {
     _dispatcher.Invoke(() =>
     {
         _configurationStatus = GetConfigurationStatus(e);
         _semaphore.Release();
     });
 }
Exemplo n.º 4
0
 private void presenceObserverChange(object sender, EngineStateValue <UserPresence> e)
 {
     if (e.IsValid)
     {
         NextUserPresenceMessage = new UserPresenceMessage(e.Value == UserPresence.Present);
     }
     //Console.WriteLine($"Presence observer value: {e.Value} (Valid: {e.IsValid})");
 }
Exemplo n.º 5
0
        private static void OnGazeTrackingStateChanged(object sender, EngineStateValue<Tobii.Interaction.Framework.GazeTracking> state)
        {
            if(state.IsValid)
                Console.WriteLine("Gaze tracking state is: {0}", state.Value);

            // Note: To play around with this state, click on Tobii Eye Tracking tray icon,
            //       and in the menu which is appeared try to turn eyetracking on/off again.
        }
Exemplo n.º 6
0
 /// <summary>
 /// Right after calibration has started, awaits for engine to start tracking, meaning the calibration has ended.
 /// Unregisters itself, and allows command to be terminated
 /// </summary>
 /// <param name="source">Engine that sends the event</param>
 /// <param name="evt">New engine state</param>
 protected void OnStatusChanged(Object source, EngineStateValue <EyeTrackingDeviceStatus> evt)
 {
     if (evt.Value == EyeTrackingDeviceStatus.Tracking)
     {
         IsRunning = false;
         Engine.EyeTrackingDeviceStatusChanged -= OnStatusChanged;
         Console.WriteLine("calibration finished");
     }
 }
Exemplo n.º 7
0
 private void EyeXHost_GazeTrackingChanged(object sender, EngineStateValue <GazeTracking> value)
 {
     // State-changed events are received on a background thread.
     // But operations that affect the GUI must be executed on the main thread.
     RunOnMainThread(() =>
     {
         IsTrackingGaze = value.IsValid && value.Value == GazeTracking.GazeTracked;
     });
 }
Exemplo n.º 8
0
 private void EyeXHost_UserPresenceChanged(object sender, EngineStateValue <UserPresence> value)
 {
     // State-changed events are received on a background thread.
     // But operations that affect the GUI must be executed on the main thread.
     RunOnMainThread(() =>
     {
         IsUserPresent = value.IsValid && value.Value == UserPresence.Present;
     });
 }
Exemplo n.º 9
0
 private void EyeXHost_EyeTrackingDeviceStatusChanged(object sender, EngineStateValue <EyeTrackingDeviceStatus> value)
 {
     Console.WriteLine(" Tracking Status changed: " + value.IsValid + " " + value.Value);
     //TEMP workaround to track when calibrating is done: first 'tracking' state deflags calibrating state
     if (_isCalibrating && value.IsValid && value.Value == EyeTrackingDeviceStatus.Tracking)
     {
         _isCalibrating = false;
         //Console.WriteLine(_calibrationAsyncData);
     }
 }
Exemplo n.º 10
0
        private void EyeXHost_UserPresenceChanged(object sender, EngineStateValue <UserPresence> e)
        {
            // State-changed events are received on a background thread.
            // But operations that affect the GUI must be executed on the main thread.
            // We use BeginInvoke to marshal the call to the main thread.

            if (Created)
            {
                BeginInvoke(new Action(() => UpdateUserPresence(e)));
            }
        }
Exemplo n.º 11
0
        private void HostOnUserPresenceChanged(object sender, EngineStateValue <UserPresence> engineStateValue)
        {
            if (!engineStateValue.IsValid)
            {
                return;
            }

            UserPresence = engineStateValue.Value;
            UpdateReason = UpdateReason.UserPresenceChanged;
            OnUpdate();
        }
Exemplo n.º 12
0
        private void HostOnEyeTrackingDeviceStatusChanged(object sender, EngineStateValue <EyeTrackingDeviceStatus> engineStateValue)
        {
            if (!engineStateValue.IsValid)
            {
                return;
            }

            DeviceStatus = engineStateValue.Value;
            UpdateReason = UpdateReason.DeviceStatusChanged;
            OnUpdate();
        }
Exemplo n.º 13
0
        private void HostOnUserProfileNameChanged(object sender, EngineStateValue <string> engineStateValue)
        {
            if (!engineStateValue.IsValid)
            {
                return;
            }

            CurrentProfileName = engineStateValue.Value;
            UpdateReason       = UpdateReason.CurrentProfileNameChanged;
            OnUpdate();
        }
Exemplo n.º 14
0
 public void GetPresence(object sender, EngineStateValue <UserPresence> e)
 {
     if (eHost.UserPresence.ToString() == "NotPresent")
     {
         userNotPresence = true;
     }
     if (eHost.UserPresence.ToString() == "Present")
     {
         userNotPresence = false;
     }
 }
Exemplo n.º 15
0
        private void HostOnDisplaySizeChanged(object sender, EngineStateValue <Size> engineStateValue)
        {
            if (!engineStateValue.IsValid)
            {
                return;
            }

            DisplaySize  = engineStateValue.Value;
            UpdateReason = UpdateReason.DisplaySizeChanged;
            //OnUpdate();
        }
Exemplo n.º 16
0
        private void HostOnDisplaySizeChanged(object sender, EngineStateValue <Size2> engineStateValue)
        {
            if (!engineStateValue.IsValid)
            {
                return;
            }

            DisplaySize  = new Vector2((float)engineStateValue.Value.Width, (float)engineStateValue.Value.Height);
            UpdateReason = UpdateReason.DisplaySizeChanged;
            OnUpdate();
        }
Exemplo n.º 17
0
 private void EyeXHost_EyeTrackingDeviceStatusChanged(object sender, EngineStateValue <EyeTrackingDeviceStatus> e)
 {
     if (AutoAlarm && e.Value.Equals(EyeTrackingDeviceStatus.DeviceNotConnected))
     {
         ALSAlarm alarm = new ALSAlarm();
         if (!alarm.isAlarmOn())
         {
             alarm.PerformClick();
         }
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            EngineStateValue <Tobii.Interaction.Framework.GazeTracking> status = Program.EyeXHost.States.GetGazeTrackingAsync().Result;

            Console.WriteLine("XXXXX  " + Tobii.Interaction.Framework.GazeTracking.GazeTracked);

            /*var gazePointDataStream = host.Streams.CreateGazePointDataStream();
             * gazePointDataStream.GazePoint((gazePointX, gazePointY, _) => Console.WriteLine("X: {0} Y:{1}", gazePointX, gazePointY));*/
            EytrackerInit eyI = new EytrackerInit();

            eyI.InitializeEyetracker();
        }
Exemplo n.º 19
0
 private void UpdateUserPresence(EngineStateValue <UserPresence> value)
 {
     if (value.IsValid &&
         value.Value == UserPresence.Present)
     {
         pictureBox1.ImageLocation  = "Images/present.png";
         _labelHasUserPresence.Text = "Yes";
     }
     else
     {
         pictureBox1.ImageLocation  = "Images/not-present.png";
         _labelHasUserPresence.Text = "No";
     }
 }
        /// <summary>
        /// getting the gaze's status of the user (looking or not looking at the screen)
        /// using it to detect blink and depending on wich timer is running
        /// freeze the cursor, click and/or start another timer
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e">EngineStateValue<GazeTracking></param>
        public void OnGazeTrackingChangedEvent(Object source, EngineStateValue <GazeTracking> e)
        {
            //Console.WriteLine("Gaze tracking (state-changed event): {0}", e);

            if (e.Value.ToString().Equals("GazeNotTracked"))
            {
                OnGazeNotTracked(new EventArgs());
            }

            if (e.Value.ToString().Equals("GazeTracked"))
            {
                OnGazeTracked(new EventArgs());
            }
        }
Exemplo n.º 21
0
        public void GetGaze(object sender, EngineStateValue <GazeTracking> e)
        {
            if (eHost.GazeTracking.ToString() == "GazeNotTracked")
            {
                gazeNotTracked = true;

                hasGazed = false;
            }
            if (eHost.GazeTracking.ToString() == "GazeTracked")
            {
                gazeNotTracked = false;

                hasGazed = true;
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Combines the provided profiles with a sequence of <see cref="ConsoleKey"/>.
        /// </summary>
        /// <param name="profiles">The profiles to create key bindings for.</param>
        /// <returns>A dictionary of profile key bindings.</returns>
        private static IDictionary <ConsoleKey, string> CreateKeyBindings(EngineStateValue <string[]> profiles)
        {
            var bindings = new Dictionary <ConsoleKey, string>();

            if (profiles.IsValid)
            {
                const int startIndex = (int)ConsoleKey.F1;
                var       maxIndex   = startIndex + profiles.Value.Length;
                for (var index = startIndex; index < maxIndex; index++)
                {
                    bindings.Add((ConsoleKey)index, profiles.Value[index - startIndex]);
                }
            }
            return(bindings);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Combines the provided profiles with a sequence of <see cref="ConsoleKey"/>.
        /// </summary>
        /// <param name="profiles">The profiles to create key bindings for.</param>
        /// <returns>A dictionary of profile key bindings.</returns>
        private static IDictionary<ConsoleKey, string> CreateKeyBindings(EngineStateValue<string[]> profiles)
        {
            var bindings = new Dictionary<ConsoleKey, string>();
            if (profiles.IsValid)
            {
                const int startIndex = (int)ConsoleKey.F1;
                var maxIndex = startIndex + profiles.Value.Length;
                for (var index = startIndex; index < maxIndex; index++)
                {
                    bindings.Add((ConsoleKey)index, profiles.Value[index - startIndex]);
                }

            }
            return bindings;
        }
Exemplo n.º 24
0
 private void EyeXHost_UserPresenceChanged(object sender, EngineStateValue <UserPresence> e)
 {
     try
     {
         if (AutoAlarm && e.Value.Equals(UserPresence.NotPresent))
         {
             StartTimer();
         }
         else
         {
             CVInterface.timer.Stop();
         }
     }
     catch (Exception) { }
 }
Exemplo n.º 25
0
        private void EyeXHost_GazeTrackingChanged(object sender, EngineStateValue <GazeTracking> e)
        {
            // State-changed events are received on a background thread.
            // But operations that affect the GUI must be executed on the main thread.
            // We use BeginInvoke to marshal the call to the main thread.

            if (Created)
            {
                BeginInvoke(new Action(() =>
                {
                    if (e.IsValid && e.Value == GazeTracking.GazeTracked)
                    {
                        _labelHasGazeTracking.Text = "Yes";
                    }
                    else
                    {
                        _labelHasGazeTracking.Text = "No";
                    }
                }));
            }
        }
Exemplo n.º 26
0
        private void EyeXHost_GazeTrackingChanged(object sender, EngineStateValue<GazeTracking> e)
        {
            // State-changed events are received on a background thread.
            // But operations that affect the GUI must be executed on the main thread.
            // We use BeginInvoke to marshal the call to the main thread.

            if (Created)
            {
                BeginInvoke(new Action(() =>
                {
                    if (e.IsValid && e.Value == GazeTracking.GazeTracked)
                    {
                        _labelHasGazeTracking.Text = "Yes";
                    }
                    else
                    {
                        _labelHasGazeTracking.Text = "No";
                    }
                }));
            }
        }
Exemplo n.º 27
0
 private void UpdateUserPresence(EngineStateValue<UserPresence> value)
 {
     if (value.IsValid &&
         value.Value == UserPresence.Present)
     {
         pictureBox1.ImageLocation = "Images/present.png";
         _labelHasUserPresence.Text = "Yes";
     }
     else
     {
         pictureBox1.ImageLocation = "Images/not-present.png";
         _labelHasUserPresence.Text = "No";
     }
 }
Exemplo n.º 28
0
 static EyeTrackingConfigurationStatus GetConfigurationStatus(EngineStateValue <EyeTrackingConfigurationStatus> status)
 {
     return(status.IsValid ? status.Value : default(EyeTrackingConfigurationStatus));
 }
Exemplo n.º 29
0
 private void EyeXHost_UserPresenceChanged(object sender, EngineStateValue<UserPresence> value)
 {
     // State-changed events are received on a background thread.
     // But operations that affect the GUI must be executed on the main thread.
     RunOnMainThread(() =>
     {
         IsUserPresent = value.IsValid && value.Value == UserPresence.Present;
     });
 }
Exemplo n.º 30
0
 private void EyeXHost_GazeTrackingChanged(object sender, EngineStateValue<GazeTracking> value)
 {
     // State-changed events are received on a background thread.
     // But operations that affect the GUI must be executed on the main thread.
     RunOnMainThread(() =>
     {
         IsTrackingGaze = value.IsValid && value.Value == GazeTracking.GazeTracked;
     });
 }
        //############################################################################################
        public bool IsStarted()
        {
            EngineStateValue <Tobii.Interaction.Framework.GazeTracking> status = Program.EyeXHost.States.GetGazeTrackingAsync().Result;

            return(status.Value == Tobii.Interaction.Framework.GazeTracking.GazeTracked);
        }
Exemplo n.º 32
0
 private void EyeXHost_UserPresenceChanged(object sender, EngineStateValue<UserPresence> e)
 {
     try
     {
         if (AutoAlarm && e.Value.Equals(UserPresence.NotPresent))
         {
             StartTimer();
         }
         else
         {
             CVInterface.timer.Stop();
         }
     }
     catch (Exception) { }
 }
Exemplo n.º 33
0
 private void EyeXHost_EyeTrackingDeviceStatusChanged(object sender, EngineStateValue<EyeTrackingDeviceStatus> e)
 {
     if (AutoAlarm && e.Value.Equals(EyeTrackingDeviceStatus.DeviceNotConnected))
     {
         ALSAlarm alarm = new ALSAlarm();
         if (!alarm.isAlarmOn())
         {
             alarm.PerformClick();
         }
     }
 }
Exemplo n.º 34
0
 static EyeTrackingDeviceStatus GetDeviceStatus(EngineStateValue <EyeTrackingDeviceStatus> status)
 {
     return(status.IsValid ? status.Value : default(EyeTrackingDeviceStatus));
 }
Exemplo n.º 35
0
        private void EyeXHost_UserPresenceChanged(object sender, EngineStateValue<UserPresence> e)
        {
            // State-changed events are received on a background thread.
            // But operations that affect the GUI must be executed on the main thread.
            // We use BeginInvoke to marshal the call to the main thread.

            if (Created)
            {
                BeginInvoke(new Action(() => UpdateUserPresence(e)));
            }
        }