我正在尝试将 kinect 深度传感器图像保存到 png 文件中。我试图用我的 RGB 相机拍摄它,它没有任何问题。有什么我错过的吗?PS 我正在使用 Kinect ToolKit 的函数来显示 rgb 和深度图像。
WriteableBitmap depthBitmap;
DepthStreamManager dsm;
dsm = new DepthStreamManager();
kinect.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
kinect.DepthFrameReady += kinect_DepthFrameReady;
depthBitmap = new WriteableBitmap(kinect.DepthStream.FrameWidth,this.kinect.DepthStream.FrameHeight, 96.0, 96.0, PixelFormats.Gray16, null);
private string TakeImage(int x)
{
if (x == 0)
{
BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(this.depthBitmap));
string myPhotos = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string path = System.IO.Path.Combine(myPhotos, "Image 1.png");
try
{
using (FileStream fs = new FileStream(path, FileMode.Create))
{
encoder.Save(fs);
}
}
catch (IOException details)
{
Console.Write(details.ToString());
}
if (path == null)
return "Image was not taken.";
else
return path;
}}