Exemplo n.º 1
0
        public void RegisterGestures(List<GestureType> gestureList)
        {
            if (gestureList.Contains(GestureType.JoinedHands) || gestureList.Contains(GestureType.LeftHandHalfLift) ||
                gestureList.Contains(GestureType.Pull) || gestureList.Contains(GestureType.Push) ||
                gestureList.Contains(GestureType.ZoomIn) || gestureList.Contains(GestureType.ZoomOut))
            {
                gestureController = new GestureController();
                gestureController.GestureRecognized += OnGestureRecognized;
                if (gestureList.Contains(GestureType.JoinedHands))
                {
                    IRelativeGestureSegment[] joinedhandsSegments = new IRelativeGestureSegment[15];
                    JoinedHandsSegment1 joinedhandsSegment = new JoinedHandsSegment1();
                    for (int i = 0; i < 15; i++)
                    {
                        // gestureType consists of the same thing 10 times
                        joinedhandsSegments[i] = joinedhandsSegment;
                    }
                    gestureController.AddGesture("JoinedHands", joinedhandsSegments);
                }
                if (gestureList.Contains(GestureType.LeftHandHalfLift))
                {
                    IRelativeGestureSegment[] menuSegments = new IRelativeGestureSegment[15];
                    MenuSegment1 menuSegment = new MenuSegment1();
                    for (int i = 0; i < 15; i++)
                    {
                        // gestureType consists of the same thing 20 times
                        menuSegments[i] = menuSegment;
                    }
                    gestureController.AddGesture("Menu", menuSegments);
                }
                if (gestureList.Contains(GestureType.Pull))
                {
                    IRelativeGestureSegment[] pullLeftSegment = new IRelativeGestureSegment[2];
                    pullLeftSegment[0] = new PullAndPush6();
                    pullLeftSegment[1] = new PullAndPush7();
                    gestureController.AddGesture("PullLeft", pullLeftSegment);

                    IRelativeGestureSegment[] pullSegment = new IRelativeGestureSegment[2];
                    pullSegment[0] = new PullAndPush3();
                    pullSegment[1] = new PullAndPush4();
                    gestureController.AddGesture("Pull", pullSegment);
                }
                if (gestureList.Contains(GestureType.Push))
                {
                    IRelativeGestureSegment[] pushLeftSegment = new IRelativeGestureSegment[2];
                    pushLeftSegment[0] = new PullAndPush8();
                    pushLeftSegment[1] = new PullAndPush6();
                    gestureController.AddGesture("PushLeft", pushLeftSegment);

                    IRelativeGestureSegment[] pushSegment = new IRelativeGestureSegment[2];
                    pushSegment[0] = new PullAndPush5();
                    pushSegment[1] = new PullAndPush3();
                    gestureController.AddGesture("Push", pushSegment);
                }
                if (gestureList.Contains(GestureType.ZoomIn))
                {
                    IRelativeGestureSegment[] zoomInSegments = new IRelativeGestureSegment[3];
                    zoomInSegments[0] = new ZoomSegment1();
                    zoomInSegments[1] = new ZoomSegment2();
                    zoomInSegments[2] = new ZoomSegment3();
                    gestureController.AddGesture("ZoomIn", zoomInSegments);
                }
                if (gestureList.Contains(GestureType.ZoomOut))
                {
                    IRelativeGestureSegment[] zoomOutSegments = new IRelativeGestureSegment[3];
                    zoomOutSegments[0] = new ZoomSegment3();
                    zoomOutSegments[1] = new ZoomSegment2();
                    zoomOutSegments[2] = new ZoomSegment1();
                    gestureController.AddGesture("ZoomOut", zoomOutSegments);
                }
            }

            if (gestureList.Contains(GestureType.SwipLeft)||gestureList.Contains(GestureType.SwipRight))
            {
               activeRecognizer  = new Recognizer();
                if (gestureList.Contains(GestureType.SwipLeft))
                {
                    activeRecognizer.SwipeLeftDetected += (s, e) =>
                    {
                        if (e.Skeleton.TrackingId == NearestId)
                        {
                            GestureDetected(this,GestureType.SwipLeft);
                        }
                    };
                }
                if (gestureList.Contains(GestureType.SwipRight))
                {
                    activeRecognizer.SwipeRightDetected += (s, e) =>
                    {
                        if (e.Skeleton.TrackingId == NearestId)
                        {
                            GestureDetected(this,GestureType.SwipRight);
                        }
                    };
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GestureController"/> class.
        /// </summary>
        public GestureController()
        {
            // Define the gestures

            IRelativeGestureSegment[] joinedhandsSegments = new IRelativeGestureSegment[20];
            JoinedHandsSegment1 joinedhandsSegment = new JoinedHandsSegment1();
            for (int i = 0; i < 20; i++)
            {
                // gesture consists of the same thing 10 times 
                joinedhandsSegments[i] = joinedhandsSegment;
            }
            AddGesture(GestureType.JoinedHands, joinedhandsSegments);

            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;
            }
            AddGesture(GestureType.Menu, menuSegments);

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

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

            IRelativeGestureSegment[] waveRightSegments = new IRelativeGestureSegment[6];
            WaveRightSegment1 waveRightSegment1 = new WaveRightSegment1();
            WaveRightSegment2 waveRightSegment2 = new WaveRightSegment2();
            waveRightSegments[0] = waveRightSegment1;
            waveRightSegments[1] = waveRightSegment2;
            waveRightSegments[2] = waveRightSegment1;
            waveRightSegments[3] = waveRightSegment2;
            waveRightSegments[4] = waveRightSegment1;
            waveRightSegments[5] = waveRightSegment2;
            AddGesture(GestureType.WaveRight, waveRightSegments);

            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;
            AddGesture(GestureType.WaveLeft, waveLeftSegments);

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

            IRelativeGestureSegment[] zoomOutSegments = new IRelativeGestureSegment[3];
            zoomOutSegments[0] = new ZoomSegment3();
            zoomOutSegments[1] = new ZoomSegment2();
            zoomOutSegments[2] = new ZoomSegment1();
            AddGesture(GestureType.ZoomOut, zoomOutSegments);
        }
        private void registerGestures()
        {
            // Define all recognisable gestures:
            IRelativeGestureSegment[] joined_hands_segments = new IRelativeGestureSegment[20];
            JoinedHandsSegment1 joined_hands_segment = new JoinedHandsSegment1();

            for (int i = 0; i < 20; i++)
            {
                // Gesture consists of the same thing 10 times
                joined_hands_segments[i] = joined_hands_segment;
            }
            this.fizbin_controller.AddGesture("JoinedHands", joined_hands_segments);

            IRelativeGestureSegment[] menu_segments = new IRelativeGestureSegment[20];
            MenuSegment1 menu_segment = new MenuSegment1();

            for (int i = 0; i < 20; i++)
            {
                // Festure consists of the same thing 20 times
                menu_segments[i] = menu_segment;
            }
            this.fizbin_controller.AddGesture("Menu", menu_segments);

            IRelativeGestureSegment[] swipe_left_segments = new IRelativeGestureSegment[3];
            swipe_left_segments[0] = new SwipeLeftSegment1();
            swipe_left_segments[1] = new SwipeLeftSegment2();
            swipe_left_segments[2] = new SwipeLeftSegment3();
            this.fizbin_controller.AddGesture("SwipeLeft", swipe_left_segments);

            IRelativeGestureSegment[] swipe_right_segments = new IRelativeGestureSegment[3];
            swipe_right_segments[0] = new SwipeRightSegment1();
            swipe_right_segments[1] = new SwipeRightSegment2();
            swipe_right_segments[2] = new SwipeRightSegment3();
            this.fizbin_controller.AddGesture("SwipeRight", swipe_right_segments);

            IRelativeGestureSegment[] wave_right_segments = new IRelativeGestureSegment[6];
            WaveRightSegment1 wave_right_segment_1 = new WaveRightSegment1();
            WaveRightSegment2 wave_right_segment_2 = new WaveRightSegment2();
            wave_right_segments[0] = wave_right_segment_1;
            wave_right_segments[1] = wave_right_segment_2;
            wave_right_segments[2] = wave_right_segment_1;
            wave_right_segments[3] = wave_right_segment_2;
            wave_right_segments[4] = wave_right_segment_1;
            wave_right_segments[5] = wave_right_segment_2;
            this.fizbin_controller.AddGesture("WaveRight", wave_right_segments);

            IRelativeGestureSegment[] wave_left_segments = new IRelativeGestureSegment[6];
            WaveLeftSegment1 wave_left_segment_1 = new WaveLeftSegment1();
            WaveLeftSegment2 wave_left_segment_2 = new WaveLeftSegment2();
            wave_left_segments[0] = wave_left_segment_1;
            wave_left_segments[1] = wave_left_segment_2;
            wave_left_segments[2] = wave_left_segment_1;
            wave_left_segments[3] = wave_left_segment_2;
            wave_left_segments[4] = wave_left_segment_1;
            wave_left_segments[5] = wave_left_segment_2;
            this.fizbin_controller.AddGesture("WaveLeft", wave_left_segments);

            IRelativeGestureSegment[] zoom_in_segments = new IRelativeGestureSegment[3];
            zoom_in_segments[0] = new ZoomSegment1();
            zoom_in_segments[1] = new ZoomSegment2();
            zoom_in_segments[2] = new ZoomSegment3();
            this.fizbin_controller.AddGesture("ZoomIn", zoom_in_segments);

            IRelativeGestureSegment[] zoom_out_segments = new IRelativeGestureSegment[3];
            zoom_out_segments[0] = new ZoomSegment3();
            zoom_out_segments[1] = new ZoomSegment2();
            zoom_out_segments[2] = new ZoomSegment1();
            this.fizbin_controller.AddGesture("ZoomOut", zoom_out_segments);

            IRelativeGestureSegment[] swipe_up_segments = new IRelativeGestureSegment[3];
            swipe_up_segments[0] = new SwipeUpSegment1();
            swipe_up_segments[1] = new SwipeUpSegment2();
            swipe_up_segments[2] = new SwipeUpSegment3();
            this.fizbin_controller.AddGesture("SwipeUp", swipe_up_segments);

            IRelativeGestureSegment[] swipe_down_segments = new IRelativeGestureSegment[3];
            swipe_down_segments[0] = new SwipeDownSegment1();
            swipe_down_segments[1] = new SwipeDownSegment2();
            swipe_down_segments[2] = new SwipeDownSegment3();
            this.fizbin_controller.AddGesture("SwipeDown", swipe_down_segments);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Helper function to register all available 
        /// </summary>
        private void RegisterGestures()
        {
            // define the gestures for the demo

            IRelativeGestureSegment[] joinedhandsSegments = new IRelativeGestureSegment[20];
            JoinedHandsSegment1 joinedhandsSegment = new JoinedHandsSegment1();
            for (int i = 0; i < 20; i++)
            {
                // gesture consists of the same thing 10 times
                joinedhandsSegments[i] = joinedhandsSegment;
            }
            gestureController.AddGesture("JoinedHands", joinedhandsSegments);

            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("Menu", menuSegments);

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

            IRelativeGestureSegment[] swiperightSegments = new IRelativeGestureSegment[3];
            swiperightSegments[0] = new SwipeRightSegment1();
            swiperightSegments[1] = new SwipeRightSegment2();
            swiperightSegments[2] = new SwipeRightSegment3();
            gestureController.AddGesture("SwipeRight", swiperightSegments);

            IRelativeGestureSegment[] waveRightSegments = new IRelativeGestureSegment[6];
            WaveRightSegment1 waveRightSegment1 = new WaveRightSegment1();
            WaveRightSegment2 waveRightSegment2 = new WaveRightSegment2();
            waveRightSegments[0] = waveRightSegment1;
            waveRightSegments[1] = waveRightSegment2;
            waveRightSegments[2] = waveRightSegment1;
            waveRightSegments[3] = waveRightSegment2;
            waveRightSegments[4] = waveRightSegment1;
            waveRightSegments[5] = waveRightSegment2;
            gestureController.AddGesture("WaveRight", waveRightSegments);

            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;
            gestureController.AddGesture("WaveLeft", waveLeftSegments);

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

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

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

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

            IRelativeGestureSegment[] swipeSurrenderSegment = new IRelativeGestureSegment[5];

            for (int i = 0; i < 5; i++)
            {
                swipeSurrenderSegment[i] = new SurrenderSegment1();
            }
            gestureController.AddGesture("Surrender", swipeSurrenderSegment);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Helper function to register all available 
        /// </summary>
        private void RegisterGestures()
        {
            // define the gestures for the demo

            IRelativeGestureSegment[] joinedhandsSegments = new IRelativeGestureSegment[20];
            JoinedHandsSegment1 joinedhandsSegment = new JoinedHandsSegment1();
            for (int i = 0; i < 20; i++)
            {
                // gesture consists of the same thing 10 times 
                joinedhandsSegments[i] = joinedhandsSegment;
            }
            gestureController.AddGesture("JoinedHands", joinedhandsSegments);

            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("Menu", menuSegments);

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

            IRelativeGestureSegment[] swiperightSegments = new IRelativeGestureSegment[3];
            swiperightSegments[0] = new SwipeRightSegment1();
            swiperightSegments[1] = new SwipeRightSegment2();
            swiperightSegments[2] = new SwipeRightSegment3();
            gestureController.AddGesture("SwipeRight", swiperightSegments);

            IRelativeGestureSegment[] waveRightSegments = new IRelativeGestureSegment[6];
            WaveRightSegment1 waveRightSegment1 = new WaveRightSegment1();
            WaveRightSegment2 waveRightSegment2 = new WaveRightSegment2();
            waveRightSegments[0] = waveRightSegment1;
            waveRightSegments[1] = waveRightSegment2;
            waveRightSegments[2] = waveRightSegment1;
            waveRightSegments[3] = waveRightSegment2;
            waveRightSegments[4] = waveRightSegment1;
            waveRightSegments[5] = waveRightSegment2;
            gestureController.AddGesture("WaveRight", waveRightSegments);

            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;
            gestureController.AddGesture("WaveLeft", waveLeftSegments);

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

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

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

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

            IRelativeGestureSegment[] leanleftSegments = new IRelativeGestureSegment[2];
            leanleftSegments[0] = new LeanLeftSegment1();
            leanleftSegments[1] = new LeanLeftSegment2();
            gestureController.AddGesture("LeanLeft", leanleftSegments);

            IRelativeGestureSegment[] leanrightSegments = new IRelativeGestureSegment[2];
            leanrightSegments[0] = new LeanRightSegment1();
            leanrightSegments[1] = new LeanRightSegment2();
            gestureController.AddGesture("LeanRight", leanrightSegments);

            IRelativeGestureSegment[] MRStepRightSegments = new IRelativeGestureSegment[3];
            MRStepRightSegments[0] = new MRStepRightSegment1();
            MRStepRightSegments[1] = new MRStepRightSegment2();
            MRStepRightSegments[2] = new MRStepRightSegment3();
            gestureController.AddGesture("MRStepRight", MRStepRightSegments);

            IRelativeGestureSegment[] RightPushSegments = new IRelativeGestureSegment[2];
            RightPushSegments[0] = new RightPushForwardSegment1();
            RightPushSegments[1] = new RightPushForwardSegment2();
            gestureController.AddGesture("RightPush", RightPushSegments);

            IRelativeGestureSegment[] LeftPushSegments = new IRelativeGestureSegment[2];
            LeftPushSegments[0] = new LeftPushForwardSegment1();
            LeftPushSegments[1] = new LeftPushForwardSegment2();
            gestureController.AddGesture("LeftPush", LeftPushSegments);

            IRelativeGestureSegment[] LeftThrowSegments = new IRelativeGestureSegment[3];
            LeftPushSegments[0] = new LeftThrowSegment1();
            LeftPushSegments[1] = new LeftThrowSegment2();
            LeftPushSegments[2] = new LeftThrowSegment3();
            gestureController.AddGesture("LeftThrow", LeftThrowSegments);
        }