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; } }
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; } }
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; } }