简体   繁体   English

从3个视点获得3个图像上的三个点如何在3d空间中获取其坐标?

[英]Having three points on 3 images from 3 viewpoints how to get its coordinates in 3d space?

I have 3 viewpoints locations (x,y,z coordinates on 3d grid), directions (relative to viewpoints origin points x,y,z vector) in 3d space. 我在3d空间中有3个视点位置(3d网格上的x,y,z坐标),方向(相对于视点原点x,y,z矢量)。 They all look and each does see exactly three points (markers (x,y) with filtered out background) in space (say we have a red, blue, green dot on white images). 它们都看起来,每个都确实在空间中看到了三个点(标记(x,y)和滤出的背景)(比如我们在白色图像上有一个红色,蓝色,绿色的点)。 We do not know any other viewpoints-camera properties except resolution and that this are same (extremely similar) cameras. 除了分辨率以外,我们不知道任何其他视点 - 相机属性,这是相同(非常相似)的相机。 How could we get our point position in space? 我们怎样才能在太空获得我们的位置?

I assume you have your 3 cameras calibrated, otherwise I do not know if a solution exists to your problem. 我假设您校准了3台摄像机,否则我不知道您的问题是否存在解决方案。

If you have your cameras calibration parameters ie camera matrix (A), rotation vector (T), translation vector (R). 如果您有摄像机校准参数,即摄像机矩阵(A),旋转矢量(T),平移矢量(R)。 From these you can get the projection matrix using P = A[R|T] . 从这些中你可以使用P = A[R|T]得到投影矩阵。 This means that you can project any 3d point in the real world X to image i using X.Pi = x which means you can get a system of linear equations for each view using xi' = xi.P3T - P1T and yi' = yi.P3T - P2T PiT is the transpose of the ith column in P. You can solve this system of equations using singular value decomposition. 这意味着您可以使用X.Pi = x将现实世界X中的任何3d点投影到图像i,这意味着您可以使用xi' = xi.P3T - P1Tyi' = yi.P3T - P2T为每个视图获取线性方程组yi' = yi.P3T - P2T PiT是P中第i列的转置。您可以使用奇异值分解来求解这个方程组。

References: 参考文献:

  1. http://www.robots.ox.ac.uk/~az/tutorials/tutoriala.pdf http://www.robots.ox.ac.uk/~az/tutorials/tutoriala.pdf
  2. https://github.com/opencv/opencv_contrib/blob/master/modules/sfm/src/triangulation.cpp https://github.com/opencv/opencv_contrib/blob/master/modules/sfm/src/triangulation.cpp
  3. http://www.morethantechnical.com/2012/01/04/simple-triangulation-with-opencv-from-harley-zisserman-w-code/ http://www.morethantechnical.com/2012/01/04/simple-triangulation-with-opencv-from-harley-zisserman-w-code/

You need one more piece of information: your camera's field of view: 您还需要一条信息:您的相机的视野:

https://blog.codinghorror.com/content/images/uploads/2007/08/6a0120a85dcdae970b0120a86d9495970b-pi.png https://blog.codinghorror.com/content/images/uploads/2007/08/6a0120a85dcdae970b0120a86d9495970b-pi.png

I'll refer to horizontal field of view as hFOV and vertical field of view as vFOV . 我将水平视野称为hFOV ,垂直视野称为vFOV You only need one of these numbers to solve your problem though, as hFOV/vFOV is equal to the aspect ratio (horizontal resolution / vertical resolution). 您只需要其中一个数字来解决您的问题,因为hFOV/vFOV等于纵横比(水平分辨率/垂直分辨率)。

With that information, you can use the camera's position ( Pc , a 3D vector), direction ( Dc , a 3D vector), resolution ( R , a 2D vector) and the point's position in view space ( Pp , a 2D vector) to build a 3D vector that the point lies upon in space. 使用该信息,您可以使用相机的位置( Pc ,3D矢量),方向( Dc ,3D矢量),分辨率( R ,2D矢量)和点在视图空间中的位置( Pp ,2D矢量)构建一个点在空间中的3D矢量。

If the point lies exactly in the middle of the view ( Pp / R = 0.5 ) then this vector is simply Pc + d * Dc , where d is any positive number, corresponding to the distance from the camera (this will become our variable that we need to solve for. 如果该点恰好位于视图的中间( Pp / R = 0.5 ),则此向量仅为Pc + d * Dc ,其中d为任意正数,对应于距摄像机的距离(这将成为我们的变量,我们需要解决。

The x coordinate of Pp rotates Dc in x from -hFOV/2 to hFOV/2 about the vector perpendicular to both Dc and the x direction of the screen (you can find this with the cross product). x的坐标Pp旋转Dcx-hFOV/2hFOV/2绕垂直于两个矢量Dcx屏幕的方向(你可以找到这与叉积)。 The y coordinate does the same in y. y坐标在y中的作用相同。 We'll call this rotated vector D'c . 我们称之为旋转矢量D'c Rotating a vector by θ about another vector is solved here: Rotating a Vector in 3D Space 在这里解决了关于另一个向量的θ向量旋转:在3D空间中旋转向量

So now we have the relationship: 所以现在我们有了这样的关系:

Position of marker = Pc + d * D'c

Now, d is still an unknown (distance from camera). 现在, d仍然是未知的(距离相机的距离)。 But if we do this for two cameras, we can solve the system of equations and find the absolute position of the marker. 但是如果我们为两个摄像机做这个,我们可以解决方程组并找到标记的绝对位置。 The third camera is useful for verification. 第三台相机可用于验证。

Note: This is more or less the same answer as @osama-alkoky, just the manual version. 注意:这与@ osama-alkoky或者手动版本的答案大致相同。 Learning about projection/transformation matrices is a good idea if you're going to be doing a lot of this. 如果你要做很多这方面的事情,学习投影/变换矩阵是一个好主意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM