/// <summary> /// Starts a new session with the Kinect's cameras /// </summary> public static void Run() { XnMOpenNIContext context = new XnMOpenNIContext(); try { context.Init(); KinectExists = true; } catch (XnMException) { Trace.WriteLine("Kinect device was not found."); Active = false; KinectFail = true; return; } Trace.WriteLine("Kinect device found."); sessionManager = new XnMSessionManager(context, "RaiseHand", "RaiseHand"); sessionManager.SessionStarted += new EventHandler <PointEventArgs>(sessionManager_SessionStarted); sessionManager.SessionEnded += new EventHandler(sessionManager_SessionEnded); RegisterGestures(); while (!ShutDown) { context.Update(); sessionManager.Update(context); } }
static void Main(string[] args) { Console.WriteLine("Connecting to device..."); var context = new XnMOpenNIContext(); context.Init(); var session = new XnMSessionManager(context, "Wave", "RaiseHand"); session.SessionStarted += new EventHandler <PointEventArgs>(session_SessionStarted); session.SessionEnded += new EventHandler(session_SessionEnded); var pointFilter = new XnMPointFilter(); pointFilter.PointCreate += new EventHandler <PointBasedEventArgs>(pointControl_PointCreate); pointFilter.PointDestroy += new EventHandler <PointDestroyEventArgs>(pointControl_PointDestroy); pointFilter.PointUpdate += new EventHandler <PointBasedEventArgs>(pointControl_PointUpdate); session.AddListener(pointFilter); Console.WriteLine("Wave to start."); while (!Console.KeyAvailable) { context.Update(); session.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); } }
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; points = new Point3D[SmoothingFactor]; XnMOpenNIContext context = new XnMOpenNIContext(); try { context.Init(); KinectExists = true; } catch (XnMException) { Initializing = false; Active = false; KinectExists = false; return; } // Kinect session sessionManager = new XnMSessionManager(context, "Wave", "RaiseHand"); sessionManager.SessionStarted += new EventHandler <PointEventArgs>(sessionManager_SessionStarted); sessionManager.SessionEnded += new EventHandler(sessionManager_SessionEnded); // hand tracking filter XnMPointFilter filter = new XnMPointFilter(); filter.PointCreate += new EventHandler <PointBasedEventArgs>(control_PointCreate); filter.PointUpdate += new EventHandler <PointBasedEventArgs>(control_PointUpdate); sessionManager.AddListener(filter); Initializing = false; // infinite loop until app shutdown while (!ShutDown) { context.Update(); sessionManager.Update(context); } }
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; } }
static void Main(string[] args) { Console.WriteLine("Connecting to device..."); var context = new XnMOpenNIContext(); context.Init(); var session = new XnMSessionManager(context, "Wave", "RaiseHand"); session.FocusStartDetected += new EventHandler <FocusStartEventArgs>(session_FocusStartDetected); session.SessionStarted += new EventHandler <PointEventArgs>(session_SessionStarted); session.SessionEnded += new EventHandler(session_SessionEnded); Console.WriteLine("Running. Press any key to exit."); while (!Console.KeyAvailable) { context.Update(); session.Update(context); } }
static void Main(string[] args) { Console.WriteLine("Connecting to device..."); var context = new XnMOpenNIContext(); context.Init(); var session = new XnMSessionManager(context, "Wave", "RaiseHand"); var pointControl = new XnMPointFilter(); pointControl.PointUpdate += new EventHandler <PointBasedEventArgs>(pointControl_PointUpdate); pointControl.PointDestroy += new EventHandler <PointDestroyEventArgs>(pointControl_PointDestroy); pointControl.PointCreate += new EventHandler <PointBasedEventArgs>(pointControl_PointCreate); session.AddListener(pointControl); Console.WriteLine("Wave to start."); while (!Console.KeyAvailable) { context.Update(); session.Update(context); Console.Clear(); if (points.Keys.Count > 0) { foreach (var key in points.Keys) { var point = points[key]; Console.WriteLine("{0}: {1}, {2}, {3}", key.ToString(), point.X.ToString(), point.Y.ToString(), point.Z.ToString()); } } else { Console.WriteLine("No points."); Console.WriteLine("Please wave to start."); } } }
static void Main(string[] args) { Console.WriteLine("Connecting to device..."); var context = new XnMOpenNIContext(); context.Init(); var session = new XnMSessionManager(context, "Wave", "RaiseHand"); var pointControl = new XnMPointFilter(); pointControl.PointUpdate += new EventHandler<PointBasedEventArgs>(pointControl_PointUpdate); pointControl.PointDestroy += new EventHandler<PointDestroyEventArgs>(pointControl_PointDestroy); pointControl.PointCreate += new EventHandler<PointBasedEventArgs>(pointControl_PointCreate); session.AddListener(pointControl); Console.WriteLine("Wave to start."); while (!Console.KeyAvailable) { context.Update(); session.Update(context); Console.Clear(); if (points.Keys.Count > 0) { foreach (var key in points.Keys) { var point = points[key]; Console.WriteLine("{0}: {1}, {2}, {3}", key.ToString(), point.X.ToString(), point.Y.ToString(), point.Z.ToString()); } } else { Console.WriteLine("No points."); Console.WriteLine("Please wave to start."); } } }
public void IniciarKinect() { Debug.WriteLine("Iniciando acceso a Kinect ..."); //Instancia o contexto do Kinect para Iniciar Operação context = new XnMOpenNIContext(); //Inicia Kinect context.Init(); neverStarted = true; //SessionManager configurado para quando você sacudir a mão ele iniciar //Wave seria o movimento de tchau //E RaiseHand é só erguer a mão... //Os eventos serão disparador com o foco na mão, ou seja, se perder o foco vai ter que fazer o RaiseHand novamente sessionManager = new XnMSessionManager(context, "Wave", "RaiseHand"); swipeDetector = new XnMSwipeDetector(true); swipeDetector.MotionTime = 600; swipeDetector.SteadyDuration = 10; //200 uint swipeDetector.SteadyMaxVelocity = 1f; //0.01 float swipeDetector.XAngleThreshold = 25.00f; //25.0 float swipeDetector.YAngleThreshold = 25.00f; //20.0 float swipeDetector.GeneralSwipe += OnGeneralSwipe; sessionManager.AddListener(swipeDetector); //O evento é disparado quando for feito o tchauzinho sessionManager.SessionStarted += SessionManagerSessionStarted; //Thread Necessária thread = new Thread(mainLoop); thread.Start(); //Mensagem de Inicio Debug.WriteLine("Kinect configurado. Fazer saudação para iniciar Sessao"); Debug.WriteLine(""); }
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; } }
public void Init() { context = new XnMOpenNIContext(); context.Init(); sessionManager = new XnMSessionManager(context, "Click,Wave", "RaiseHand"); sessionManager.SessionStarted += new EventHandler<PointEventArgs>(sessionManager_SessionStarted); sessionManager.SessionEnded += new EventHandler(sessionManager_SessionEnded); //slider2D = new XnMSelectableSlider2D(xItems, yItems); //slider2D.Activate += new EventHandler(slider2D_Activate); //slider2D.Deactivate += new EventHandler(slider2D_Deactivate); //slider2D.ValueChanged += new EventHandler<SelectableSlider2DValueChangedEventArgs>(slider2D_ValueChanged); //slider2D.MessageUpdate += new EventHandler<OneMessageEventArgs>(slider2D_MessageUpdate); //slider2D.ItemHovered += new EventHandler<SelectableSlider2DHoverEventArgs>(slider2D_ItemHovered); //slider2D.ItemSelected += new EventHandler<SelectableSlider2DSelectEventArgs>(slider2D_ItemSelected); //pointDenoiser = new XnMPointDenoiser(); //pointDenoiser.AddListener(slider2D); //flowRouter = new XnMFlowRouter(); //flowRouter.SetActiveControl(pointDenoiser); circleDetector = new XnMCircleDetector(); circleDetector.Circle += new EventHandler<CircleEventArgs>(circleDetector_Circle); pushDetector = new XnMPushDetector(); pushDetector.Push += new EventHandler<PushDetectorEventArgs>(pushDetector_Push); swipeDetector = new XnMSwipeDetector(true); swipeDetector.GeneralSwipe += new EventHandler<SwipeDetectorGeneralEventArgs>(swipeDetector_GeneralSwipe); steadyDetector = new XnMSteadyDetector(5, 5000); steadyDetector.Activate += new EventHandler(steadyDetector_Activate); steadyDetector.Deactivate += new EventHandler(steadyDetector_Deactivate); steadyDetector.Steady += new EventHandler<SteadyEventArgs>(steadyDetector_Steady); //sessionManager.AddListener(flowRouter); sessionManager.AddListener(circleDetector); sessionManager.AddListener(pushDetector); sessionManager.AddListener(swipeDetector); sessionManager.AddListener(steadyDetector); Thread th = new Thread(new ThreadStart(SpinInfinite)); th.Priority = ThreadPriority.Lowest; th.Start(); }
/// <summary> /// Starts a new session with the Kinect's cameras /// </summary> public static void Run() { XnMOpenNIContext context = new XnMOpenNIContext(); try { context.Init(); KinectExists = true; } catch (XnMException) { Trace.WriteLine("Kinect device was not found."); Active = false; KinectFail = true; return; } Trace.WriteLine("Kinect device found."); sessionManager = new XnMSessionManager(context, "RaiseHand", "RaiseHand"); sessionManager.SessionStarted += new EventHandler<PointEventArgs>(sessionManager_SessionStarted); sessionManager.SessionEnded += new EventHandler(sessionManager_SessionEnded); RegisterGestures(); while (!ShutDown) { context.Update(); sessionManager.Update(context); } }