首页 文章

使用Kinect的simpleopenni点 Cloud 程序

提问于
浏览
0

我正在尝试使用处理来获得点 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++)
  {

    PVector currentPoint = depthPoints[i];

    point(currentPoint.x,  currentPoint.y, currentPoint.z );
  }

}

1 回答

  • 1

    你的代码很好,只是经过测试 . 它循环307200次,因为它将深度图像(640x480 = 307200)中的数据转换为3D位置 .

    你确定没有收到任何错误吗?此外,在Processing中绘制所有点有点慢,您可能想要跳过一些 . 并且作为测试,尝试打印出第一个点并查看值是否发生变化(应该)或者深度图像是否有任何数据(不是黑色/用零填充):

    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();
      image(kinect.depthImage(),0,0,160,120);//check depth image
    
      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+=4)//draw point for every 4th pixel
      {
    
        PVector currentPoint = depthPoints[i];
        if(i == 0) println(currentPoint);
        point(currentPoint.x,  currentPoint.y, currentPoint.z );
      }
    
    }
    

相关问题