/// <summary> /// Connections the specified object. /// </summary> /// <param name="obj">The object.</param> private void Connection(object obj) { if (null != obj) { var state = (bool)obj; if (!state) { Manipulator?.Disconnect(); } else { if (string.IsNullOrEmpty(SelectedCOMPort)) { BadgeText = "!"; ConnectionToggleIsChecked = false; return; } ConnectionToggleIsChecked = true; Manipulator = new E3JManipulator(Settings); Manipulator.Port.ConnectionStatusChanged += Port_ConnectionStatusChanged; Manipulator.Connect(SelectedCOMPort); Manipulator.Port.DataReceived += Port_DataReceived; KinectHandler?.StartKinect(Manipulator); } } }
protected void MainWindow_Loaded(object sender, RoutedEventArgs e) { try { kinectHandler = new KinectHandler(); this.kinectHandler.getSensor().Start(); this.kinectHandler.getSensor().ColorStream.Disable(); if (!this.kinectHandler.getSensor().ColorStream.IsEnabled) { this.kinectHandler.getSensor().ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); this.kinectHandler.getSensor().ColorFrameReady += new EventHandler <ColorImageFrameReadyEventArgs>(sensor_ColorFrameReady); } this.kinectHandler.getSensor().DepthStream.Disable(); if (!this.kinectHandler.getSensor().DepthStream.IsEnabled) { this.kinectHandler.getSensor().DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30); this.kinectHandler.getSensor().DepthFrameReady += new EventHandler <DepthImageFrameReadyEventArgs>(sensor_DepthFrameReady); } this.kinectHandler.getSensor().SkeletonStream.Disable(); if (!this.kinectHandler.getSensor().SkeletonStream.IsEnabled) { this.kinectHandler.getSensor().SkeletonStream.Enable(); this.kinectHandler.getSensor().SkeletonFrameReady += new EventHandler <SkeletonFrameReadyEventArgs>(sensor_SkeletonFrameReady); } } catch (Exception ex) { Console.Write(ex); System.Windows.Forms.MessageBox.Show("No Kinect device connected", "Device Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public WaitingWindow(WindowHandler windowHandler) { _windowHandler = windowHandler; _kinectHandler = _windowHandler.Game.KinectHandler; _spriteBatch = new SpriteBatch(_windowHandler.Game.GraphicsDevice); _spriteFont = Game1.contentManager.Load <SpriteFont>(@"MyFont"); startTimer = 0; _waitString = "Waiting for player"; }
public WaitingWindow(WindowHandler windowHandler) { _windowHandler = windowHandler; _kinectHandler = _windowHandler.Game.KinectHandler; _spriteBatch = new SpriteBatch(_windowHandler.Game.GraphicsDevice); _spriteFont = Game1.contentManager.Load<SpriteFont>(@"MyFont"); startTimer = 0; _waitString = "Waiting for player"; }
private void EnableKinect(object obj) { DialogHostIsOpen = true; DialogHost = new DialogHost() { CurrentAction = "Initializing Kinect" }; KinectHandler = new KinectHandler(); DialogHostIsOpen = false; }
public MainWindow() { InitializeComponent(); //Setup culture settings CultureInfo customCulture = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone(); customCulture.NumberFormat.NumberDecimalSeparator = "."; Thread.CurrentThread.CurrentCulture = customCulture; //Initialize Web and sensors WebSocketsHandler.Initialize(); SensorsHandler.Initialize(); //Setup kinect settings MainKinectHandler = KinectHandler.Instance(); SensorChooserUI.KinectSensorChooser = MainKinectHandler.SensorChooser; var regionSensorBinding = new Binding("Kinect") { Source = MainKinectHandler.SensorChooser }; //Setup GUI bindings BindingOperations.SetBinding(this.MainKinectRegion, KinectRegion.KinectSensorProperty, regionSensorBinding); MainKinectRegion.KinectSensor = MainKinectHandler.SensorChooser.Kinect; //Setup & Register Custom Gestures //Both hands up registered custom gesture. CustomGesturesHandler.Instance().RegisterCustomGesture( new CustomGesture("BothHandsUp", (skeleton) => { Joint rightHand = skeleton.Joints[JointType.HandRight]; Joint leftHand = skeleton.Joints[JointType.HandLeft]; Joint leftElbow = skeleton.Joints[JointType.ElbowLeft]; Joint rightElbow = skeleton.Joints[JointType.ElbowLeft]; Joint head = skeleton.Joints[JointType.Head]; //Hands are in front. if (leftHand.Position.Z < leftElbow.Position.Z && rightHand.Position.Z < rightElbow.Position.Z) { //Hands are over head. return(rightHand.Position.Y > head.Position.Y && leftHand.Position.Y > head.Position.Y); } return(CustomGesture.FAILURE); }) ); }
//InputManager m_inputManager; public KinectInputHandler(InputManager inputManager) { //this.m_inputManager = inputManager; kinectHandler = new KinectHandler(); kinectHandler.StartKinectSensor(); if (kinectHandler.SensorStatus == KinectSensorStatus.Started) { kinectHandler.StartKinectServices(); inputManager.GameState.IsKinectConnected = true; } //kinectHandler.onGestureChanged += new EventHandler (KinectHandlerOnGestureChanged); }
public NewSignRecord(Sign s, List <Sequence> examples) { this.InitializeComponent(); this.Cursor = Cursors.None; #if KINECT KinectHandler.Get().AddVideoListener(NUIVideoFrameReady); skeletonDrawer = new SkeletonDrawer(SkeletonImage); skeletonDrawer.StartDrawing(); CursorController.Get().StartListening(); #endif this.s = s; this.examples = examples; this.currentCount = -1; lblTrainExampleNum.Content = "Number of Training Examples: " + examples.Count; }
private Point GetDisplayPosition(Joint joint) { float depthX, depthY; KinectHandler.Get().GetDepthCoordsFromSkeleton(joint.Position, out depthX, out depthY); depthX = depthX * 320; //convert to 320, 240 space depthY = depthY * 240; //convert to 320, 240 space int colorX, colorY; KinectHandler.Get().GetVideoCoordsFromDepth(ImageResolution.Resolution640x480, (int)depthX, (int)depthY, out colorX, out colorY); // map back to skeleton.Width & skeleton.Height return(new Point((int)(skeletonCanvas.Width * colorX / 640.0), (int)(skeletonCanvas.Height * colorY / 480))); }
public TopDownTrackerViewModel() { //kinectImageSource = new BitmapImage(new Uri("c:\\lenna.png")); kinectHandler = KinectHandler.Instance; trackingStrategy = new SimpleKinectBlobTracker(); LoadReferenceFrame(); LoadMaskImage(); KinectCycle(); var uiRefreshTimer = new DispatcherTimer(); uiRefreshTimer.Interval = TimeSpan.FromMilliseconds(500); uiRefreshTimer.Tick += UpdateUIImages; uiRefreshTimer.Start(); }
/// <summary> /// Record a sequence, wait until silence is observed (user stands still) then /// output the extracted features to OnFinishedHandler /// </summary> /// <param name="onFinishedHandler">The function to call with the output as a parameter</param> /// <param name="onLowEntropyHandler">The function to call when partial silence is observed</param> /// <param name="onHighEntropyHandler">The function to call when the user is moving</param> public void RecordSequence(Action <Sequence> onFinishedHandler, Action <int> onLowEntropyHandler, Action onHighEntropyHandler) { // Start Recording frameHistory.Clear(); frames.Clear(); lowEntropyFrameCount = 0; onRecordingFinishedEventHandler = onFinishedHandler; onLowEntropyEventHandler = onLowEntropyHandler; onHighEntropyEventHandler = onHighEntropyHandler; KinectHandler.Get().SkeletonReady += SkeletonFrameReady; KinectHandler.Get().AddDepthListener(DepthReady); KinectHandler.Get().AddVideoListener(VideoReady); recordVideo = false; }
/// <summary> /// Stop recording the sequence /// </summary> public void CancelRecording() { KinectHandler.Get().SkeletonReady -= SkeletonFrameReady; KinectHandler.Get().RemoveDepthListener(DepthReady); KinectHandler.Get().RemoveVideoListener(VideoReady); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { Plant.LoadContent(); DeathFactory.LoadContent(); PoisonCloud.LoadContent(); spriteBatch = new SpriteBatch(GraphicsDevice); GameWindow gameWindow = new GameWindow(); gameWindow.Initialize(spriteBatch); windowHandler.ChangeWindow(gameWindow); kinectHandler = new KinectHandler(gameWindow); kinectThread = new Thread(() => kinectHandler.run()); kinectThread.IsBackground = true; kinectThread.Start(); }
public GameController() { kinect = new KinectHandler(); data = new KinectData(); }
/// <summary> /// Stop the drawing of the skeleton /// </summary> public void StopDrawing() { KinectHandler.Get().SkeletonDataReady -= DrawSkeleton; }