获取Kinect v2中每个3D点的RGB值

时间:2017-11-21 10:40:09

标签: c# kinect-sdk kinect-v2

我对Kinect v2 CoordinateMapper API感到困惑。我想在Kinect v2中获取每个3D点的RGB值,即CameraSpacePoint

请参阅下面的代码段:

var depthFrame = multiSourceFrame.DepthFrameReference.AcquireFrame();
var colorFrame = multiSourceFrame.ColorFrameReference.AcquireFrame();

var depthWidth = depthFrame.FrameDescription.Width;
var depthHeight = depthFrame.FrameDescription.Height;

ushort[] depthData = new ushort[depthWidth * depthHeight];
CameraSpacePoint[] camerapoints = new CameraSpacePoint[depthData.Length];
ColorSpacePoint[] colorpoints = new ColorSpacePoint[depthData.Length];

depthFrame.CopyFrameDataToArray(depthData);
this.coordinateMapper.MapDepthFrameToCameraSpace(depthData, camerapoints);
this.coordinateMapper.MapDepthFrameToColorSpace(depthData, colorpoints);

3D点存储在camerapoints变量中。我想要每个camerapoints的RGB值。换句话说,请参阅下面的pesudo代码:

RGBPoint[] rgbpoints = new RGBPoint[depthData.Length];
RGBPoint rgbpoint = rgbpoints[0];
int red   = rgbpoint.r
int green = rgbpoint.g
int blue  = rgbpoint.b

一如既往,非常感谢你。我非常感谢您的回应。

1 个答案:

答案 0 :(得分:1)

android数组包含与colorpoints数组中每个像素对应的(x,y)索引。从这里开始,我们可以在depthData指示的每个特定(x,y)索引处获取颜色框架数据(来自colorFrame)。

colorpoints[index]