22

我目前使用名为procamcalib的JavaCV软件来校准以 Kinect RGB 相机为原点的 Kinect 投影仪设置。此设置仅包含一个 Kinect RGB 相机(我目前大致将 Kinect 用作​​普通相机)和一个投影仪。该校准软件使用LibFreenect (OpenKinect) 作为 Kinect 驱动程序。

一旦软件完成它的过程,它会给我相机和投影仪的内在和外在参数,这些参数被扔给OpenGL软件以验证校准,并且是一些问题开始的地方。一旦正确设置了投影和模型视图,我应该能够将 Kinect 看到的内容与正在投影的内容相匹配,但为了实现这一点,我必须在所有 3 个轴上进行手动平移,而最后一部分不是对我有任何意义!请各位大神帮我整理一下好吗?用于检索 Kinect 数据的 SDK 是OpenNI(不是最新的 2.x 版本,应该是 1.5.x)

我将准确解释我正在做什么来重现此错误。校准参数使用如下:

投影矩阵设置为(基于 http://sightations.wordpress.com/2010/08/03/simulating-calibrated-cameras-in-opengl/):

r = width/2.0f;         l = -width/2.0f;
t = height/2.0f;        b = -height/2.0f;

alpha = fx;      beta = fy;
xo    = cx;      yo   = cy;

X = kinectCalibration.c_near + kinectCalibration.c_far;
Y = kinectCalibration.c_near*kinectCalibration.c_far;

d = kinectCalibration.c_near - kinectCalibration.c_far;


float* glOrthoMatrix = (float*)malloc(16*sizeof(float));

glOrthoMatrix[0] = 2/(r-l); glOrthoMatrix[4] = 0.0f;        glOrthoMatrix[8] = 0.0f;        glOrthoMatrix[12] = (r+l)/(l-r);
glOrthoMatrix[1] = 0.0f;    glOrthoMatrix[5] = 2/(t-b);     glOrthoMatrix[9] = 0.0f;        glOrthoMatrix[13] = (t+b)/(b-t);
glOrthoMatrix[2] = 0.0f;    glOrthoMatrix[6] = 0.0f;        glOrthoMatrix[10] = 2/d;        glOrthoMatrix[14] = X/d;
glOrthoMatrix[3] = 0.0f;    glOrthoMatrix[7] = 0.0f;        glOrthoMatrix[11] = 0.0f;       glOrthoMatrix[15] = 1;
printM( glOrthoMatrix, 4, 4, true, "glOrthoMatrix" );


float* glCameraMatrix = (float*)malloc(16*sizeof(float));

glCameraMatrix[0] = alpha;  glCameraMatrix[4] = skew;   glCameraMatrix[8] = -xo;    glCameraMatrix[12] = 0.0f;
glCameraMatrix[1] = 0.0f;   glCameraMatrix[5] = beta;   glCameraMatrix[9] = -yo;    glCameraMatrix[13] = 0.0f;
glCameraMatrix[2] = 0.0f;   glCameraMatrix[6] = 0.0f;   glCameraMatrix[10] = X;     glCameraMatrix[14] = Y;
glCameraMatrix[3] = 0.0f;   glCameraMatrix[7] = 0.0f;   glCameraMatrix[11] = -1;    glCameraMatrix[15] = 0.0f;

float* glProjectionMatrix = algMult( glOrthoMatrix, glCameraMatrix );

模型视图矩阵设置为:

proj_loc = new Vec3f(   proj_RT[12], proj_RT[13], proj_RT[14] );    
proj_fwd = new Vec3f(   proj_RT[8],  proj_RT[9],  proj_RT[10] );
proj_up  = new Vec3f(   proj_RT[4],  proj_RT[5],  proj_RT[6]  );
proj_trg = new Vec3f(   proj_RT[12] + proj_RT[8], 
                        proj_RT[13] + proj_RT[9], 
                        proj_RT[14] + proj_RT[10] );

gluLookAt( proj_loc[0], proj_loc[1], proj_loc[2],
           proj_trg[0], proj_trg[1], proj_trg[2],
           proj_up[0],  proj_up[1],  proj_up[2] );

最后,相机显示并移动:

glPushMatrix();
glTranslatef(translateX, translateY, translateZ); 
drawRGBCamera();
glPopMatrix();

其中翻译值是用键盘手动调整的,直到我有一个视觉匹配(我在校准板上投射 Kinect-rgb 相机看到的东西,所以我手动调整 opengl-camera 直到投射的图案与打印的图案匹配)。

我的问题是为什么我必须进行手动调整?模型视图和投影设置应该处理它。

如果在切换这样的驱动程序时出现任何问题,我也会徘徊,因为 OpenKinect 用于校准,OpenNI 用于验证。这是在研究另一种流行的校准工具 RGBDemo 时想到的,它说如果使用 LibFreenect 后端,则需要进行 Kinect 校准。

那么,如果使用驱动程序进行校准并使用另一个驱动程序显示,校准会出错吗?

有没有人认为使用 OpenCV 而不是 OpenGL 会更容易取得成功?

JavaCV 参考:https
://code.google.com/p/javacv/ Procamcalib《短篇论文》:http:
//www.ok.ctrl.titech.ac.jp/~saudet/research/procamcalib/ Procamcalib 源代码:https://code.google.com/p/javacv/source/browse?repo=procamcalib
RGBDemo校准参考:http ://labs.manctl.com/rgbdemo/index.php/Documentation/Calibration

如果需要,我可以上传更多东西,让我知道你们需要什么来帮助我:)

4

2 回答 2

3

我是您链接到的文章的作者,我想我可以提供帮助。

问题在于您如何设置模型视图矩阵。当您调用 gluLookAt() 时,您使用 proj_RT 的第三列作为相机的位置,但它不是相机的位置,它是相机坐标中世界原点的位置。我为我的新博客写了一篇文章,可能有助于澄清这一点。它描述了解释外在矩阵的三种不同(等效)方法,每种方法都有 WebGL 演示:

http://ksimek.github.io/2012/08/22/extrinsic/

如果您必须使用 gluLookAt,本文将向您展示如何使用,但调用起来要简单得多glLoadMatrix(proj_RT)

tl;博士:替换gluLookAt()glLoadMatrix(proj_RT)

于 2013-05-26T17:13:02.087 回答
0

对于 Kinect 校准,请查看最新 0.7 版本的 RGBDemo http://labs.manctl.com/rgbdemo和相应的Freenect 校准源

从 v0.7.0 变更日志:

自 v0.6.1 以来的新功能:

  • 使用标记获取对象模型的新演示
  • rgbd-multikinect 的简单校准模式
  • 在 rgbd-multikinect 中抓取速度更快
  • 保存到磁盘时添加时间戳和相机序列
  • 与 PCL 1.4 的兼容性 各种错误修复

一本非常好的书是 Jason McKesson 的Learning Modern 3D Graphics Programming你也可以阅读Kinect 的 ROS 页面和 Nicolas 的Kinect 校准页面

于 2013-03-26T14:39:18.930 回答