Пример #1
0
        /// <summary>
        /// Registers gestures to be tracked by the Kinect
        /// </summary>
        static void RegisterGestures()
        {
            double hBound = 5;
            double vBound = 6;

            Double.TryParse(ConfigurationManager.AppSettings["horBound"], out hBound);
            Double.TryParse(ConfigurationManager.AppSettings["verBound"], out vBound);

            leftBoundary  = -(double)hBound * (300.00 / (double)7); // Left treshold needed for swipe
            rightBoundary = -leftBoundary;                          // Right treshold needed for swipe
            topBoundary   = (double)vBound * (200.00 / (double)7);  //Top treshold
            botBoundary   = -topBoundary;                           //Bottom treshold

            double actHeight = 0;

            Double.TryParse(ConfigurationManager.AppSettings["kinectHeight"], out actHeight);

            adjustedHeight = actHeight - baseKinectHeight;

            XnMPointDenoiser pointFilter  = new XnMPointDenoiser();
            XnMPointControl  pointControl = new XnMPointControl();

            pointControl.PointUpdate += new EventHandler <PointBasedEventArgs>(control_PointUpdate);
            pointFilter.PointCreate  += new EventHandler <PointBasedEventArgs>(control_PointCreate);

            XnMSwipeDetector swipeDetector = new XnMSwipeDetector(true);

            swipeDetector.MotionSpeedThreshold = 0.8f;
            swipeDetector.MotionTime           = 180; //350
            swipeDetector.SteadyDuration       = 150; //200

            swipeDetector.SwipeRight += new EventHandler <SwipeDetectorEventArgs>(swipeDetector_SwipeRight);
            swipeDetector.SwipeLeft  += new EventHandler <SwipeDetectorEventArgs>(swipeDetector_SwipeLeft);
            swipeDetector.SwipeDown  += new EventHandler <SwipeDetectorEventArgs>(swipeDetector_SwipeDown);
            swipeDetector.SwipeUp    += new EventHandler <SwipeDetectorEventArgs>(swipeDetector_SwipeUp);

            XnMSteadyDetector steadyDetector = new XnMSteadyDetector();

            steadyDetector.DetectionDuration = 800;
            steadyDetector.Steady           += new EventHandler <SteadyEventArgs>(steadyDetector_Steady);

            //XnMPushDetector pushDetector = new XnMPushDetector();
            //pushDetector.Push += new EventHandler<PushDetectorEventArgs>(pushDetector_Push);

            XnMBroadcaster broadcaster = new XnMBroadcaster();

            pointFilter.AddListener(pointControl);
            broadcaster.AddListener(pointFilter);
            broadcaster.AddListener(swipeDetector);
            broadcaster.AddListener(steadyDetector);
            //broadcaster.AddListener(steadyDetector);
            HorSwipeStarted = VertSwipeStarted = true;
            sessionManager.AddListener(broadcaster);
        }
Пример #2
0
        /// <summary>
        /// Registers gestures to be tracked by the Kinect
        /// </summary>
        static void RegisterGestures()
        {
            double hBound = 5;
            double vBound = 6;

            Double.TryParse(ConfigurationManager.AppSettings["horBound"], out hBound);
            Double.TryParse(ConfigurationManager.AppSettings["verBound"], out vBound);

            leftBoundary = -(double)hBound * (300.00 / (double)7); // Left treshold needed for swipe
            rightBoundary = -leftBoundary; // Right treshold needed for swipe
            topBoundary = (double)vBound * (200.00 / (double)7); //Top treshold
            botBoundary = -topBoundary; //Bottom treshold

            double actHeight = 0;
            Double.TryParse(ConfigurationManager.AppSettings["kinectHeight"], out actHeight);

            adjustedHeight = actHeight - baseKinectHeight;

            XnMPointDenoiser pointFilter = new XnMPointDenoiser();
            XnMPointControl pointControl = new XnMPointControl();
            pointControl.PointUpdate += new EventHandler<PointBasedEventArgs>(control_PointUpdate);
            pointFilter.PointCreate += new EventHandler<PointBasedEventArgs>(control_PointCreate);

            XnMSwipeDetector swipeDetector = new XnMSwipeDetector(true);
            swipeDetector.MotionSpeedThreshold = 0.8f;
            swipeDetector.MotionTime = 180; //350
            swipeDetector.SteadyDuration = 150; //200

            swipeDetector.SwipeRight += new EventHandler<SwipeDetectorEventArgs>(swipeDetector_SwipeRight);
            swipeDetector.SwipeLeft += new EventHandler<SwipeDetectorEventArgs>(swipeDetector_SwipeLeft);
            swipeDetector.SwipeDown += new EventHandler<SwipeDetectorEventArgs>(swipeDetector_SwipeDown);
            swipeDetector.SwipeUp += new EventHandler<SwipeDetectorEventArgs>(swipeDetector_SwipeUp);

            XnMSteadyDetector steadyDetector = new XnMSteadyDetector();
            steadyDetector.DetectionDuration = 800;
            steadyDetector.Steady += new EventHandler<SteadyEventArgs>(steadyDetector_Steady);

            //XnMPushDetector pushDetector = new XnMPushDetector();
            //pushDetector.Push += new EventHandler<PushDetectorEventArgs>(pushDetector_Push);

            XnMBroadcaster broadcaster = new XnMBroadcaster();
            pointFilter.AddListener(pointControl);
            broadcaster.AddListener(pointFilter);
            broadcaster.AddListener(swipeDetector);
            broadcaster.AddListener(steadyDetector);
            //broadcaster.AddListener(steadyDetector);
            HorSwipeStarted = VertSwipeStarted = true;
            sessionManager.AddListener(broadcaster);
        }