Esempio n. 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);
        }
Esempio n. 2
0
        public SensorHandler()
        {
            try
            {
                context = new XnMOpenNIContext();
                context.Init();

                slider2D = new XnMSelectableSlider2D(7, 7, 700, 600);
                slider2D.HysteresisRatio = 0;
                slider2D.BorderWidth     = 0;
                slider2D.ItemHovered    += new EventHandler <SelectableSlider2DHoverEventArgs>(slider2D_ItemHovered);
                slider2D.ItemSelected   += new EventHandler <SelectableSlider2DSelectEventArgs>(slider2D_ItemSelected);

                pointDenoiser = new XnMPointDenoiser(15);
                pointDenoiser.PrimaryPointUpdate += new EventHandler <HandPointContextEventArgs>(pointDenoiser_PrimaryPointUpdate);
                pointDenoiser.AddListener(slider2D);

                flowRouter = new XnMFlowRouter();
                flowRouter.SetActiveControl(pointDenoiser);

                sessionManager = new XnMSessionManager(context, "Click", "");
                sessionManager.SessionStarted += new EventHandler <PointEventArgs>(SessionStarted);
                sessionManager.SessionEnded   += new EventHandler(sessionManager_SessionEnded);
                sessionManager.AddListener(flowRouter);

                readerThread          = new Thread(new ThreadStart(SpinInfinite));
                readerThread.Priority = ThreadPriority.Highest;
                readerThread.Start();
            }
            catch (XnMException ex)
            {
                ///
                /// - todo: proper error logging here
                ///

                MessageBox.Show("Error initializing NITE.");
                MessageBox.Show(ex.ExceptionDescription);

                isOK = false;
            }
        }
Esempio n. 3
0
        public SensorHandler()
        {
            try
            {
                context = new XnMOpenNIContext();
                context.Init();

                slider2D = new XnMSelectableSlider2D(7, 7, 700, 600);
                slider2D.HysteresisRatio = 0;
                slider2D.BorderWidth = 0;
                slider2D.ItemHovered += new EventHandler<SelectableSlider2DHoverEventArgs>(slider2D_ItemHovered);
                slider2D.ItemSelected += new EventHandler<SelectableSlider2DSelectEventArgs>(slider2D_ItemSelected);

                pointDenoiser = new XnMPointDenoiser(15);
                pointDenoiser.PrimaryPointUpdate += new EventHandler<HandPointContextEventArgs>(pointDenoiser_PrimaryPointUpdate);
                pointDenoiser.AddListener(slider2D);

                flowRouter = new XnMFlowRouter();
                flowRouter.SetActiveControl(pointDenoiser);

                sessionManager = new XnMSessionManager(context, "Click", "");
                sessionManager.SessionStarted += new EventHandler<PointEventArgs>(SessionStarted);
                sessionManager.SessionEnded += new EventHandler(sessionManager_SessionEnded);
                sessionManager.AddListener(flowRouter);

                readerThread = new Thread(new ThreadStart(SpinInfinite));
                readerThread.Priority = ThreadPriority.Highest;
                readerThread.Start();
            }
            catch (XnMException ex)
            {
                ///
                /// - todo: proper error logging here
                ///

                MessageBox.Show("Error initializing NITE.");
                MessageBox.Show(ex.ExceptionDescription);

                isOK = false;
            }
        }
Esempio n. 4
0
        public void Init()
        {
            try
            {
                state = SessionState.Initialized;
                context = new XnMOpenNIContext();
                context.Init();

                session = new XnMSessionManager(context, "Click,Wave", "RaiseHand");
                session.SessionStarted += new EventHandler<PointEventArgs>(session_SessionStarted);
                session.FocusStartDetected += new EventHandler<FocusStartEventArgs>(session_FocusStartDetected);

                slider = new XnMSelectableSlider2D(bounds.Width, bounds.Height);
                slider.Deactivate += new EventHandler(slider_Deactivate);
                slider.ItemHovered += new EventHandler<SelectableSlider2DHoverEventArgs>(slider_ItemHovered);

                pointDenoiser = new XnMPointDenoiser();
                pointDenoiser.AddListener(slider);

                flowRouter = new XnMFlowRouter();
                flowRouter.SetActiveControl(pointDenoiser);

                session.AddListener(flowRouter);
            }
            catch (XnMException)
            {
                state = SessionState.Starting;
            }
        }
Esempio n. 5
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);
        }