确定变换矩阵
作为我之前关于确定相机参数的问题的后续内容,我制定了一个新问题。
我有两张相同矩形的图片:
第一张是没有任何变换的图像,并按原样显示矩形。
第二张图显示了应用一些 3D 变换(XYZ 旋转、缩放、XY 平移)后的矩形。 这导致矩形看起来是梯形。
我希望下图描述了我的问题:
alt text http:// /wilco.menge.nl/application.data/cms/upload/transformation%20matrix.png
如何确定哪些转换(更具体地说:哪些转换矩阵)导致了此转换?
我知道两个图像中角点的像素位置,因此我也知道角点之间的距离。
As a followup to my previous question about determining camera parameters I have formulated a new problem.
I have two pictures of the same rectangle:
The first is an image without any transformations and shows the rectangle as it is.
The second image shows the rectangle after some 3d transformation (XYZ-rotation, scaling, XY-translation) is applied. This has caused the rectangle to look a trapezoid.
I hope the following picture describes my problem:
alt text http://wilco.menge.nl/application.data/cms/upload/transformation%20matrix.png
How do determine what transformations (more specifically: what transformation matrix) have caused this tranformation?
I know the pixel locations of the corners in both images, hence i also know the distances between the corners.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我很困惑。 这是 2d 问题还是 3d 问题?
按照我的理解,你有一个嵌入 3D 空间的平面矩形,你正在看它的两张 2D“图片”——一张是原始版本,一张是基于转换后的版本。 它是否正确?
如果这是正确的,则没有足够的信息来解决问题。 例如,假设两张图片看起来完全相同。 这可能是因为平移是恒等式,也可能是因为平移使矩形距离相机的距离增加了一倍,并且其大小增加了一倍(从而使其看起来完全相同)。
I'm confused. Is this a 2d or a 3d problem?
The way I understand it, you have a flat rectangle embedded in 3d space, and you're looking at two 2d "pictures" of it - one of the original version and one based on the transformed version. Is this correct?
If this is correct, then there is not enough information to solve the problem. For example, suppose the two pictures look exactly the same. This could be because the translation is the identity, or it could be because the translation moves the rectangle twice as far away from the camera and doubles its size (thus making it look exactly the same).
这是一个数学问题,而不是编程..
你需要定义一组方程(你的变换矩阵,我猜是3个方程),然后求解角点的4个变换。
我只用德语单词描述过这一点......所以上面的内容听起来很奇怪......
This is a math problem, not programming ..
you need to define a set of equations (your transformation matrix, my guess is 3 equations) and then solve it for the 4 transformations of the corner-points.
I've only ever described this using German words ... so the above will sound strange ..
根据您掌握的信息,这并不容易。 不过,我会给你一些想法。 如果您有角点的 3D 坐标,您会更轻松。 这是基本想法。
如果没有 z 坐标,您可以看到这会很困难,但这是一般过程。 我希望这有帮助。
Based on the information you have, this is not that easy. I will give you some ideas to play with, however. If you had the 3D coordinates of the corners, you'd have an easier time. Here's the basic idea.
Without the z coordinates, you can see that this will be difficult, but this is the general process. I hope this helps.
正如 Alex319 指出的那样,解决方案不会是唯一的。
如果第二张图片确实像你所说的那样是梯形,那么这不会太难。 由于透视它是一个梯形(不是平行四边形),所以它一定是一个等腰梯形。
画出两条对角线。 它们在矩形的中心相交,这样就可以进行平移。
旋转梯形,直到其平行边与原矩形的两条边平行。 (哪两条?没关系。)
穿过中心画第三条平行线。 将其缩放到您选择的矩形的边。
现在旋转出平面。 测量从中心到平行边之一的距离并使用正弦定律。
如果不是梯形,只是四边形,那就更难了,你必须使用对角线之间的角度来找到旋转轴。
The solution will not be unique, as Alex319 points out.
If the second image is really a trapezoid as you say, then this won't be too hard. It is a trapezoid (not a parallelogram) because of perspective, so it must be an isosceles trapezoid.
Draw the two diagonals. They intersect at the center of the rectangle, so that takes care of the translation.
Rotate the trapezoid until its parallel sides are parallel to two sides of the original rectangle. (Which two? It doesn't matter.)
Draw a third parallel through the center. Scale this to the sides of the rectangle you chose.
Now for the rotation out of the plane. Measure the distance from the center to one of the parallel sides and use the law of sines.
If it's not a trapezoid, just a quadralateral, then it'll be harder, you'll have to use the angles between the diagonals to find the axis of rotation.