将 2D 点映射到新视角
这是我的第一篇文章!
我正在尝试制作一个应用程序,可以确定网格(图像)中的某些点是亮还是暗。原始网格定义良好(我知道所有点应该相对于角点)。一旦我知道了这个点应该在哪里,我就可以很容易地判断它是亮还是暗。
问题是,我想通过手持相机拍摄的网格图像来完成此操作。显然,由于手部移动,视角会发生变化,我需要做一些数学计算来找出新点相对于角点的位置(我知道如何检测角点)。
我在其他帖子中读到,在转换过程中保留的唯一属性是交叉比和发生率。具体来说,这篇文章让我找到了正确的方向,但作者没有完成数学计算。请注意,在这个例子中,作者将从倾斜视角转向鸟瞰图,而我试图做相反的事情。不过,数学应该是相同的。
从发布投影变换
(显然我无法发布图像,因为我是新人,但图像已打开上面的帖子)
1)找到线段AD和CP定义的线的交点处的点C'。
2)找到线段AD和BP定义的线的交点处的点B'。
3)确定B'DAC'的交叉比,即r = (BA' * DC') / (DA * B'C')。
4)构造投影线F'HEG'。这些点的交比等于r,即r = (F'E * HG') / (HE * F'G')。
5)F'F 和 G'G 将在投影点 Q 处相交,因此使交比相等并知道正方形边长,您可以通过一些算术体操确定 Q 的位置。
我的问题是第 4 步,构建 F'HEG' 线。只知道 2 个点和所需的交叉比是否可以构建 4 个点的线?我觉得这是 1 个方程和 2 个未知数。
如果有人可以帮助我,我将非常感激!
抱歉,时间太长了,
罗布
PS,我本来会在该论坛上发布的,但这是我的第一篇文章,所以我还没有获得许可。
This is my first post!
I'm trying to make an application that can determine whether certain points in a grid (image) are light or dark. The original grid is well defined (I know where all the points should be relative to the corners). Once I know where the point is supposed to be, I can easily tell whether it is light or dark.
The problem is, I'd like to do this from an image of the grid taken from a hand-held camera. Clearly, due to hand movement, the perspective will change, and I'll need to do some math to figure out the location of the new points relative to the corners (I know how to detect the corners).
I've read in other postings that the only properties that are preserved during a transformation are the cross-ratio and incidence. Specifically, this posting put me in the right direction, but the author didn't finish the math. Note that in this example, the author is going from the skewed perspective to the birdseye view, and I'm trying to do the opposite. The math should be the same, though.
From the posting Projective transformation
(So apparently I can't post images because I'm new but the image is on the above post)
1)Find the point C' at the intersection of the lines defined by the segments AD and CP.
2)Find the point B' at the intersection of the lines defined by the segments AD and BP.
3)Determine the cross-ratio of B'DAC', i.e. r = (BA' * DC') / (DA * B'C').
4)Construct the projected line F'HEG'. The cross-ratio of these points is equal to r, i.e. r = (F'E * HG') / (HE * F'G').
5)F'F and G'G will intersect at the projected point Q so equating the cross-ratios and knowing the length of the side of the square you can determine the position of Q with some arithmetic gymnastics.
My question is step 4, Constructing the line F'HEG'. Is it possible to construct a line of 4 points just knowing 2 points and the desired cross ratio? I feel like that's 1 equation with 2 unknowns.
If someone could help me I will be very grateful!
Sorry that was so long,
Rob
PS I would have just posted on that forum but this is my first post so I don't have permission yet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您知道任何 4 个 2D 点(其中没有 3 个位于同一条线上)的位置,例如您的角点,您可以找到 2D 图像和网络摄像头框架之间的单应变换 H。
H 是一个 3x3 矩阵,可以将帧中的任何点转换为 2D 图像。
点 p 以齐次坐标表示:[x,y,1],使得 p'=Hp。
给定图像和帧中的 4 个对应点,您可以求解 H 的 9 个元素。
If you know the positions of any 4 2D point (no 3 of which lie on the same line), e.g. your corners, you can find the Homography transformation H between your 2D image and the webcam frame.
H is a 3x3 matrix that can convert any point in your frame to the 2D image.
The points p are written in homogenious coordinates: [x,y,1] such that p'=Hp.
Given 4 corresponding points in the image and the frame you can solve for the 9 elements of H.
由于 F'、H、E 和 G 位于 2D 空间中的一条线上,因此您的问题从一开始就受到很大限制。您拥有的未知数是:
为此请使用第一点。
所需的交叉比实际上是两个方程(x 坐标和 y 坐标各一个),因此您有两个方程和两个未知数。
Since F', H, E and G lie on a line in 2D space your problem is very constrained from the start. The unknowns you have are:
use the first point for this.
The desired cross ration is actually two equations (one each for the x- and y-coordinate) so you have two equations and two unknowns.