/// <summary> /// Displays the raw camera image from the Kinect sensor /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnCameraImageFrameReady(object sender, IavaColorImageFrameReadyEventArgs e) { if (e.ImageFrame == null) { return; } // Set up the writable bitmap... if (_firstRun) { // This is more efficient than creating a new bitmap every frame _colorBitmap = new WriteableBitmap( e.ImageFrame.Width, e.ImageFrame.Height, 96.0, // DpiX 96.0, // DpiY PixelFormats.Bgr32, null); // Set the image source VideoFeed.Source = _colorBitmap; // Indicate this is not the first run _firstRun = false; } // Draw the image _colorBitmap.WritePixels( new Int32Rect(0, 0, e.ImageFrame.Width, e.ImageFrame.Height), e.ImageFrame.PixelData, e.ImageFrame.Width * ((PixelFormats.Bgr32.BitsPerPixel + 7) / 8), // Got this from sample code 0); }
/// <summary> /// Handles the ColorImageFrameReady event of the IRuntime control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="IavaColorImageFrameReadyEventArgs"/> instance containing the event data.</param> private static void OnImageFrameReady(object sender, IavaColorImageFrameReadyEventArgs e) { if (ImageFrameReady != null) { ImageFrameReady(null, e); } }