Exemple #1
0
        static void Main(string[] args)
        {
            // Create a sample listener and controller
            GestureListener listener = new GestureListener();
            Controller controller = new Controller();

            listener.Gestures.GestureReceived += Gestures_GestureReceived;

            // Have the sample listener receive events from the controller
            controller.AddListener(listener);

            // Keep this process running until Enter is pressed
            Console.WriteLine("Press Enter to quit...");

            while (true)
            {
                var key = Console.ReadKey(true);

                if (key.Key == ConsoleKey.Enter)
                {
                    break;
                }

                switch (key.Key)
                {
                    case ConsoleKey.D1:
                        listener.Gestures.StartTraining();
                        Console.WriteLine("Training...");
                        break;

                    case ConsoleKey.D2:
                        listener.Gestures.StopTraining();
                        Console.WriteLine("Recorded gesture.");
                        break;

                    case ConsoleKey.D3:
                        var model = listener.Gestures.FinishTrainingSession();
                        Console.WriteLine("Enter a name for this gesture:");
                        var name = Console.ReadLine();
                        model.Name = name;
                        Console.WriteLine(String.Format("Completed training of gesture {0}.", name));
                        break;

                    case ConsoleKey.D4:
                        listener.Gestures.StartRecognition();
                        Console.WriteLine("Recognizing...");
                        break;

                    case ConsoleKey.D5:
                        listener.Gestures.StopRecognition();
                        break;
                }
            }

            // Remove the sample listener when done
            controller.RemoveListener(listener);
            controller.Dispose();
        }