如何提高单应性精度? [英] How to improve the homography accuracy?

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

问题描述

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

I used OpenCV's cv::findHomography API to calculate 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:

https://postimg.cc/image/5igwvfrx9/

我们可以看到,RANSAC选择的匹配点是正确的,但是轮廓显示单应性不准确.

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:

https://postimg.cc/image/dvjnvtm53/

我的猜测是,如果选择的匹配点太接近,像素位置的小误差会导致单应矩阵的显着误差.如果这四个点在图像的角落,那么匹配的点移动4-6个像素仍然得到很好的单应矩阵.(根据齐次坐标,我觉得是合理的,近平面的小误差会在远处放大)

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)

我的问题是:

1.我猜对了吗?2.由于四个匹配点是由RANSAC迭代产生的,所有关键点的整体误差最小.但是如何获得稳定的单应性,至少使轮廓的映射是正确的?理论证明,如果找到一个平面内的四个对应点,就应该计算出单应矩阵,但是工程师工作有什么窍门吗?

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?

推荐答案

我觉得你是对的,4个点的接近度无助于结果的准确性.您观察到的结果可能是由数值问题引起的:对于这 4 个点,结果可能局部正确,但越深入则越差.

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.

但是,RANSAC 不会在这里为您提供帮助.原因很简单:RANSAC 是一种稳健的估计程序,旨在在许多对应关系(包括一些错误的对应关系)中找到最佳点对.然后,在RANSAC的内循环中,进行标准的单应性估计.

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.

您可以将 RANSAC 视为一种拒绝错误点对应的方法,这会导致不好的结果.

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

回到你的问题:

您真正需要的是获得更多积分.在您的示例中,您仅使用 4 点对应关系,这足以估计单应性.您将通过在整个目标图像中提供更多匹配来改善您的结果.然后问题变得过度确定,但 OpenCV 仍然可以找到最小二乘解决方案.此外,在点对应过程或某些点定位中存在一些错误时,RANSAC 将能够选择最好的,并且仍然可以为您提供可靠的结果.

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.

如果 RANSAC 导致某些 4 个点的过度拟合(在您的示例中似乎就是这种情况),请尝试通过增加 ransacReprojThreshold 参数来放松约束.或者,您可以:

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:

  • 使用不同的估计器(如果匹配错误很少,稳健的中位数 CV_LMEDS 是一个不错的选择)
  • 或在第一步使用具有较大重投影误差(以获得粗略估计)的 RANSAC 以检测虚假匹配,然后在正确匹配上使用 LMEDS.

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

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