Пример #1
0
        static void RunStandaloneTestApplication()
        {
            Console.WriteLine("Welcome to the Cisco Kinect Team 1 Demo Application.");
            Console.WriteLine("First, we will set up a connection to the Kinect.");
            String deviceName = "NuiDeviceFramework.devices.Kinect";
            String dllPath = "NuiDeviceFramework.dll";
            object device = DeviceManager.GetConnection(deviceName, dllPath);

            if (device == null)
            {
                Console.WriteLine("Error occurred connecting to the {0} device.", deviceName);
                Environment.Exit(-1);
            }

            NuiStreamTypes s = NuiStreamTypes.ColorData;
            for (; s <= NuiStreamTypes.AudioData; s++)
            {
                object val = ReflectionUtilities.InvokeMethod(device, "supportsStreamType", new object[] { s });
                if (val is bool && (bool)val == true)
                {
                    Console.WriteLine("Device {0} supports stream type {1}", deviceName, s);
                }
            }

            GestureManager gm = new GestureManager(device);

            /*
            Gesture audioGesture = new MyAudioGesture(device);

            if (!gm.Add(audioGesture))
            {
                Console.WriteLine("Could not add the gesture {0} to the device {1}. Unsupported gesture.", audioGesture, device);
                Environment.Exit(-1);
            }
            */

            Gesture skeletonGestureSL = new SwipeLeft(device);

            if (!gm.Add(skeletonGestureSL))
            {
                Console.WriteLine("Could not add the gesture {0} to the device {1}. Unsupported gesture.", skeletonGestureSL, device);
            }

            /*
            Gesture skeletonGestureB = new Bow(device);
            if (!gm.Add(skeletonGestureB))
            {
                Console.WriteLine("Could not add the gesture {0} to the device {1}. Unsupported gesture.", skeletonGestureB, device);
            }

            Console.WriteLine("You've successfully added a Gesture to the GestureManager!");
            */

            Console.WriteLine("Now the GestureManager will start listening for input.");
            gm.Start();
            List<Gesture> completedGestures;
            for (; ; )
            {
                completedGestures = gm.getCompletedGestures();
                if (completedGestures.Count == 0)
                {
                    //Console.WriteLine("No gesture detected this frame.");
                }
                else
                {
                    break;
                }
            }

            foreach (Gesture ge in completedGestures)
            {
                Console.WriteLine("Gesture {0} successfully detected!", ge);
            }

            Console.WriteLine("The program will now exit.");
        }
Пример #2
0
        static void RunMessagingApplication()
        {
            Console.WriteLine("Welcome to the recipient!");
            string recvQueuePath = ".\\Private$\\recvQueue";
            string sendQueuePath = ".\\Private$\\sendQueue";
            string message;
            string ack = "ACK";
            CreateQueue(recvQueuePath);
            CreateQueue(sendQueuePath);
            Console.WriteLine("Welcome to the Cisco Kinect Team 1 Demo Application. (Messaging Version)");
            message = ReceiveMessage(recvQueuePath);
            SendMessage(sendQueuePath, ack);

            Console.WriteLine("First, we will set up a connection to the {0}.", message);
            if (message != "Kinect")
            {
                Console.WriteLine("Unknown device name {0].", message);
                Environment.Exit(-1);
            }
            String deviceName = "NuiDeviceFramework.devices.Kinect";
            String dllPath = "C:\\Users\\Eric\\Documents\\Visual Studio 2010\\Projects\\NuiDeviceFramework\\NuiDeviceFramework\\bin\\Debug\\NuiDeviceFramework.dll";
            object device = DeviceManager.GetConnection(deviceName, dllPath);

            if (device == null)
            {
                Console.WriteLine("Error occurred connecting to the {0} device.", deviceName);
                Environment.Exit(-1);
            }

            NuiStreamTypes s = NuiStreamTypes.ColorData;
            for (; s <= NuiStreamTypes.ObjectData; s++)
            {
                object val = ReflectionUtilities.InvokeMethod(device, "supportsStreamType", new object[] { s });
                if (val is bool && (bool)val == true)
                {
                    Console.WriteLine("Device {0} supports stream type {1}", deviceName, s);
                }
            }

            message = ReceiveMessage(recvQueuePath);
            SendMessage(sendQueuePath, ack);
            GestureManager gm = new GestureManager(device);
            switch (message)
            {
                case "AudioGesture":
                    List<string> myWords = new List<string> { "hello", "computer", "action" };
                    Gesture audioGesture = new MyAudioGesture(device);
                    foreach (string w in myWords)
                    {
                        ((MyAudioGesture)audioGesture).AddWord(w);
                    }

                    if (!gm.Add(audioGesture))
                    {
                        Console.WriteLine("Could not add the gesture {0} to the device {1}. Unsupported gesture.", audioGesture, device);
                        Environment.Exit(-1);
                    }

                    Console.WriteLine("You've successfully added a Gesture to the GestureManager!");
                    break;
                default:
                    Console.WriteLine("Unknown gesture type {0}", message);
                    Environment.Exit(-1);
                    break;
            }

            Console.WriteLine("Now the GestureManager will start listening for input.");
            gm.Start();
            List<Gesture> completedGestures;
            for (; ; )
            {
                completedGestures = gm.getCompletedGestures();
                if (completedGestures.Count == 0)
                {
                    //Console.WriteLine("No gesture detected this frame.");
                }
                else
                {
                    break;
                }
            }

            foreach (Gesture ge in completedGestures)
            {
                SendMessage(sendQueuePath, "Gesture " + ge + " successfully detected!");
                //Console.WriteLine("Gesture {0} successfully detected!", ge);
            }

            Console.WriteLine("The program will now exit.");
        }