视场+宽高比+投影矩阵的视图矩阵(HMD OST校准) [英] Field of view + Aspect Ratio + View Matrix from Projection Matrix (HMD OST Calibration)

查看:310
本文介绍了视场+宽高比+投影矩阵的视图矩阵(HMD OST校准)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发增强现实应用程序.目标设备是光学透明HMD,我需要校准其显示器以实现虚拟对象的正确配准. 我使用了 SPAAM的实现来实现此目的,结果对于我的目的来说足够精确.

I'm currently working on an Augmented reality application. The targetted device being an Optical See-though HMD I need to calibrate its display to achieve a correct registration of virtual objects. I used that implementation of SPAAM for android to do it and the result are precise enough for my purpose.

我的问题是,校准应用程序会在输出中给出一个 4x4 投影矩阵,例如,我可以直接将其与OpenGL一起使用.但是,我使用的增强现实框架仅接受以下格式的光学校准参数: 视场一些参数+ 纵横比一些参数+ 4x4 View 矩阵.

My problem is, calibration application give in output a 4x4 projection matrix I could have directly use with OpenGL for exemple. But, the Augmented Reality framework I use only accept optical calibration parameters under the format Field of View some parameter + Aspect Ratio some parameter + 4x4 View matrix.

这就是我所拥有的:

以错误的格式校正校准结果:

 6.191399, 0.114267, -0.142429, -0.142144
-0.100027, 11.791289, 0.05604,   0.055928
 0.217304,-0.486923, -0.990243, -0.988265
 0.728104, 0.005347, -0.197072,  0.003122

您可以查看生成此结果的代码

You can take a look at the code that generate this result here.

我了解的是单点主动对准方法产生3x4矩阵,然后程序将此矩阵乘以正交投影矩阵以得到上述结果.这是用于产生正交矩阵的参数:

What I understand is the Single Point Active Alignment Method produce a 3x4 matrix, then the program multiply this matrice by an orthogonal projection matrix to get the result above. Here are the param used to produce the orthogonal matrix :

near : 0.1, far : 100.0, right : 960, left : 0, top :  540, bottom:  0

正确格式的错误校准结果:

Param 1 : 12.465418
Param 2 : 1.535465

 0.995903,   -0.046072,   0.077501,  0.000000   
 0.050040,    0.994671,  -0.047959,  0.000000
-0.075318,    0.051640,   0.992901,  0.000000
 114.639359, -14.115030, -24.993097, 1.000000

我没有任何有关如何获得这些结果的信息.

I don't have any information on how these result are obtained.

我从二进制文件中读取了这些参数,并且我不知道矩阵是以行还是列的主要形式存储的.因此,可能必须对这两个矩阵进行转置.

I read these parameters from binary files, and I don't know if matrices are stored in row or column major form. So the two matrices may have to be transposed.

我的问题是:有可能吗?如果可以,如何从 projections 我拥有的第一个矩阵中获得这三个参数?

My question is : Is it possible, and if yes, how to get these three parameters from the projection first matrix I have ?

推荐答案

有可能吗?如果可以,如何从我拥有的投影矩阵中获得这三个参数?

Is it possible, and if yes, how to get these three parameters from the projection matrix I have ?

投影矩阵和视图矩阵描述了完全不同的变换.投影矩阵描述了从场景的3D点到视口的2D点的映射,而视图矩阵描述了从中查看场景的方向和位置.视图矩阵由摄像机的位置,方向以及摄像机的目标和摄像机的向上矢量定义.
(请参阅

The projection matrix and the view matrix describe completely different transformations. While the projection matrix describes the mapping from 3D points of a scene, to 2D points of the viewport, the view matrix describes the direction and position from which the scene is looked at. The view matrix is defined by the camera position and the direction too the target of view and the up vector of the camera.
(see Transform the modelMatrix)

这意味着无法从投影矩阵中获取视图矩阵.但是相机定义了一个视图矩阵.

This means it is not possible to get the view matrix from the projection matrix. But the camera defines a view matrix.


如果投影是透视的,则可以从投影矩阵中获取视角和纵横比.


If the projection is perspective, then it will be possible to get the field of view angle and the aspect ratio from the projection matrix.

透视投影矩阵如下:

r = right, l = left, b = bottom, t = top, n = near, f = far

2*n/(r-l)      0              0               0
0              2*n/(t-b)      0               0
(r+l)/(r-l)    (t+b)/(t-b)    -(f+n)/(f-n)   -1    
0              0              -2*f*n/(f-n)    0

它遵循:

aspect = w / h
tanFov = tan( fov_y * 0.5 );

p[0][0] = 2*n/(r-l) = 1.0 / (tanFov * aspect)
p[1][1] = 2*n/(t-b) = 1.0 / tanFov

沿Y轴的视场角,以度为单位:

The field of view angle along the Y-axis in degrees:

fov = 2.0*atan( 1.0/prjMatrix[1][1] ) * 180.0 / PI;

宽高比:

aspect = prjMatrix[1][1] / prjMatrix[0][0];


进一步了解以下问题的答案:


See further the answers to the following question:

  • How to render depth linearly in modern OpenGL with gl_FragCoord.z in fragment shader?
  • How to recover view space position given view space depth value and ndc xy
  • Transform the modelMatrix

这篇关于视场+宽高比+投影矩阵的视图矩阵(HMD OST校准)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