public static void Run() { Initializing = true; Trace.WriteLine("Initializing Kinect..."); XnMOpenNIContext context = new XnMOpenNIContext(); try { context.Init(); KinectExists = true; Trace.WriteLine("Kinect exists"); } catch (XnMException) { Initializing = false; Active = false; KinectExists = false; return; } // Kinect session Trace.WriteLine("Creating session manager..."); sessionManager = new XnMSessionManager(context, "Wave", "RaiseHand"); sessionManager.SessionStarted += new EventHandler <PointEventArgs>(sessionManager_SessionStarted); sessionManager.SessionEnded += new EventHandler(sessionManager_SessionEnded); // hand tracking filter Trace.WriteLine("Creating filters..."); var pointManager = new KinectPointManager(); sessionManager.AddListener(pointManager); var swipeDetector = new XnMSwipeDetector(true); swipeDetector.GeneralSwipe += new EventHandler <SwipeDetectorGeneralEventArgs>(swipeDetector_GeneralSwipe); swipeDetector.MotionSpeedThreshold = .7f; swipeDetector.MotionTime = 300; sessionManager.AddListener(swipeDetector); Initializing = false; Trace.WriteLine("Kinect initialized"); // infinite loop until app shutdown while (!ShutDown) { context.Update(); sessionManager.Update(context); } }
public static void Run() { Initializing = true; Trace.WriteLine("Initializing Kinect..."); XnMOpenNIContext context = new XnMOpenNIContext(); try { context.Init(); KinectExists = true; Trace.WriteLine("Kinect exists"); } catch (XnMException) { Initializing = false; Active = false; KinectExists = false; return; } // Kinect session Trace.WriteLine("Creating session manager..."); sessionManager = new XnMSessionManager(context, "Wave", "RaiseHand"); sessionManager.SessionStarted += new EventHandler<PointEventArgs>(sessionManager_SessionStarted); sessionManager.SessionEnded += new EventHandler(sessionManager_SessionEnded); // hand tracking filter Trace.WriteLine("Creating filters..."); var pointManager = new KinectPointManager(); sessionManager.AddListener(pointManager); var swipeDetector = new XnMSwipeDetector(true); swipeDetector.GeneralSwipe += new EventHandler<SwipeDetectorGeneralEventArgs>(swipeDetector_GeneralSwipe); swipeDetector.MotionSpeedThreshold = .7f; swipeDetector.MotionTime = 300; sessionManager.AddListener(swipeDetector); Initializing = false; Trace.WriteLine("Kinect initialized"); // infinite loop until app shutdown while (!ShutDown) { context.Update(); sessionManager.Update(context); } }