/// <summary> /// Store color image /// </summary> /// <param name="colorFrame">color frame to be stored</param> /// <param name="frameNumber">frame number</param> public static void Handle_ColorFrame(ColorFrame colorFrame, String frameNumber) { colorFrame.CopyConvertedFrameDataToArray(bgraColor, ColorImageFormat.Bgra); BitmapSource bitmapSource = BitmapSource.Create(colorWidth, colorHeight, 96.0, 96.0, PixelFormats.Bgra32, null, bgraColor, colorWidth << 2); String colorPath = FramesAndPaths.GetImageFilePath(FramesAndPaths.FileType.ColorImage, frameNumber); bitmapSource.Save(colorPath + ".jpg", ImageFormat.Jpeg); // Release colorFrame colorFrame.Dispose(); }
/// <summary> /// Store body index image /// </summary> /// <param name="bodyIndexFrame">body index frame to be stored</param> /// <param name="frameNumber">frame number</param> public static void Handle_BodyIndexFrame(BodyIndexFrame bodyIndexFrame, String frameNumber) { using (Microsoft.Kinect.KinectBuffer bodyIndexBuffer = bodyIndexFrame.LockImageBuffer()) { BitmapSource bitmapSource = BitmapSource.Create(bodyIndexWidth, bodyIndexHeight, 96.0, 96.0, PixelFormats.Gray8, null, bodyIndexBuffer.UnderlyingBuffer, (int)bodyIndexBuffer.Size, bodyIndexWidth * 1); String bodyIndexPath = FramesAndPaths.GetImageFilePath(FramesAndPaths.FileType.BodyIndexImage, frameNumber); bitmapSource.Save(bodyIndexPath + ".jpg", ImageFormat.Jpeg); } // Release bodyIndexFrame bodyIndexFrame.Dispose(); }
/// <summary> /// Store depth image /// </summary> /// <param name="depthFrame">depth frame to be stored</param> /// <param name="frameNumber">frame number</param> public static void Handle_DepthFrame(DepthFrame depthFrame, String frameNumber) { using (Microsoft.Kinect.KinectBuffer depthBuffer = depthFrame.LockImageBuffer()) { BitmapSource bitmapSource = BitmapSource.Create(depthWidth, depthHeight, 96.0, 96.0, PixelFormats.Gray16, null, depthBuffer.UnderlyingBuffer, (int)depthBuffer.Size, depthWidth << 1); String depthPath = FramesAndPaths.GetImageFilePath(FramesAndPaths.FileType.DepthImage, frameNumber); bitmapSource.Save(depthPath + ".png", ImageFormat.Png); } // Release depthFrame depthFrame.Dispose(); }
/// <summary> /// Store infrared image /// </summary> /// <param name="infraredFrame">infrared frame to be stored</param> /// <param name="frameNumber">frame number</param> public static void Handle_InfraredFrame(InfraredFrame infraredFrame, String frameNumber) { using (Microsoft.Kinect.KinectBuffer infraredBuffer = infraredFrame.LockImageBuffer()) { BitmapSource bitmapSource = BitmapSource.Create(infraredWidth, infraredHeight, 96.0, 96.0, PixelFormats.Gray16, null, infraredBuffer.UnderlyingBuffer, (int)infraredBuffer.Size, infraredWidth << 1); String infraredPath = FramesAndPaths.GetImageFilePath(FramesAndPaths.FileType.InfraredImage, frameNumber); bitmapSource.Save(infraredPath + ".jpg", ImageFormat.Jpeg); } // Release infraredFrame infraredFrame.Dispose(); }