OpenCV:用于查找单应性的 RANSAC 置信度参数
OpenCV 函数 findhomography()
查找两个图像的匹配点之间的单应变换。 (参见定义)
为了查找点的匹配子集,可以使用RANSAC 。
这里有一个要点:与 OpenCV 中使用 RANSAC 的其他函数相比(例如 findfundamentalMat
)(参见 定义)) RANSAC 参数信心 无法改变。只有重投影阈值可以作为参数传递。
我查看了 OpenCV 源代码,对于 findhomography()
,置信度被硬编码为 0.995。
出于我的目的,我需要增加这个。有没有办法在不改变 OpenCV 源本身的值的情况下做到这一点?
是否有理由对此进行硬编码?
PS:我在 Ticket 1557 下添加了一个更改请求以进行下一个颠覆。
The OpenCV function findhomography()
finds a homographic transformation between matching points of two images. (See Definition)
For finding matching subsets of points RANSAC can be used.
Here's the catch: In contrast to other function in OpenCV which use RANSAC (e.g. findfundamentalMat
(See Definition)) the RANSAC parameter for confidence cannot be changed. Only the reprojection threshold can be passed as an argument.
I looked in the OpenCV source, and for findhomography()
the confidence is hardcoded to 0.995.
For my purposes I need to increase this. Is there a way to do this without changing the value in the OpenCV source itself?
Is there a reason why this should be hardcoded?
PS: I added a change request under Ticket 1557 for the next subversion.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
之所以要硬编码,是因为对于大多数用户来说,这是一个非常好的选择。
也许你是第一个感到需要更多东西的人。但这就是 OpenCV 开放的原因 - 获取代码、修改它、制作补丁并向 OpenCV 开发团队提出 - 无论你喜欢什么。
而且,您确定这是您需要的吗?通常,更严格的 reproj 阈值就可以解决问题。如果您遇到问题,它们可能在其他地方 - 一些选择错误的点,点匹配的拟合误差太大等。
The reason to be hardcoded is that for the majority of users, this is a very good choice.
Maybe you were the first to feel the need for something more. But this is why OpenCV is open - take the code, modify it, make a patch and propose it to OpenCV dev team - whatever you like.
And, are you sure this is what you need? Usually, a tighter reproj threshold will do the trick. If you have problems, they may be somewhere else - some badly chosen points, a too big fit error on point matching, etc.
好吧,您并不是第一个需要更改 OpenCV 中的硬编码变量或函数的人。实际上,我们正在改变很多 OpenCV 功能,以使它们在手机上更快、更高效。
创建具有不同名称的类的副本
如果您想更改 RANSAC,只需在代码中 ,然后根据需要自行修改即可。您还可以更改 RANSAC 的最大迭代次数,默认值非常高,并且会使应用程序非常慢。
Well, you are not the first that needs to change harcoded variables or functions in OpenCV. Actually we are changing a lot of OpenCV functions in order to make them faster and more efficient for mobile phones.
If you want to change RANSAC, just create a copy of the class with a different name
in your code, and modify it yourself as you need. You can also change the maxnumber of iterations for RANSAC, the default is very high and makes application really slow.