Пример #1
0
        void KinectSensors_StatusChanged(object sender, StatusChangedEventArgs e)
        {
            // Ensure the current sensor is still connected.
            if (this.sensor != null && this.sensor.Status != KinectStatus.Connected)
            {
                this.sensor = null;
            }

            foreach (var potentialSensor in KinectSensor.KinectSensors)
            {
                if (potentialSensor.Status == KinectStatus.Connected)
                {
                    this.sensor = potentialSensor;
                    break;
                }
            }

            if (null != this.sensor)
            {
                // Notify user kinect is ready
                this.statusBarText.Text = Properties.Resources.KinectReady;

                // Enable skeleton processing
                SkeletonFrameProcessor skelProc = new SkeletonFrameProcessor();
                skelProc.Register(this.sensor);
                skelProc.Start();
                skelProc.SetTargetImage(this.frameImage);

                // Enable gesture processing
                this.recognizer = new GestureRecognizer();
                this.recognizer.Register(this.sensor);

                // Attempt to load up configs from last time
                this.gestures = BinarySerializer.DeserializeObject<GesturePack>(Properties.Resources.TempFile);
                if (this.gestures == null)
                {
                    this.gestures = new GesturePack();
                    // this.gestures.MassExecute(RegistrationVisitor.Singleton, this.recognizer);
                }
                this.gestures.MassExecute(RegistrationVisitor.Singleton, this.recognizer);

                // Start the sensor
                try
                {
                    this.sensor.Start();
                }
                catch (IOException)
                {
                    this.statusBarText.Text = Properties.Resources.KinectInUse;
                    this.sensor = null;
                }
            }

            if (null == this.sensor)
            {
                this.statusBarText.Text = Properties.Resources.NoKinectReady;
            }
        }
Пример #2
0
        private void LoadButtonClicked(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog openDialog = new System.Windows.Forms.OpenFileDialog();
            openDialog.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments);
            openDialog.Filter = Properties.Resources.NuiConfigFilter;

            if (openDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this.gestures = BinarySerializer.DeserializeObject<GesturePack>(openDialog.FileName);
            }
        }