C# 使用Kinect将深度数据转换为点云
我想将相机视图的整个场景中的深度数据转换为点云。此时,我只跟踪并导入深度数据中的人体骨架。如果有人能帮助我,我将不胜感激 代码如下:C# 使用Kinect将深度数据转换为点云,c#,kinect,C#,Kinect,我想将相机视图的整个场景中的深度数据转换为点云。此时,我只跟踪并导入深度数据中的人体骨架。如果有人能帮助我,我将不胜感激 代码如下: // we got all frames if (multiSourceFrameProcessed && depthFrameProcessed && bodyIndexFrameProcessed) {
// we got all frames
if (multiSourceFrameProcessed && depthFrameProcessed && bodyIndexFrameProcessed)
{
StringBuilder sb = new StringBuilder();
int len = 0;
// this.coordinateMapper.MapDepthFrameToColorSpace(this.depthFrameData, this.colorPoints);
this.coordinateMapper.MapDepthFrameToCameraSpace(this.depthFrameData, this.cameraPoints);
// loop over each row and column of the depth
for (int y = 0; y < depthHeight; y += step)
{
for (int x = 0; x < depthWidth; x += step)
{
// calculate index into depth array
int depthIndex = (y * depthWidth) + x;
byte player = this.bodyIndexFrameData[depthIndex];
// if we're tracking a player for the current pixel, sets its color and alpha to full
if (player != 0xff)
{
//ty = ty + 1;
CameraSpacePoint p = this.cameraPoints[depthIndex];
// retrieve the depth to color mapping for the current depth pixel
// ColorSpacePoint colorPoint = this.colorPoints[depthIndex];
// make sure the depth pixel maps to a valid point in color space
if (!(Double.IsInfinity(p.X)) && !(Double.IsInfinity(p.Y)) && !(Double.IsInfinity(p.Z)))
{
sb.Append(String.Format(CultureInfo.InvariantCulture, "{0} {1} {2} \n", p.X, p.Y, p.Z));
if (this.NewPointEvent != null)
{
this.NewPointEvent(this, new NewPointEventArgs(p.X, p.Y, p.Z));
len++;
}
}
}
}
}
}
//我们得到了所有帧
if(multiSourceFrameProcessed&&depthFrameProcessed&&bodyIndexFrameProcessed)
{
StringBuilder sb=新的StringBuilder();
int len=0;
//this.coordinateMapper.MapDepthFrameToColorSpace(this.depthFrameData,this.colorPoints);
this.coordinateMapper.MapDepthFrameToCameraSpace(this.depthFrameData,this.cameraPoints);
//在深度的每行和每列上循环
对于(int y=0;y
//p、 X,p.Y,p.Z是人体骨骼的X-Y-Z位置