1

在处理中,我可以使用 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);
}
4

1 回答 1

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();

不会改变任何东西。

已提交问题,希望能得到解决。同时,尝试在不同的语言/框架中使用 OpenNI。OpenFrameworks 与 Processing 有许多相似之处(老实说,也有许多不同之处,但它不是火箭科学)。尝试xOpenNI 的实验性插件来测试多个摄像头,希望它能解决您的问题。

于 2013-02-07T13:10:20.863 回答