计算将矩形转换为其透视图形式所需的转换 [英] Calculate transformation which is needed to transform a rectangle into its perspective form
问题描述
我有一个相同的矩形,处于未变换形式和透视图形式. 来自未变换形式的坐标和来自透视图形式的坐标都在未变换的坐标系中.
I have the same rectangle in an untransformed form and in a perspective form. Both, the coordinates from the untransformed form as well as from the perspective form are in the untransformed coordinate system.
是否有一种方法可以重建导致该变换的变换矩阵?
Is there a way to reconstruct the transformation matrix which leads to this transformation?
我认为应该可以通过求解四个角所给出的四个方程来做到这一点,但我不确定从哪里开始.
I think it should be possible to do that by solving the 4 equations given by the 4 corners but I am not sure where to start.
// 看来我在这里是xy问题的受害者.所有答案均基于3d环境.但是我在图像上有一个矩形+我知道这个矩形的实际尺寸.我需要知道的是如何将其他已知点转换为透视图图像
// It looks like I am victim of a xy problem here. All answers are based in a 3d environment. But I have a rectangle on an image + I know the real dimensions of this rectangle. What I need to know is how to transform other known points onto the perspective image
推荐答案
请注意,您有8对对应的参数(每个点分别为x和y),并且需要使用8个方程式来计算矩阵的8个参数
Note that you have 8 pairs of corresponding parameters (x and y for every point), and need to calculate 8 parameters of matrix using 8 equations
//four pairs of such equaions:
x' = (A * x + B * y + C) / (G * x + H * y + 1.0)
y' = (D * x + E * y + F) / (G * x + H * y + 1.0)
Theory of finding perspective transformation matrix is described in Paul Heckbert article.
C ++实现可在 antigrain库(文件agg_trans_perspective.h
)中找到
C++ implementation could be found in antigrain library (file agg_trans_perspective.h
)
这篇关于计算将矩形转换为其透视图形式所需的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!