【问题标题】:SimpleOpenNI: Multiple Kinects and enableScene()/sceneImage() in ProcessingSimpleOpenNI:处理中的多个 Kinect 和 enableScene()/sceneImage()
【发布时间】:2013-01-25 20:11:31
【问题描述】:

在处理中,我可以使用 SimpleOpenNI 从 2 个 Kinect 成功绘制深度图,但我现在尝试绘制 2 个“场景”(来自 enableScene() 与 enableDepth())。两个 Kinect 都被检测到,但是当我绘制输出时,我看到同一个场景被绘制了两次(而使用 enableDepth() 总是给我 2 个不同的深度图像)。任何想法我做错了什么?提前致谢。

/* --------------------------------------------------------------------------
 * SimpleOpenNI Multi Camera Test
 * --------------------------------------------------------------------------
 */

import SimpleOpenNI.*;

SimpleOpenNI cam1;
SimpleOpenNI cam2;

void setup()
{
  size(640 * 2 + 10,480); 

  // start OpenNI, loads the library
  SimpleOpenNI.start();

  // init the cameras
  cam1 = new SimpleOpenNI(0,this);
  cam2 = new SimpleOpenNI(1,this);

  // set the camera generators ** HAD TO REVERSE ORDER FOR BOTH KINECTS TO WORK

  // enable Scene
  if(cam2.enableScene() == false)
  {
     println("Can't open the scene for Camera 2"); 
     exit();
     return;
  }

  // enable depthMap generation 
  if(cam1.enableScene() == false)
  {
     println("Can't open the scene for Camera 1"); 
     exit();
     return;
  }

  background(10,200,20);
}

void draw()
{
  // update the cams
  SimpleOpenNI.updateAll();

  image(cam1.sceneImage(),0,0);

  image(cam2.sceneImage(),640 + 10,0);
}

【问题讨论】:

  • 您的代码存在一些语法错误,现已修复,但问题仍然存在。在我的机器(旧的 macbook)上,SimpleOpenNI 无法生成第二个 Kinect 的深度图。我不确定这是 USB 总线限制还是 SimpleOpenNI 库本身存在问题。
  • 非常有趣。我们已经在几台全新的机器上使用 Kinect 在不同的总线上运行它,并且来自 enableDepth() 的简单深度图像可以工作,但是两个摄像头上的 enableScene() 始终会产生相同的场景,所以我认为它是 SimpleOpenNI 中的东西。那好吧。感谢您的观看。

标签: kinect processing openni simple-openni


【解决方案1】:

我已经使用 sceneMap() 功能完成了另一个文本,但看起来 SimpleOpenNI 内部没有正确更新确实存在问题:

/* --------------------------------------------------------------------------
 * SimpleOpenNI Multi Camera Test
 * --------------------------------------------------------------------------
 */

import SimpleOpenNI.*;

SimpleOpenNI cam1;
SimpleOpenNI cam2;

int numPixels = 640*480;
int[] sceneM1 = new int[numPixels];
int[] sceneM2 = new int[numPixels];
PImage scene1,scene2;

void setup()
{
  size(640 * 2 + 10,480 * 2 + 10); 

  // start OpenNI, loads the library
  SimpleOpenNI.start();

  // init the cameras
  cam1 = new SimpleOpenNI(0,this);
  cam2 = new SimpleOpenNI(1,this);

  // set the camera generators ** HAD TO REVERSE ORDER FOR BOTH KINECTS TO WORK

  // enable Scene
  if(cam2.enableScene() == false)
  {
     println("Can't open the scene for Camera 2"); 
     exit();
     return;
  }
//  cam2.enableDepth();//this fails when using only 1 bus

  // enable depthMap generation 
  if(cam1.enableScene() == false)
  {
     println("Can't open the scene for Camera 1"); 
     exit();
     return;
  }
  cam1.enableDepth();

  scene1 = createImage(640,480,RGB);
  scene2 = createImage(640,480,RGB);

  background(10,200,20);
}

void draw()
{
  // update the cams
  SimpleOpenNI.updateAll();

  image(cam1.depthImage(),0,0);
  image(cam1.sceneImage(),0,0);

  cam1.sceneMap(sceneM1);
  cam2.sceneMap(sceneM2);
  updateSceneImage(sceneM1,scene1);
  updateSceneImage(sceneM2,scene2);
  image(scene1,0,490);
  image(scene2,650,490);
}
void updateSceneImage(int[] sceneMap,PImage sceneImage){
  for(int i = 0; i < numPixels; i++) sceneImage.pixels[i] = sceneMap[i] * 255;
  sceneImage.updatePixels();
}

使用类似的东西

cam1.update();
cam2.update();

而不是

SimpleOpenNI.updateAll();

不会改变任何东西。

issue was filed,希望能解决。 同时,尝试在不同的语言/框架中使用 OpenNI。 OpenFrameworks 与 Processing 有很多相似之处(也有很多不同之处) 老实说,这也不是火箭科学)。 试试实验性的ofxOpenNI addon to test multiple cameras,希望它能解决你的问题。

【讨论】:

  • 啊,好主意。我的一位同事今天尝试了同样的事情并得到了相同的结果,但这是个好主意。无论如何,我一直想看看像 OpenFrameworks 或 Cinder 这样的东西,所以这可能是一个很好的机会。再次感谢您查看此内容。 (顺便说一句,为了解决我们在长期使用多个摄像头时尝试做的事情,我们使用 TSPS 作为多个摄像头的辅助应用程序,效果很好。opentsps.com
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-15
  • 1970-01-01
相关资源
最近更新 更多