3d 到 2d 投影矩阵 [英] 3d to 2d Projection Matrix

查看:60
本文介绍了3d 到 2d 投影矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 3D 空间中有 3 个点,我知道其中的确切位置.假设它们是:(x0,y0,z0)(x1,y1,z1)(x2,y2,z2).

I have 3 points in a 3D space of which I know the exact locations. Suppose they are: (x0,y0,z0), (x1,y1,z1) and (x2,y2,z2).

另外,我有一个相机正在观察这 3 个点,我知道这三个点在相机视图平面上的 2D 位置.因此,例如 (x0,y0,z0) 将是 (x0',y0'),而 (x1,y1,z1) 将是 (x1',y1')(x2,y2,z2) 将从相机的角度为 (x2',y2')的观点.

Also I have a camera that is looking at these 3 points and I know the 2D locations of those three points on camera view plane. So for example (x0,y0,z0) will be (x0',y0'), and (x1,y1,z1) will be (x1',y1') and (x2,y2,z2) will be (x2',y2') from the camera's point of view.

找到将这些 3D 点投影到相机视图平面上的 2D 点的投影矩阵的最简单方法是什么.我们对相机位置一无所知.

What is the easiest way to find the projection matrix that will project those 3D points into 2D points on camera view plane. We don't know anything about the camera location.

推荐答案

这给了你两组,每组 3 个变量中的三个方程:

This gives you two sets, each of three equations in 3 variables:

a*x0+b*y0+c*z0 = x0'
a*x1+b*y1+c*z1 = x1'
a*x2+b*y2+c*z2 = x2'

d*x0+e*y0+f*z0 = y0'
d*x1+e*y1+f*z1 = y1'
d*x2+e*y2+f*z2 = y2'

只需使用在您的情况下最简单的解联立方程的方法(手动"解决这些问题甚至并不难).那么你的变换矩阵就是 ((a,b,c)(d,e,f)).

Just use whatever method of solving simultaneous equations is easiest in your situation (it isn't even hard to solve these "by hand"). Then your transformation matrix is just ((a,b,c)(d,e,f)).

...

实际上,这过于简单,并假设相机指向您的 3D 坐标系的原点并且没有透视.

Actually, that is over-simplified and assumes a camera pointed at the origin of your 3D coordinate system and no perspective.

对于透视,变换矩阵更像是:

For perspective, the transformation matrix works more like:

               ( a, b, c, d )   ( xt )
( x, y, z, 1 ) ( e, f, g, h ) = ( yt )
               ( i, j, k, l )   ( zt )

( xv, yv ) = ( xc+s*xt/zt, yc+s*yt/zt ) if md < zt;

但是 4x3 矩阵比 12 个自由度更受约束,因为我们应该有

but the 4x3 matrix is more constrained than 12 degrees of freedom since we should have

a*a+b*b+c*c = e*e+f*f+g*g = i*i+j*j+k*k = 1
a*a+e*e+i*i = b*b+f*f+j*j = c*c+g*g+k*k = 1

所以你可能应该有 4 个点来获得 8 个方程来覆盖相机位置和角度的 6 个变量,还有 1 个用于缩放二维视点,因为我们将能够消除中心"坐标(xc,yc).

So you should probably have 4 points to get 8 equations to cover the 6 variables for camera position and angle and 1 more for scaling of the 2-D view points since we'll be able to eliminate the "center" coordinates (xc,yc).

因此,如果您有 4 个点并将您的二维视点转换为相对于显示器中心的位置,那么您可以获得 13 个变量中的 14 个联立方程并求解.

So if you have 4 points and transform your 2-D view points to be relative to the center of your display, then you can get 14 simultaneous equations in 13 variables and solve.

不幸的是,其中六个方程不是线性方程.幸运的是,这些方程中的所有变量都被限制在 -1 和 1 之间的值,因此求解方程可能仍然可行.

Unfortunately, six of the equations are not linear equations. Fortunately, all of the variables in those equations are restricted to the values between -1 and 1 so it is still probably feasible to solve the equations.

这篇关于3d 到 2d 投影矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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