Exemple #1
0
        /// <summary>
        /// Handle insertion of Kinect sensor.
        /// </summary>
        private void InitializeNui()
        {
            _gesture = "";
            var index = 0;

            while (this.nui == null && index < KinectSensor.KinectSensors.Count)
            {
                this.nui = KinectSensor.KinectSensors[index];
                this.nui.Start();
            }
            try
            {
                this.skeletons = new Skeleton[this.nui.SkeletonStream.FrameSkeletonArrayLength];
                var parameters = new TransformSmoothParameters
                {
                    Smoothing          = 0.75f,
                    Correction         = 0.0f,
                    Prediction         = 0.0f,
                    JitterRadius       = 0.05f,
                    MaxDeviationRadius = 0.04f
                };
                this.nui.SkeletonStream.Enable(parameters);
                this.nui.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);
                this.nui.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
            }
            catch (Exception)
            { return; }
            this.nui.SkeletonFrameReady += this.OnSkeletonFrameReady;
            this.nui.DepthFrameReady    += this.SensorDepthFrameReady;
            RawDepthData      = new short[nui.DepthStream.FramePixelDataLength];
            DepthData         = new Microsoft.Xna.Framework.Color[nui.DepthStream.FramePixelDataLength];
            gestureController = new GestureController();
            InitializeGestures();
            InitializeDevices();
            gestureController.GestureRecognized += OnGestureRecognized;
            InitializeVoiceGrammar();
        }
Exemple #2
0
 /// <summary>
 /// Handle insertion of Kinect sensor.
 /// </summary>
 private void InitializeNui()
 {
     _gesture = "";
     var index = 0;
     while (this.nui == null && index < KinectSensor.KinectSensors.Count)
     {
         this.nui = KinectSensor.KinectSensors[index];
         try
         {
             this.nui.Start();
         }
         catch(Exception)
         {
         }
     }
     try
     {
         this.skeletons = new Skeleton[this.nui.SkeletonStream.FrameSkeletonArrayLength];
         var parameters = new TransformSmoothParameters
         {
             Smoothing = 0.75f,
             Correction = 0.0f,
             Prediction = 0.0f,
             JitterRadius = 0.05f,
             MaxDeviationRadius = 0.04f
         };
         this.nui.SkeletonStream.Enable(parameters);
         this.nui.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
     }
     catch (Exception)
     { return; }
     this.nui.SkeletonFrameReady += this.OnSkeletonFrameReady;
     gestureController = new GestureController();
     InitializeGestures();
     InitializeDevices();
     gestureController.GestureRecognized += OnGestureRecognized;
     InitializeVoiceGrammar();
 }
