5

我目前正在完成我的兴趣点检测器评估工具。在最后的步骤中,我发现了一个令人困惑的错误。

Mat findHomography(InputArray srcPoints, InputArray dstPoints, int method=0, double ransacReprojThreshold=3, OutputArray mask=noArray() )

srcPointsdstPoints是存储匹配关键点的vector<Points2f>对应点。到目前为止没有什么特别的 - 就像在教程中一样。

但是当我使用 RANSAC 并且vector<Points2f>在 [0, ... , 4] 范围内时,我得到一个断言错误,而不是计数器应该大于或等于四。

问题1:算法是否需要至少四个点来描述什么属于当前模型并创建共识?

问题 2:是否有关于此的任何文档?(我看了看文档教程。)

请注意,我已经看过这个问题。但对于 RANSAC 的行为,并没有令人满意的答案。还是我应该接受这种方法至少需要四个点才能找到单应性?

谢谢你的帮助。

4

2 回答 2

10

A homography cannot be computed with less than 4 pairs of points. That is because with only 3 points there is a perspective ambiguity. Picture a triangle

a


b        c

in image 1. In image 2 the points have been transformed to look like this

a


b    c

The distance between b and c has been cut in half. Unfortunately you don't know if that is because point c got closer to your or farther from you. With a 4th point the difference becomes clear.

a        d


b        c

Here is a square in image 1

     d


a        


b    c    

here d and c rotated towards you

a     

     d
b    c   

and here they rotated away from you.

I don't see this requirement in the openCV documentation but if you find any resources on homography calculation you won't have to read very far before you find this requirement and a more rigorous proof of 4 points being sufficient.

于 2013-01-21T00:38:28.863 回答
4

srcPoints.size() >= 4RANSAC 用于在更大的集合或对应关系中(即当)选择 4 对匹配点。这就是为什么如果srcPoints.size() <=4.

您至少需要 4 个对应关系,因为单应矩阵H有 8 个自由度,因此需要 8 个线性方程才能找到解。由于每对点都会生成两个线性方程(使用 x 和 y 坐标),因此您总共需要至少 4 个对应关系。

于 2013-01-21T08:56:01.830 回答