使用RANSAC时,如何获得更多的嵌入器


matches = sorted(matches, key = lambda x: x.distance)
src_pts = np.float32([ kp1[m.queryIdx].pt for m in matches ]).reshape(-1,1,2)
dst_pts = np.float32([ kp2[m.trainIdx].pt for m in matches ]).reshape(-1,1,2)
M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC,5.0)
matchesMask = mask.ravel().tolist()

我正在使用MatchesMask中的值作为插入物,事实证明这太严重地受到Ransac的影响,我试图从比赛中获得前100个最佳匹配项,但百分比的异常值仍然太高。

cv2.findHomography如果源点和目的地投影之间的距离比ransacReprojThreshold(5.0-在您的代码中(将点对视为inlief

norm(src_pts[i] - M * dst_pts[i]) > ransacReprojThreshold

lansacreprojthreshold-最大允许的再投影错误将点对视为inlier。

所以,如果您想找到100个"最佳"匹配,即使重新投影错误超过5.0:

  1. 创建对成对的数组:(点对和再投影错误(,
  2. 通过再投影错误排序,
  3. 以最小的再投影错误取100点。

最新更新