基于深度数据的RGB图像 [英] RGB image based on depth data
问题描述
我试图根据深度数据在图像的所需部分上显示原始颜色。例如,如果主题在深度(z值)的某个边界内,我想用
原始颜色显示它,而超出边界的其余帧应该显示为黑色或其他任何东西。到目前为止,我只能将它显示为单一颜色,而不是原始颜色数据。下面的代码将显示与RED颜色边界的代码。
在浏览了一些论坛之后,我注意到SDK中有一个参数' GetColorPixelCoordinatesFromDepthPixel'。但是我没有在我安装的SDK中显示(SDK v1.0)。任何关于如何解决这个问题的指导都将非常感激。
这是我目前拥有的代码。
I am trying to display original colour on desired parts of the image based on the depth data. For example, if the subject is within certain boundary of depth(z-value), I want to display it with original colour and the rest of the frame which are out of boundary should be displayed as black or anything else. So far, I could only get it displayed in a single colour, not original color data. The code below will display those in boundary with RED colour. After going through some forums, i noticed there is a parameter 'GetColorPixelCoordinatesFromDepthPixel' in SDK. But this is not shown in the SDK that I installed (SDK v1.0). Any guidance on how to go about this would be much appreciated. Here's the code that I currently have.
DepthImageFrame depthframe = _sensor.DepthStream.OpenNextFrame(0);
if (depthframe != null)
{
short[] depthArray = depthframe.ToDepthArray();
byte[] depthBytes = new byte[depthArray.Length * 4];
for (int colorIndex = 0, depthIndex = 0;
colorIndex < depthBytes.Length;
colorIndex += 4, depthIndex++)
{
depthBytes[colorIndex + GREEN_INDEX] = 0;
depthBytes[colorIndex + BLUE_INDEX] = 0;
if (depthArray[depthIndex] > _minDepth &&
depthArray[depthIndex] < _maxDepth)
{
depthBytes[colorIndex + RED_INDEX] = 255;
}
else
depthBytes[colorIndex + RED_INDEX] = 0;
}
source = depthBytes.ToBitmapSource(depthframe.Width, depthframe.Height);
推荐答案
看看
http://social.msdn.microsoft.com/Forums/en-US/kinectsdknuiapi/thread/01998bc1-73a2-46f2-9635-677b4b2040ce/。你应该一直在使用最新的SDK,截至回复日期为1.5.2,因为新功能一直在增加。
Take a look at http://social.msdn.microsoft.com/Forums/en-US/kinectsdknuiapi/thread/01998bc1-73a2-46f2-9635-677b4b2040ce/. You should always be using the latest SDK, which is 1.5.2 as of the date of the response because new features are being added all the time.
这篇关于基于深度数据的RGB图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!