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

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

问题描述

我有3点在3D空间中的我知道确切的位置。假设他们是:(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.

什么是找到投影矩阵,将项目的三维点插入相机视图平面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)).

...

其实,这是过度简化,假设相机对准你的三维坐标系的原点,也没有角度。

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对多的2-D观点缩放,因为我们将能够消除中心坐标( 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分和改变你的2-D观点是相对于显示器的中心,那么你可以得到14联立方程组在13个变量和解决的问题。

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天全站免登陆