Exemple #3
0
        public void InitializeGestures()
        {
            gestureController  = new GestureController();
            blankScreen        = new BlankScreen();
            nui.ElevationAngle = 10;
            comm = new CommunicationManager("9600");

            /*IRelativeGestureSegment[] waveLeftSegments = new IRelativeGestureSegment[6];
             * WaveLeftSegment1 waveLeftSegment1 = new WaveLeftSegment1();
             * WaveLeftSegment2 waveLeftSegment2 = new WaveLeftSegment2();
             * waveLeftSegments[0] = waveLeftSegment1;
             * waveLeftSegments[1] = waveLeftSegment2;
             * waveLeftSegments[2] = waveLeftSegment1;
             * waveLeftSegments[3] = waveLeftSegment2;
             * waveLeftSegments[4] = waveLeftSegment1;
             * waveLeftSegments[5] = waveLeftSegment2;
             * this.gestureController.AddGesture(GestureType.WaveLeft, waveLeftSegments);*/


            /*IRelativeGestureSegment[] swipeUpSegments = new IRelativeGestureSegment[3];
             * swipeUpSegments[0] = new SwipeUpSegment1();
             * swipeUpSegments[1] = new SwipeUpSegment2();
             * swipeUpSegments[2] = new SwipeUpSegment3();
             * gestureController.AddGesture(GestureType.SwipeUp, swipeUpSegments);
             *
             * IRelativeGestureSegment[] swipeDownSegments = new IRelativeGestureSegment[3];
             * swipeDownSegments[0] = new SwipeDownSegment1();
             * swipeDownSegments[1] = new SwipeDownSegment2();
             * swipeDownSegments[2] = new SwipeDownSegment3();
             * gestureController.AddGesture(GestureType.SwipeDown, swipeDownSegments);
             *
             * IRelativeGestureSegment[] swipeLeftSegments = new IRelativeGestureSegment[3];
             * swipeLeftSegments[0] = new SwipeLeftSegment1();
             * swipeLeftSegments[1] = new SwipeLeftSegment2();
             * swipeLeftSegments[2] = new SwipeLeftSegment3();
             * gestureController.AddGesture(GestureType.SwipeLeft, swipeLeftSegments);
             *
             * IRelativeGestureSegment[] swipeRightSegments = new IRelativeGestureSegment[3];
             * swipeRightSegments[0] = new SwipeRightSegment1();
             * swipeRightSegments[1] = new SwipeRightSegment2();
             * swipeRightSegments[2] = new SwipeRightSegment3();
             * gestureController.AddGesture(GestureType.SwipeRight, swipeRightSegments);*/

            IRelativeGestureSegment[] menuSegments = new IRelativeGestureSegment[20];
            MenuSegment1 menuSegment = new MenuSegment1();

            for (int i = 0; i < 20; i++)
            {
                // gesture consists of the same thing 20 times
                menuSegments[i] = menuSegment;
            }
            gestureController.AddGesture(GestureType.Menu, menuSegments);

            /*IRelativeGestureSegment[] zoomInSegments = new IRelativeGestureSegment[3];
             * zoomInSegments[0] = new ZoomSegment1();
             * zoomInSegments[1] = new ZoomSegment2();
             * zoomInSegments[2] = new ZoomSegment3();
             * gestureController.AddGesture(GestureType.ZoomIn, zoomInSegments);*/

            IRelativeGestureSegment[] joinedHandsSegments = new IRelativeGestureSegment[10];

            /* JoinedHandsSegment1 JoinedHandsSegment = new JoinedHandsSegment1();
             * for (int i = 0; i < 10; i++)
             * {
             *   // gesture consists of the same thing 10 times
             *   JoinedHandsSegments[i] = JoinedHandsSegment;
             * }
             * this.gestureController.AddGesture(GestureType.JoinedHands, JoinedHandsSegments);*/


            IRelativeGestureSegment[] joinedZoom         = new IRelativeGestureSegment[13];
            JoinedHandsSegment1       joinedHandsSegment = new JoinedHandsSegment1();

            for (int i = 0; i < 10; i++)
            {
                joinedZoom[i] = joinedHandsSegment;
                //joinedHandsSegments[i] = joinedHandsSegment;
            }
            //this.gestureController.AddGesture(GestureType.JoinedHands, joinedHandsSegments);

            joinedZoom[10] = new ZoomSegment1();
            joinedZoom[11] = new ZoomSegment2();
            joinedZoom[12] = new ZoomSegment3();
            gestureController.AddGesture(GestureType.JoinedZoom, joinedZoom);


            /*IRelativeGestureSegment[] zoomOutSegments = new IRelativeGestureSegment[3];
             * zoomOutSegments[0] = new ZoomSegment3();
             * zoomOutSegments[1] = new ZoomSegment2();
             * zoomOutSegments[2] = new ZoomSegment1();
             * gestureController.AddGesture(GestureType.ZoomOut, zoomOutSegments);
             */


            gestureController.GestureRecognized += OnGestureRecognized;
        }
