更新时间:2023-11-15 12:35:28
认为这个问题会产生一套可能的解决方案,至少在2D中它是。对于2D情况:
|
----------- + -----------
/ | \
/ | \
/ | \
/ --- + --- \VP
/ | \
/ | \
/ | \
/ | \
/ | - \
/ | | \
/ | | \
在上图中,垂直线段和水平线段将投影到视图平面(VP)。如果你把它缩放,你会看到有两条光线从眼睛通过未投影线的每个终点。这条线可以在许多位置和旋转 - 想象一根棍子到锥体,它可以卡在任何数量的位置。
因此,在2D空间
这个算法是否适用于3D?
编辑:如果你知道到对象的距离会变得无足轻重。
编辑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) 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.
The Question is the following :
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:
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.