Beispiel #1
0
        // Kinect enabled apps should customize which Kinect services it initializes here.
        private void InitializeKinectServices(KinectSensorManager kinectSensorManager, KinectSensor sensor)
        {
            // Application should enable all streams first.
            kinectSensorManager.ColorFormat        = ColorImageFormat.RgbResolution640x480Fps30;
            kinectSensorManager.ColorStreamEnabled = true;

            sensor.SkeletonFrameReady += this.SkeletonsReady;
            kinectSensorManager.TransformSmoothParameters = new TransformSmoothParameters
            {
                Smoothing          = 0.5f,
                Correction         = 0.5f,
                Prediction         = 0.5f,
                JitterRadius       = 0.05f,
                MaxDeviationRadius = 0.04f
            };
            kinectSensorManager.SkeletonStreamEnabled = true;
            kinectSensorManager.KinectSensorEnabled   = true;

            foreach (var keyValuePair in gestureMap)
            {
                var gesture = keyValuePair.Key;
                var cmd     = keyValuePair.Value;
                gesture.AddListener((s, e) => SendCommand(cmd));
            }

            leftSwipeRight.AddListener((s, e) => swipeThrottle.Push(Swipe.lr));
            rightSwipeLeft.AddListener((s, e) => swipeThrottle.Push(Swipe.rl));
            rightSwipeRight.AddListener((s, e) => swipeThrottle.Push(Swipe.rr));
            leftSwipeLeft.AddListener((s, e) => swipeThrottle.Push(Swipe.ll));

            if (!kinectSensorManager.KinectSensorAppConflict)
            {
                // Start speech recognizer after KinectSensor started successfully.
                this.mySpeechRecognizer = SpeechRecognizer.Create();

                if (null != this.mySpeechRecognizer)
                {
                    this.mySpeechRecognizer.SaidSomething += this.RecognizerSaidSomething;
                    this.mySpeechRecognizer.Start(sensor.AudioSource);
                }

                enableAec.Visibility = Visibility.Visible;
                this.UpdateEchoCancellation(this.enableAec);
            }
        }