如何提高单应性准确性? [英] how to improve the homography accuracy?

查看:228
本文介绍了如何提高单应性准确性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用OpenCV的 cv :: findHomography API来计算两个平面图像的单应性矩阵。
匹配的关键点由SIFT提取并由BFMatcher匹配。我知道, cv:findHomography 使用RANSAC迭代找出最好的四个对应点,得到单应性矩阵。
因此,我使用对象边缘的同值矩阵绘制所选的四对点与计算的轮廓。
结果如链接:



http://postimg.org/image/5igwvfrx9/



我们可以看到,RANSAC选择的匹配点是正确的,但轮廓显示



但这些测试表明,所选的匹配点和单应性都是正确的:



http://postimg.org/image/dvjnvtm53/



我的猜测是,如果选择的匹配点太近,像素位置的小误差将导致单应性矩阵的显着误差。如果四个点在图像的角落中,则匹配点移动4-6个像素仍然具有良好的单应矩阵。
(根据均匀坐标,我认为这是合理的,因为近平面中的小误差将在远处放大)



我的问题是:



1.我的猜测是对的吗?
2.由于通过RANSAC迭代生成四个匹配点,所有关键点的总体误差最小。但是如何获得稳定的单应性,至少使轮廓的映射是正确的?理论证明,如果找到平面中的四个对应点,应该计算单应性矩阵,但是在工程师工作中有什么招数吗?



谢谢。

解决方案

我认为你是对的,而且 4分的接近度精度的结果。你观察到的可能是数值问题:结果可能局部正确这4个点,但进一步变得更糟。



但是,RANSAC在这里不会帮助你。原因很简单:RANSAC是一个鲁棒的估计程序,旨在找出许多对应中的最佳点对(包括一些错误的对)。然后,在RANSAC的内循环中,执行标准单应性估计。



您可以看到 RANSAC


你真正需要的是有更多的积分。在你的例子中,你只使用4点对应,这足以估计单应性。
您将通过在目标图片上提供更多匹配来提高搜索结果。然后问题变得过度确定,但是OpenCV仍然可以找到最小二乘解。此外,在点对应过程或一些点本地化中有一些错误,RANSAC将能够选择最好的,并仍然给你一个可靠的结果。



如果RANSAC导致过度拟合约4点(如你的示例中的情况),请尝试通过增加 ransacReprojThreshold 参数来放宽约束。
或者,您可以:




  • 使用不同的估算器(强健中值 CV_LMEDS 是一个不错的选择,如果有很少的匹配错误)

  • 或使用RANSAC在第一步与大的重投影错误(得到一个粗略估计)为了检测然后在正确的匹配上使用LMEDS。


I used OpenCV's cv::findHomography API to caculate the homography matrix of two planar images. The matched key points are extracted by SIFT and matched by BFMatcher. As I know, cv:findHomography use RANSAC iteration to find out the best four corresponding points to get the homography matrix. So I draw the selected four pairs of points with the calculated contour using homograhy matrix of the edge of the object. The result are as the links:

http://postimg.org/image/5igwvfrx9/

As we can see, the selected matched points by RANSAC are correct, but the contour shows that the homography is not accurate.

But these test shows that, both the selected matched points and the homography are correct:

http://postimg.org/image/dvjnvtm53/

My guess is that if the selected matched points are too close, the small error of the pixel position will lead to the significant error of the homography matrix. If the four points are in the corner of the image, then the shift of the matched points by 4-6 pixels still got good homography matrix. (According the homogenous coordinate, I think it is reasonable, as the small error in the near plane will be amplified in the far away)

My question is:

1.Is my guess right? 2.Since the four matched points are generated by the RANSAC iteration, the overall error of all the keypoints are minimal. But How to get the stable homography, at least making the contour's mapping is correct? The theory proved that if the four corresponding points in a plane are found, the homography matrix should be calculated, but is there any trick in the engineer work?

Thank you.

解决方案

I think you're right, and the proximity of the 4 points does not help the accuracy of the result. What you observe is maybe induced by numerical issues: the result may be locally correct for these 4 points but becomes worse when going further.

However, RANSAC will not help you here. The reason is simple: RANSAC is a robust estimation procedure that was designed to find the best point pairs among many correspondences (including some wrong ones). Then, in the inner loop of the RANSAC, a standard homography estimation is performed.

You can see RANSAC as a way to reject wrong point correspondences that would provoke a bad result.

Back to your problem:

What you really need is to have more points. In your examples, you use only 4 point correspondences, which is just enough to estimate an homography. You will improve your result by providing more matches all over the target image. The problem then becomes over-determined, but a least squares solution can still be found by OpenCV. Furthermore, of there is some error either in the point correspondence process or in some point localization, RANSAC will be able to select the best ones and still give you a reliable result.

If RANSAC results in overfitting on some 4 points (as it seems to be the case in your example), try to relax the constraint by increasing the ransacReprojThreshold parameter. Alternatively, you can either:

  • use a different estimator (the robust median CV_LMEDS is a good choice if there are few matching errors)
  • or use RANSAC in a first step with a large reprojection error (to get a rough estimate) in order to detect the spurious matchings then use LMEDS on the correct ones.

这篇关于如何提高单应性准确性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