110,571
社区成员
发帖
与我相关
我的任务
分享
private void kinectSensor_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
{
using (DepthImageFrame depthImageFrame = e.OpenDepthImageFrame())
{
if (depthImageFrame != null)
{
pixelData = new short[depthImageFrame.PixelDataLength];
depthImageFrame.CopyPixelDataTo(pixelData);
//this.image1.Source = BitmapSource.Create(depthImageFrame.Width, depthImageFrame.Height, 96, 96, PixelFormats.Gray16, null, pixelData, depthImageFrame.Width * depthImageFrame.BytesPerPixel);
this.depthFrame32 = new byte[depthImageFrame.Width * depthImageFrame.Height * 4];
this.depthFrame32 = ConvertDepthFrame(pixelData, ((KinectSensor)sender).DepthStream);
this.image1.Source = BitmapSource.Create(depthImageFrame.Width, depthImageFrame.Height, 96, 96, PixelFormats.Bgr32, null, depthFrame32, depthImageFrame.Width * 4);
}
}
}
namespace Microsoft.Kinect
{
// 摘要:
// Arguments for the DepthFrameReady events.
public sealed class DepthImageFrameReadyEventArgs : EventArgs
{
// 摘要:
// Container for one frame's worth of depth sensor image data Can return null
// if the data is not available. Upon success, returns the DepthImageFrame
// corresponding to this event, which must be Disposed.
//
// 返回结果:
// An a new depth image frame.
public DepthImageFrame OpenDepthImageFrame();
}
}