void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Initialize the MultiEngine
            KinectViewer = new ColorAndBodyViewer();
            KinectViewer.ShowLiveVideo = true;
            KinectViewer.DrawBodies    = false;
            KinectViewer.BodyTracked  += MultiEngine_BodyTracked;
            this.DataContext           = KinectViewer;

            // Load the Gesture Files
            var Gestures = new List <Gesture>();
            var files    = Directory.GetFiles(GestureFolder, "*.xml");

            if (files.Length == 0)
            {
                MessageBox.Show("No gesture files in " + GestureFolder);
                return;
            }
            // create gestures and add them to a list
            foreach (string file in files)
            {
                Gestures.Add(new Gesture(file));
            }

            // create 6 matchers, one for each Body
            Matchers = new GestureMatcher[6];
            for (int i = 0; i < 6; i++)
            {
                Matchers[i] = new GestureMatcher(Gestures);
            }
        }
Beispiel #2
0
 public void LoadGesture(string filename)
 {
     GestureFileName = filename;
     Matcher         = new GestureMatcher(new List <Gesture>()
     {
         new Gesture(filename)
     });
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // set the phrases to listen for and start listening
            listener.Phrases = PhrasesTextBox.Text;
            listener.StartListening();

            // Make sure we have a Kinect
		    if (KinectSensor.KinectSensors.Count == 0) {
			    MessageBox.Show("Please plug in your Kinect and try again");
			    Application.Current.Shutdown();
		    }

            // Make sure we have a gesture file
            if (System.IO.File.Exists(gesturefile) == false)
            {
                MessageBox.Show("Please modify this code to point to an existing gesture file.");
                Application.Current.Shutdown();
            }

            // Create your gesture objects (however many you want to test)
            Gesture g1 = new Gesture(gesturefile);

            // Add it to a gestures collection
            List<Gesture> gestures = new List<Gesture>();
            gestures.Add(g1);
            myKinect = KinectSensor.KinectSensors[0];
            myKinect.Start();

            // Create a new matcher from the Kinect sensor and the gestures
            matcher = new GestureMatcher(KinectSensor.KinectSensors[0], gestures);

            //events
            matcher.StartedRecognizing += matcher_StartedRecognizing;
            matcher.DoneRecognizing += matcher_DoneRecognizing;
            matcher.Tracking += matcher_Tracking;
            matcher.NotTracking += matcher_NotTracking;
            matcher.GestureMatch += matcher_GestureMatch;

            // Start recognizing your gestures!
            matcher.StartRecognizing();

            //Method that initializes the skeleton tracking
            SkeletonInitilization();

            
           
            
        }