Exemplo n.º 1
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.º 2
0
 public ScreenGaze(ScreenGaze other)
 {
     m_GazeLeft.X        = other.m_GazeLeft.X;
     m_GazeLeft.Y        = other.m_GazeLeft.Y;
     m_GazeRight.X       = other.m_GazeRight.X;
     m_GazeRight.Y       = other.m_GazeRight.Y;
     m_GazePoint.X       = other.m_GazePoint.X;
     m_GazePoint.Y       = other.m_GazePoint.Y;
     m_GazeRect.Location = other.m_GazeRect.Location;
     m_GazeRect.Size     = other.m_GazeRect.Size;
 }
Exemplo n.º 3
0
        //--------------------------------------------------------------------
        // High Level Functions
        //--------------------------------------------------------------------

        private void GazeSnapshot()
        {
            //
            // make a copy of the current gaze data
            //

            lock (ScreenGaze)
                ScreenGazeSnapshot = new ScreenGaze(ScreenGaze);

            //
            // take a screenshot of the desktop and crop it to the user gaze
            //

            var      screenshot = this.TakeScreenshot();
            var      crop       = new Bitmap(ScreenGazeSnapshot.m_GazeRect.Width, ScreenGazeSnapshot.m_GazeRect.Height);
            Graphics g          = Graphics.FromImage(crop);

            g.DrawImage(screenshot, -ScreenGazeSnapshot.m_GazeRect.X, -ScreenGazeSnapshot.m_GazeRect.Y);

            //
            // use 'CV' techniques to identify on-screen click targets
            //

            var rects = do_cv(crop);

            //
            // convert the on-screen 'rectangles' to higher level 'gaze targets' for rendering
            //

            // TODO: we should put this in a config somewhere and allow the user to specify it
            var allowedLabels = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";

            GazeTargets.Clear();
            for (int i = 0; i < rects.Count; i++)
            {
                var r = rects[i];

                // TODO: we only assign as many unique labels as we have...
                var targetLabel = "";
                if (i < allowedLabels.Length)
                {
                    targetLabel = allowedLabels[i].ToString();
                }

                GazeTargets.Add(new GazeTarget(targetLabel, new Rectangle(r.X, r.Y, r.Width, r.Height)));
            }

            Console.WriteLine("done");
            m_Active = true;
            m_Dirty  = true;
        }