예제 #1
0
        public MainWindow()
        {
            InitializeComponent();

            this.kinectManager = KinectManager.Default;

            //setup the cursor with images
            Image[] cursorImages = new Image[3];
            Image cursorImage0 = new Image();
            cursorImage0.Source = ImageExtensions.ToBitmapSource(KinectShowcase.Properties.Resources.hand1);
            cursorImages[0] = cursorImage0;
            Image cursorImage1 = new Image();
            cursorImage1.Source = ImageExtensions.ToBitmapSource(KinectShowcase.Properties.Resources.hand2);
            cursorImages[1] = cursorImage1;
            Image cursorImage2 = new Image();
            cursorImage2.Source = ImageExtensions.ToBitmapSource(KinectShowcase.Properties.Resources.hand3);
            cursorImages[2] = cursorImage2;

            this.cursorView.SetCursorImages(cursorImages);

            this.kinectManager.HandManager.Cursor = this.cursorView;
            this.kinectManager.AddStateListener(this);
            //this.kinectRegion.KinectSensor = this.kinectManager.KinectSensor;

            ViewModelLocator.Locator().ApplicationViewModel.SkeletonView = this.skeletonView;
        }
예제 #2
0
        public MainWindow()
        {
            InitializeComponent();

            this.kinectManager = KinectManager.Default;

            //setup the cursor with images
            Image[] cursorImages = new Image[3];
            Image cursorImage0 = new Image();
            cursorImage0.Source = ImageExtensions.ToBitmapSource(KinectShowcaseGameTemplate.Properties.Resources.hand1);
            cursorImages[0] = cursorImage0;
            Image cursorImage1 = new Image();
            cursorImage1.Source = ImageExtensions.ToBitmapSource(KinectShowcaseGameTemplate.Properties.Resources.hand2);
            cursorImages[1] = cursorImage1;
            Image cursorImage2 = new Image();
            cursorImage2.Source = ImageExtensions.ToBitmapSource(KinectShowcaseGameTemplate.Properties.Resources.hand3);
            cursorImages[2] = cursorImage2;

            this.cursorView.SetCursorImages(cursorImages);

            this.kinectManager.HandManager.Cursor = this.cursorView;
            this.kinectManager.AddStateListener(this);
            //this.kinectRegion.KinectSensor = this.kinectManager.KinectSensor;

            this.SkeletonView = skeletonView;
            this.SkeletonView.ShouldDrawHeadJoint = false;

            _mainFrame.NavigationUIVisibility = NavigationUIVisibility.Hidden;
            _mainFrame.Navigate(new MainPage());
        }
예제 #3
0
 public void KinectManagerDidUpdateState(KinectManager aManager, bool aIsKinectActive)
 {
     if (!aIsKinectActive)
     {
         //make stuff visibile
         ViewModelLocator.Locator().HomeViewModel.KinectManagerDidBeginTracking(null);
     }
 }
예제 #4
0
 public KinectButton()
     : base()
 {
     if (!DesignerProperties.GetIsInDesignMode(this))
     {
         _kinectManager = KinectManager.Default;
         if (_kinectManager != null)
         {
             _kinectManager.HandManager.AddHandStateChangeListener(this);
             _kinectManager.HandManager.AddHandLocationListener(this);
         }
     }
 }
예제 #5
0
 public void KinectManagerDidUpdateState(KinectManager aManager, bool aIsKinectActive)
 {
     Dispatcher.InvokeAsync((Action)delegate()
     {
         if (aIsKinectActive)
         {
             this.stateMessage.Opacity = 0.0f;
         }
         else
         {
             //this.stateMessage.Opacity = 1.0f;
         }
     });
 }
        public KinectWebBrowser()
        {
            this.Address = "http://bu.edu";
            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                _kinectManager = KinectManager.Default;
                if (_kinectManager != null)
                {
                    _kinectManager.HandManager.AddHandStateChangeListener(this);
                    _kinectManager.HandManager.AddHandLocationListener(this);
                }

                if (!hasInitUserAgent)
                {
                    hasInitUserAgent = true;
                }
            }
        }
        public KinectHandManager(KinectManager aManager, Config aConfig)
        {
            _kinectManager = aManager;
            _coordinateMapper = this._kinectManager.KinectSensor.CoordinateMapper;
            this.TrackingLeftHand = false;
            this.MinimumClosedStatesAfterOpen = DEFAULT_MINIMUM_CLOSED_STATES_AFTER_OPEN;
            this.MinimumOpenStatesAfterClose = DEFAULT_MINIMUM_OPEN_STATES_AFTER_CLOSE;
            this.ShouldAttachToControls = true;

            FrameDescription frameDescription = _kinectManager.KinectSensor.DepthFrameSource.FrameDescription;
            _depthFrameWidth = frameDescription.Width;
            _depthFrameHeight = frameDescription.Height;

            this.HandCoordRangeX = 1920;
            this.HandCoordRangeY = 1080;

            this.LoadConfig(aConfig);

            this._kinectManager.AddSmoothBodyDataListener(this);
        }