Exemple #4
0
        public void InitializeGestures()
        {
            gestureController = new GestureController();
            blankScreen = new BlankScreen();
            nui.ElevationAngle = 10;
            comm = new CommunicationManager("9600");
            /*IRelativeGestureSegment[] waveLeftSegments = new IRelativeGestureSegment[6];
            WaveLeftSegment1 waveLeftSegment1 = new WaveLeftSegment1();
            WaveLeftSegment2 waveLeftSegment2 = new WaveLeftSegment2();
            waveLeftSegments[0] = waveLeftSegment1;
            waveLeftSegments[1] = waveLeftSegment2;
            waveLeftSegments[2] = waveLeftSegment1;
            waveLeftSegments[3] = waveLeftSegment2;
            waveLeftSegments[4] = waveLeftSegment1;
            waveLeftSegments[5] = waveLeftSegment2;
            this.gestureController.AddGesture(GestureType.WaveLeft, waveLeftSegments);*/


            /*IRelativeGestureSegment[] swipeUpSegments = new IRelativeGestureSegment[3];
            swipeUpSegments[0] = new SwipeUpSegment1();
            swipeUpSegments[1] = new SwipeUpSegment2();
            swipeUpSegments[2] = new SwipeUpSegment3();
            gestureController.AddGesture(GestureType.SwipeUp, swipeUpSegments);

            IRelativeGestureSegment[] swipeDownSegments = new IRelativeGestureSegment[3];
            swipeDownSegments[0] = new SwipeDownSegment1();
            swipeDownSegments[1] = new SwipeDownSegment2();
            swipeDownSegments[2] = new SwipeDownSegment3();
            gestureController.AddGesture(GestureType.SwipeDown, swipeDownSegments);

            IRelativeGestureSegment[] swipeLeftSegments = new IRelativeGestureSegment[3];
            swipeLeftSegments[0] = new SwipeLeftSegment1();
            swipeLeftSegments[1] = new SwipeLeftSegment2();
            swipeLeftSegments[2] = new SwipeLeftSegment3();
            gestureController.AddGesture(GestureType.SwipeLeft, swipeLeftSegments);

            IRelativeGestureSegment[] swipeRightSegments = new IRelativeGestureSegment[3];
            swipeRightSegments[0] = new SwipeRightSegment1();
            swipeRightSegments[1] = new SwipeRightSegment2();
            swipeRightSegments[2] = new SwipeRightSegment3();
            gestureController.AddGesture(GestureType.SwipeRight, swipeRightSegments);*/

            IRelativeGestureSegment[] menuSegments = new IRelativeGestureSegment[20];
            MenuSegment1 menuSegment = new MenuSegment1();
            for (int i = 0; i < 20; i++)
            {
                // gesture consists of the same thing 20 times 
                menuSegments[i] = menuSegment;
            }
            gestureController.AddGesture(GestureType.Menu, menuSegments);

            /*IRelativeGestureSegment[] zoomInSegments = new IRelativeGestureSegment[3];
            zoomInSegments[0] = new ZoomSegment1();
            zoomInSegments[1] = new ZoomSegment2();
            zoomInSegments[2] = new ZoomSegment3();
            gestureController.AddGesture(GestureType.ZoomIn, zoomInSegments);*/

            IRelativeGestureSegment[] joinedHandsSegments = new IRelativeGestureSegment[10];
           /* JoinedHandsSegment1 JoinedHandsSegment = new JoinedHandsSegment1();
            for (int i = 0; i < 10; i++)
            {
                // gesture consists of the same thing 10 times 
                JoinedHandsSegments[i] = JoinedHandsSegment;
            }
            this.gestureController.AddGesture(GestureType.JoinedHands, JoinedHandsSegments);*/
          

            IRelativeGestureSegment[] joinedZoom = new IRelativeGestureSegment[13];
            JoinedHandsSegment1 joinedHandsSegment = new JoinedHandsSegment1();
            for (int i = 0; i < 10; i++)
            {
                joinedZoom[i] = joinedHandsSegment;
                //joinedHandsSegments[i] = joinedHandsSegment;
            }
            //this.gestureController.AddGesture(GestureType.JoinedHands, joinedHandsSegments);

            joinedZoom[10] = new ZoomSegment1();
            joinedZoom[11] = new ZoomSegment2();
            joinedZoom[12] = new ZoomSegment3();
            gestureController.AddGesture(GestureType.JoinedZoom, joinedZoom);


            /*IRelativeGestureSegment[] zoomOutSegments = new IRelativeGestureSegment[3];
            zoomOutSegments[0] = new ZoomSegment3();
            zoomOutSegments[1] = new ZoomSegment2();
            zoomOutSegments[2] = new ZoomSegment1();
            gestureController.AddGesture(GestureType.ZoomOut, zoomOutSegments);
             */


            gestureController.GestureRecognized += OnGestureRecognized;
        }