//Code for Getting Point Cloud
import SimpleOpenNI.*;
import processing.opengl.*;
SimpleOpenNI kinect;
void setup()
{
size( 1024, 768, OPENGL);
kinect = new SimpleOpenNI( this );
kinect.enableDepth();
}
void draw()
{
background( 0);
kinect.update();
//translate( width/2, height/2, -1000);
rotateX( radians(180));
stroke(255);
PVector[] depthPoints = kinect.depthMapRealWorld();
//the program get stucked in the for loop it loops 307200 times and I don't have any points output
for( int i = 0; i < depthPoints.length ; i+=5)
{
PVector currentPoint = depthPoints[i];
if (currentPoint.z < 2000.0)
{
point(currentPoint.x, currentPoint.y, currentPoint.z );
//print("currentPoint :", currentPoint );
}
}
}
2 回答
我相信要创建一个点 Cloud ,你需要一个彩色图像和一个深度图像(又名depth map) . 您正在使用的相机需要能够构建深度图像,我相信通常使用红外光 . Microsoft Kinect是使用红外线构建深度图像的相机示例 .
您可以查看ofxKinect示例以获取更多信息 . 它给出了从kinect生成的点 Cloud 的示例 .
从Processing SimpleOpenNI库示例中轻松获取Point Cloud .
以下是我为从Kinect处理点 Cloud 而编写的代码:
您可以通过Kinect覆盖您的纪念碑 . 但是,如果您需要将RGB输出转换为深度数据,那是不可能的,因为Kinect会在对象上投射红外光来计算深度,这是通过流数据无法实现的 . 即使您使用带Kinect的相机,也只能使用来自它的RGB流 . 对于深度,使用Kinect的传感器是您最好的选择 . 为了获得更好的效果,请使用新的Kinect版本2.干杯!