예제 #8
0
        public LiveBackground()
            : base()
        {
            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                _kinectManager = KinectManager.Default;

                // open the reader for the color frames
                this._colorFrameReader = _kinectManager.KinectSensor.ColorFrameSource.OpenReader();
                this._infraredFrameReader = _kinectManager.KinectSensor.InfraredFrameSource.OpenReader();
                this._bodyIndexFrameReader = _kinectManager.KinectSensor.BodyIndexFrameSource.OpenReader();
                FrameDescription bodyDescription = this.GetFrameDescriptionForMode(BackgroundMode.BodyIndex);
                this.bodyIndexPixels = new uint[bodyDescription.Width * bodyDescription.Height];

                // wire handler for frame arrival
                this._colorFrameReader.FrameArrived += this.Reader_ColorFrameArrived;
                this._infraredFrameReader.FrameArrived += this.Reader_InfraredFrameArrived;
                this._bodyIndexFrameReader.FrameArrived += this.Reader_BodyIndexFrameArrived;

                this._needColor = true;
            }
        }
        public void KinectManagerDidGetUpdatedBodyData(KinectManager aManager, SmoothedBody<KalmanSmoother>[] aBodies)
        {
            SmoothedBody<KalmanSmoother> tracked = aBodies.Where(b => b.TrackingId == this._kinectManager.CurrentlyTrackingId).FirstOrDefault();

            if (tracked != null && tracked.TrackingId != 0)
            {
                Dictionary<JointType, Point> jointPoints = this._kinectManager.HandManager.ConvertJointsToDepthSpace(tracked);

                //check if we are already tracking a hand
                bool beganTracking = false;
                if (this._lastConfirmedHandState == HandState.NotTracked || !HandIsInCorrectPosition(jointPoints, this.TrackingLeftHand))
                {
                    if (this.ChooseHand(jointPoints))
                    {
                        beganTracking = true;
                        _lastConfirmedHandState = HandState.Open;
                    }
                }

                //Process hand loc
                Point currentHandLoc = ProcessHandLocation(jointPoints);

                //if began tracking, send out event
                if (beganTracking)
                {
                    HandStateChangeEvent beganTrackingEvent = new HandStateChangeEvent(HandStateChangeType.BeganTracking, currentHandLoc);
                    this.NotifyHandStateChangeListenersOfEvent(beganTrackingEvent);
                }

                //Process Hand State
                ProcessHandState(tracked, currentHandLoc);
            }
            else
            {
                _lastConfirmedHandState = HandState.NotTracked;
                _handStateCounter.Reset();
                _scaledHandLocationFilter.Set(new Point(this.HandCoordRangeX / 2, this.HandCoordRangeY / 2));
            }
        }
예제 #10
0
        public MainWindow()
        {
            //this must ALWAYS be first
            InitializeComponent();

            //// one sensor is currently supported
            this.kinectsensor = KinectSensor.GetDefault();
            // get the depth (display) extents
            FrameDescription frameDescription = this.kinectsensor.DepthFrameSource.FrameDescription;

            // open the reader for the body frames
            this.bodyFrameReader = this.kinectsensor.BodyFrameSource.OpenReader();
            this.bodyFrameReader.FrameArrived += this.Reader_FrameArrived;
            // open the sensor
            kinectsensor.Open();
            recordNumber = 0;
            //initialization Buttons for visibility

            initButtons();

            this.SetThreshold(HARD_THRESHOLD);

            currentUser = -1; //bugs out?!
            currentState = ScreenStates.HOME;

            //initialize global skeleton buffer
            bStorage = new Body[6]; //"hard"-coded limit of 6 (more like 2)

            //setup timer
            timer = new System.Windows.Threading.DispatcherTimer();
            timer.Tick += new EventHandler(timerTick);
            timer.Interval = new TimeSpan(0, 0, 0, 0, 100); //trigger every 50 ms (faster updates in progress bar)
            timerCount = 0;

            //initialize dataStore -- 4 user limit
            dataStore = new MathNet.Numerics.LinearAlgebra.Generic.Matrix<float>[4][][];
            for (int i = 0; i < dataStore.Length; i++)
            {
                //for each user give space for "1" gesture
                dataStore[i] = new MathNet.Numerics.LinearAlgebra.Generic.Matrix<float>[1][];
                for (int j = 0; j < dataStore[i].Length; j++)
                {
                    //each gesture give space for "1" sample of the gesture
                    dataStore[i][j] = new MathNet.Numerics.LinearAlgebra.Generic.Matrix<float>[numRecords];
                }
            }
            userNames = new string[]{"User 1", "User 2", "User 3", "User 4"};
            userHasData = new bool[4] { false, false, false, false };
            dataEnrolled = false;

            //set up recordingBuffer
            rb = new RecordingBuffer(5 * 30, 25); //full joints 5 seconds;
            rb.clearBuffer();

            //set state to welcome
            setProgramState(ScreenStates.HOME);

            this.kinectManager = KinectManager.Default;

            //setup the cursor with images
            Image[] cursorImages = new Image[3];
            Image cursorImage0 = new Image();
            cursorImage0.Source = ImageExtensions.ToBitmapSource(KinectLogin.Properties.Resources.hand1);
            cursorImages[0] = cursorImage0;
            Image cursorImage1 = new Image();
            cursorImage1.Source = ImageExtensions.ToBitmapSource(KinectLogin.Properties.Resources.hand2);
            cursorImages[1] = cursorImage1;
            Image cursorImage2 = new Image();
            cursorImage2.Source = ImageExtensions.ToBitmapSource(KinectLogin.Properties.Resources.hand3);
            cursorImages[2] = cursorImage2;

            this.cursorView.SetCursorImages(cursorImages);

            this.kinectManager.HandManager.Cursor = this.cursorView;
            this.kinectManager.AddStateListener(this);

            //MessageBox.Show("Success!");
            //Loaded += OnLoaded;
        }
