过得去RANSAC使用的5点findHomography(OpenCV进行Android版) [英] Getting the 5 points used by RANSAC in findHomography (OpenCV for Android)
问题描述
在OpenCV的针对Android,功能org.opencv.Calib3d.findHomography(..)返回齐次变换矩阵。例如,这只会返回对应性:
In OpenCV for Android, the function org.opencv.Calib3d.findHomography(..) returns the homogeneous transformation matrix. For example, this only returns the homography:
Mat homography = Calib3d.findHomography(points1, points2, Calib3d.RANSAC, 0.5);
有没有一种方法,以返回RANSAC实际上从Android OpenCV的API使用点?
Is there a way to return the points that RANSAC actually uses from the Android OpenCV API?
推荐答案
更新
我不知道它是否是一个新增加的OpenCV还是我刚刚错过了它,但<一个href=\"http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html?highlight=findhomography#Mat%20findHomography%28InputArray%20srcPoints,%20InputArray%20dstPoints,%20int%20method,%20double%20ransacReprojThreshold,%20OutputArray%20mask%29\"相对=nofollow> findHomography()函数实际上可以给你围层(OpenCV的2.4.2)。最后一个参数,屏蔽
,默认情况下是空的,将填充在由RANSAC foound内围层的那些指标(或255)。
I am not sure whether it's a new addition to OpenCV or I've just missed it, but the findHomography() function actually can give you the inliers (OpenCV 2.4.2). The last parameter, mask
, which is empty by default, will be filled with ones (or 255) at the indexes of the inliers foound by RANSAC.
Mat findHomography(InputArray srcPoints, InputArray dstPoints,
int method=0, double ransacReprojThreshold=3, OutputArray mask=noArray() )
// ^
// |
旧的答案
使用RANSAC估计单对应性(在技术文档称为内围层)的点不能被直接提取。他们内部计算的,但随后的名单被删除。
The points used by RANSAC to estimate the homography (called inliers in technical docs) cannot be extracted directly. They are computed internally, but then the list is deleted.
提取它们的方法是修改findHomography功能(以及相应的RANSAC功能)。但是,这是丑陋的。
A way to extract them is to modify the findHomography function (and the corresponding RANSAC functions). But this is ugly.
另外,清洁的方法是什么测试点对输入比赛日单应:
Another, cleaner way is to test what point pairs in the input match th homography:
使用 projectPoints(points1,单应,points1_dest)
(我希望这是函数名)申请单应于points1。
使用 CV ::距离(points1_dest,points2)
来看看哪些是足够接近他们的points2对。距离应小于或等于 MIN_DISTANCE ^ 2
。在你的情况, 0.5×0.5 = 0.25
。
use the projectPoints(points1, homography, points1_dest)
(i hope this is the function name) to apply homography to points1.
use cv::distance(points1_dest, points2)
to see which of them are close enough to their pair in points2. The distance should be smaller or equal to min_distance^2
. In your case, 0.5*0.5 = 0.25
.
这篇关于过得去RANSAC使用的5点findHomography(OpenCV进行Android版)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!