如何找到投影矩形的3D坐标? [英] How can I find the 3D coordinates of a projected rectangle?

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

问题描述

我有以下主要是算法的问题。




  • 让ABCD是一个已知维度为d1,d2位于空间中的矩形

  • 矩形ABCD投影在平面P上(在一般情况下形成梯形KLMN)。我知道投影矩阵H。

  • 我还可以找到梯形边缘点K,L,M,N的2D坐标。



问题如下:




  • 给出投影矩阵H,边的坐标在梯形上并且知道我们的对象是具有指定几何(矩形d1,d2)的矩形,我们可以计算点A,B,C,D的三维坐标



我使用单个摄像头抓取简单矩形的图像,我想重建空间上的矩形。我可以抓住多个图像,并使用三角测量,但这是不希望的。



投影矩阵本身是不够的,因为射线投射到同一点。事实上,对象具有已知的维度,使我相信问题是可解的,并有有限的解决方案。



如果我想出了如何这个重建可以做我知道如何编程。所以我要求一个算法/数学答案。



欢迎任何想法
感谢

解决方案

认为这个问题会产生一套可能的解决方案,至少在2D中它是。对于2D情况:

  | 
----------- + -----------
/ | \
/ | \
/ | \
/ --- + --- \VP
/ | \
/ | \
/ | \
/ | \
/ | - \
/ | | \
/ | | \

在上图中,垂直线段和水平线段将投影到视图平面(VP)。如果你把它缩放,你会看到有两条光线从眼睛通过未投影线的每个终点。这条线可以在许多位置和旋转 - 想象一根棍子到锥体,它可以卡在任何数量的位置。



因此,在2D空间



这个算法是否适用于3D?




  1. 反转投影矩阵

  2. 计算通过的四条光线

  3. 尝试将矩形拟合到金字塔中。这是棘手的一点,我正在想象的金字塔中的矩形可视化是否可以适应多种方式。

编辑:如果你知道到对象的距离会变得无足轻重。



编辑V2:



,令Rn为世界空间中的四条光线,即通过逆矩阵变换,用m.Rn表示,其中| Rn |是一个。因此,矩形的四个点是:

  P1 = aR1 
P2 = bR2
P3 = cR3
P4 = dR4

其中P1..P4是矩形圆周。从这里,使用向量数学位,我们可以导出四个方程:

  | aR1  -  bR2 | = d1 
| cR3-dR4 | = d1
| aR1-cR3 | = d2
| bR2-dR4 | = d2

其中d1和d2是矩形边的长度,a,b,c和d是未知数。



现在,可能没有解决方案,在这种情况下你需要交换d1和d2。您可以将每行扩展为:



(a.R1x - b.R2x) 2 +(a.R1y - b.R2y)< sup> 2 +(a.R1z-b.R2z) 2 = d1 2



其中R1〜和R2'是光线1和2的x / y / z分量。注意,你正在求解上面的a和b,而不是x,y,z。


I have the following problem which is mainly algorithmic.

  • Let ABCD be a rectangle with known dimensions d1, d2 lying somewhere in space.
  • The rectangle ABCD is projected on a plane P (forming in the general case a trapezium KLMN). I know the projection matrix H.
  • I can also find the 2D coordinates of the trapezium edge points K,L,M,N.

The Question is the following :

  • Given the Projection Matrix H, The coordinates of the edges on the trapezium and the knowledge that our object is a rectangle with specified geometry (dimensions d1, d2), could we calculate the 3D coordinates of the points A, B, C, D ?

I am grabbing images of simple rectangles with a single camera and i want to reconstruct the rectangles on space. I could grab more than one image and use triangulation but this is not desired.

The projection Matrix alone isn't enough since a ray is projected to the same point. The fact that the object has known dimensions, makes me believe that the problem is solvable and there are finite solutions.

If I figure out how this reconstruction can be made I know how to program it. So I am asking for an algorithmic/math answer.

Any ideas are welcome Thanks

解决方案

I think this problem will generate a set of possible solutions, at least in 2D it does. For the 2D case:

           |   
-----------+-----------
          /|\
         / | \
        /  |  \
       /---+---\VP
      /    |    \
     /     |     \
    /      |      \
   /       |       \
  /        |   --   \
 /         |    |    \
/          |    |     \

In the above diagram, the vertical segment and the horizontal segment would project to the same line on the view plane (VP). If you drew this out to scale you'd see that there are two rays from the eye passing through each end point of the unprojected line. This line can be in many positions and rotations - imagine dropping a stick into a cone, it can get stuck in any number of positions.

So, in 2D space there are an infinite number of solutions within a well defined set.

Does this apply to 3D?

The algorithm would be along the lines of:

  1. Invert the projection matrix
  2. Calculate the four rays that pass through the vertices of the rectangle, effectively creating a skewed pyramid
  3. Try and fit your rectangle into the pyramid. This is the tricky bit and I'm trying to mentally visualise rectangles in pyramids to see if they can fit in more than one way.

EDIT: If you knew the distance to the object it would become trivial.

EDIT V2:

OK, let Rn be the four rays in world space, i.e. transformed via the inverse matrix, expressed in terms of m.Rn, where |Rn| is one. The four points of the rectange are therefore:

P1 = aR1
P2 = bR2
P3 = cR3
P4 = dR4

where P1..P4 are the points around the circumference of the rectangle. From this, using a bit of vector maths, we can derive four equations:

|aR1 - bR2| = d1
|cR3 - dR4| = d1
|aR1 - cR3| = d2
|bR2 - dR4| = d2

where d1 and d2 are the lengths of the sides of the rectangle and a, b, c and d are the unknowns.

Now, there may be no solution to the above in which case you'd need to swap d1 with d2. You can expand each line to:

(a.R1x - b.R2x)2 + (a.R1y - b.R2y)2 + (a.R1z - b.R2z)2 = d12

where R1? and R2? are the x/y/z components of rays 1 and 2. Note that you're solving for a and b in the above, not x,y,z.

这篇关于如何找到投影矩形的3D坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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