예제 #11
0
        public void SetKinectManager(KinectManager aManager)
        {
            // one sensor is currently supported
            this.kinectManager = aManager;

            if (this.kinectManager != null)
            {
                // get the coordinate mapper
                this.coordinateMapper = this.kinectManager.KinectSensor.CoordinateMapper;

                // a bone defined as a line between two joints
                this.bones = new List<Tuple<JointType, JointType>>();

                // Torso
                this.bones.Add(new Tuple<JointType, JointType>(JointType.Head, JointType.Neck));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.Neck, JointType.SpineShoulder));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.SpineShoulder, JointType.SpineMid));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.SpineMid, JointType.SpineBase));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.SpineShoulder, JointType.ShoulderRight));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.SpineShoulder, JointType.ShoulderLeft));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.SpineBase, JointType.HipRight));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.SpineBase, JointType.HipLeft));

                // Right Arm
                this.bones.Add(new Tuple<JointType, JointType>(JointType.ShoulderRight, JointType.ElbowRight));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.ElbowRight, JointType.WristRight));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.WristRight, JointType.HandRight));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.HandRight, JointType.HandTipRight));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.WristRight, JointType.ThumbRight));

                // Left Arm
                this.bones.Add(new Tuple<JointType, JointType>(JointType.ShoulderLeft, JointType.ElbowLeft));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.ElbowLeft, JointType.WristLeft));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.WristLeft, JointType.HandLeft));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.HandLeft, JointType.HandTipLeft));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.WristLeft, JointType.ThumbLeft));

                // Right Leg
                this.bones.Add(new Tuple<JointType, JointType>(JointType.HipRight, JointType.KneeRight));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.KneeRight, JointType.AnkleRight));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.AnkleRight, JointType.FootRight));

                // Left Leg
                this.bones.Add(new Tuple<JointType, JointType>(JointType.HipLeft, JointType.KneeLeft));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.KneeLeft, JointType.AnkleLeft));
                this.bones.Add(new Tuple<JointType, JointType>(JointType.AnkleLeft, JointType.FootLeft));

                // populate body colors, one for each BodyIndex
                this.bodyColors = new List<Pen>();

                this.bodyColors.Add(new Pen(Brushes.Red, 6));
                this.bodyColors.Add(new Pen(Brushes.Gray, 6));
                //this.bodyColors.Add(new Pen(Brushes.Green, 6 * _skeletonScaleX));
                //this.bodyColors.Add(new Pen(Brushes.Blue, 6 * _skeletonScaleX));
                //this.bodyColors.Add(new Pen(Brushes.Indigo, 6 * _skeletonScaleX));
                //this.bodyColors.Add(new Pen(Brushes.Violet, 6 * _skeletonScaleX));

                this.kinectManager.AddSmoothBodyDataListener(this);
            }
        }
예제 #12
0
 public void KinectManagerDidGetUpdatedBodyData(KinectManager aManager, SmoothedBody<KalmanSmoother>[] aBodies)
 {
     //update on UI thread
     Dispatcher.InvokeAsync((Action)delegate()
     {
         DrawBodies(aBodies);
     });
 }
예제 #13
0
 public void KinectManagerDidFinishTracking(KinectManager aManager)
 {
     _isInteracting = false;
     RaisePropertyChanged("ControlVisibility");
 }
예제 #14
0
        public void KinectManagerDidBeginTracking(KinectManager aManager)
        {
            log.Info("Kinect did begin tracking");
            _isInteracting = true;
            RaisePropertyChanged("ControlVisibility");

            // TODO(droeper) System.Diagnostics.Process.Start(@"C:\KinectShowcase\scripts\toggle_numlock.vbs");
        }