使用Kinect将深度数据转换为点云

时间:2016-06-28 00:35:08

标签: c# kinect

我想将深度数据从相机视图的整个场景转换为点云。这时我只从深度数据中跟踪和导入人体骨骼。如果有人可以帮助我,我会很感激

以下是代码:

                // 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++;

                                    }
                                }




                            }
                        }


                    }
                }

// p.X,p.Y,p.Z是人类骨骼的x-y-z位置

0 个答案:

没有答案