【发布时间】:2014-04-10 16:50:15
【问题描述】:
我正在使用 Kinect 进行一个研究项目,直到现在我只是在搞乱骨骼跟踪。现在我进入了深度流的深处,我想知道如何创建我们在某些深度流中看到的 RGB 色标。我的是灰度。深度事件的一部分我不理解,我觉得这对于理解它是如何工作的以及如何将其更改为颜色以及强度变量的定义非常重要。
private void SensorDepthFrameReady(object sender, DepthImageFrameReadyEventArgs e){
using (DepthImageFrame depthFrame = e.OpenDepthImageFrame())
{
if (depthFrame != null)
{
// Copy the pixel data from the image to a temporary array
depthFrame.CopyDepthImagePixelDataTo(this.depthPixels);
// Get the min and max reliable depth for the current frame
int minDepth = depthFrame.MinDepth;
int maxDepth = depthFrame.MaxDepth;
// Convert the depth to RGB
int colorPixelIndex = 0;
for (int i = 0; i < this.depthPixels.Length; ++i)
{
// Get the depth for this pixel
short depth = depthPixels[i].Depth;
if (depth > 2000) depth = 0; //ive put this here just to test background elimination
byte intensity = (byte)(depth >= minDepth && depth <= maxDepth ? depth : 0);
//WHAT IS THIS LINE ABOVE DOING?
// Write out blue byte
this.colorPixels[colorPixelIndex++] = intensity;
// Write out green byte
this.colorPixels[colorPixelIndex++] = intensity;
// Write out red byte
this.colorPixels[colorPixelIndex++] = intensity;
// We're outputting BGR, the last byte in the 32 bits is unused so skip it
// If we were outputting BGRA, we would write alpha here.
++colorPixelIndex;
}
// Write the pixel data into our bitmap
this.colorBitmap.WritePixels(
new Int32Rect(0, 0, this.colorBitmap.PixelWidth, this.colorBitmap.PixelHeight),
this.colorPixels,
this.colorBitmap.PixelWidth * sizeof(int),
0);
}
}
}
【问题讨论】:
-
您是否找到了为深度图像着色的解决方案?
-
最后我使用了我在 kinect 示例中找到的一个类,该文件名为 DepthColorizer.cs。查看您的具有深度着色的样本!
标签: c# kinect kinect-sdk