我已经尝试过自己。通常深度数据是16位值。 13个高阶比特包含距离,3个低阶比特包含用户分段映射。
用户分割贴图仅在骨架跟踪处于活动状态时生成,我相信这不在您的示例中。虽然rgb值是24位,但它似乎工作。我从分段的手中获得图像。
Bitmap bmpOrg = new Bitmap("bKawM.png");
Bitmap bmp = new Bitmap(106, 119);
for (int i = 0; i < 106;i++)
{
for (int j = 0; j < 119;j++)
{
Color rgb = bmpOrg.GetPixel(i, j);
int bit24 = (rgb.B << 16 + rgb.G << 8 + rgb.R);
int user = bit24 & 0x07;
int realDepth = bit24 >> 3;
bmp.SetPixel(i, j, Color.FromArgb(realDepth));
}
}
pictureBox1.Image = bmp;
我的输出:
我用它再次播放。首先,我在Photoshop中增加了亮度和对比度。 因此,如果您不需要以毫米为单位的实际深度值,则rgb值可用。
然后我试图与WPF从图像获取16位的值,因为图像进行编码的16位灰度。
Stream imageStreamSource = new FileStream("bKawM.png", FileMode.Open, FileAccess.Read, FileShare.Read);
PngBitmapDecoder decoder = new PngBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapSource bitmapSource = decoder.Frames[0];
int height = bitmapSource.PixelHeight;
int width = bitmapSource.PixelWidth;
int stride = width * ((bitmapSource.Format.BitsPerPixel + 7)/8);
byte[] bytes = new byte[height * stride];
bitmapSource.CopyPixels(bytes, stride, 0);
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
{
byte low = bytes[y * stride + x + 0];
byte high = bytes[y * stride + x + 1];
ushort bit16 = (ushort)((high << 8) | low);
int user = bit16 & 0x07;
int realDepth = bit16 >> 3;
}
}
我创建了深度值的新形象,它看起来很奇怪。我没有找到任何信息 图像包含的数据。我不知道它是否包含用户数据(3位),或者深度是否在保存到文件之前以某种方式转换。
我运行了你的代码并生成了相同的输出文件,但是看起来这个输出中没有深度信息。而不是深度信息,它更像是一个二进制。我期待深度图像.. – Sait 2013-03-04 07:50:33
我已经更新了我的答案。希望这有助于.. – bitWorking 2013-03-04 20:34:41
好吧,事实证明,最有可能的是,图像并不包含比我刚开始时想的更多的东西。谢谢你的帮助。 – Sait 2013-03-05 16:53:10