private void Clean() { if (_skeletonManager != null) { _skeletonManager = null; } if (_colorManager != null) { _colorManager = null; } if (_swipeGestureRecognizer != null) { _swipeGestureRecognizer.OnGestureDetected -= OnGestureDetected; _swipeGestureRecognizer = null; } if (_kinectSensor != null) { _kinectSensor.SkeletonStream.Disable(); _kinectSensor.ColorStream.Disable(); _kinectSensor.SkeletonFrameReady -= KinectSensor_SkeletonFrameReady; _kinectSensor.ColorFrameReady -= KinectSensor_ColorFrameReady; _kinectSensor.Stop(); _kinectSensor = null; } }
private void Initialize() { if (_kinectSensor == null) return; _colorManager = new KinectColorStreamManager(); _skeletonManager = new KinectSkeletonDisplayManager(_kinectSensor, SkeletonCanvas); _swipeGestureRecognizer = new SwipeGestureDetector(GesturesCanvas); _swipeGestureRecognizer.OnGestureDetected += OnGestureDetected; _seated = true; KinectDisplay.DataContext = _colorManager; _kinectSensor.SkeletonStream.Enable(); _kinectSensor.SkeletonStream.EnableTrackingInNearRange = _seated; _kinectSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); _kinectSensor.SkeletonFrameReady += KinectSensor_SkeletonFrameReady; _kinectSensor.ColorFrameReady += KinectSensor_ColorFrameReady; _kinectSensor.Start(); }