void MainWindow_Loaded(object sender, RoutedEventArgs e) { var parameters = new TransformSmoothParameters { Smoothing = 0.3f, Correction = 0.0f, Prediction = 0.0f, JitterRadius = 1.0f, MaxDeviationRadius = 0.5f }; this.sensor = KinectSensor.KinectSensors[0]; this.sensor.ColorStream.Enable(); this.sensor.SkeletonStream.Enable(parameters); //this.sensor.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(sensor_SkeletonFrameReady); this.sensor.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(sensor_AllFramesReady); ColorViewer.Kinect = sensor; recognitionEngine = new GestureRecognitionEngine(); recognitionEngine.GestureRecognized += new EventHandler<GestureEventArgs>(recognitionEngine_GestureRecognized); this.sensor.Start(); }
/// <summary> /// Initializes a new instance of the <see cref="MainWindow" /> class. /// </summary> public MainWindow() { InitializePresentation(); picturePaths = CreatePicturePaths(); videoPlaying = false; this.PreviousPicture = p.getPreviousSlide().getImage(); this.Picture = p.getCurrentSlide().getImage(); this.NextPicture = p.getNextSlide().getImage(); this.ParentPicture = null; InitializeComponent(); // Create the gesture recognizer. this.activeRecognizer = this.CreateRecognizer(); recognitionEngine = new GestureRecognitionEngine(); recognitionEngine.GestureRecognized += new EventHandler<GestureEventArgs>(recognitionEngine_GestureRecognized); // Wire-up window loaded event. Loaded += this.OnMainWindowLoaded; GetVideo(p.getCurrentSlide()); }
private void SetUpKinect(KinectSensor sensor) { if (sensor.Status == KinectStatus.Connected) { sensor.DepthStream.Enable(); ColorImageStream colorStream = sensor.ColorStream; colorStream.Enable(); sensor.SkeletonFrameReady += SkeletonFrameReady; this.bitmapy = new WriteableBitmap(colorStream.FrameWidth, colorStream.FrameHeight, 96, 96, PixelFormats.Bgr32, null); this.colorImageBitMapRect = new Int32Rect(0, 0, colorStream.FrameWidth, colorStream.FrameHeight); this._ColourImageStride = colorStream.FrameWidth * colorStream.FrameBytesPerPixel; ColourStream.Source = this.bitmapy; sensor.ColorFrameReady += SensorColourReady; var SmoothingParams = new TransformSmoothParameters { }; sensor.SkeletonStream.Enable(SmoothingParams); recognitionEngine = new GestureRecognitionEngine(); recog2 = new GestureRecognitionEngine(); recog3 = new GestureRecognitionEngine(); recog4 = new GestureRecognitionEngine(); recog3.GestureType = GestureType.Eating; recog4.GestureType = GestureType.Toilet; recog2.GestureType = GestureType.Sleeping; recog3.GestureRecognized += new EventHandler<GestureEventArgs> (recog3_GestureDone); recog2.GestureRecognized += new EventHandler<GestureEventArgs> (recog2_GestureDone); recog4.GestureRecognized += new EventHandler<GestureEventArgs>(recog4_GestureRecognized); recognitionEngine.GestureType = GestureType.HandsClapping; recognitionEngine.GestureRecognized += new EventHandler<GestureEventArgs> (recognitionEngine_GestureRecognized); sensor.Start(); } }