【问题标题】:How can count outlier and inlier points after applying RANSAC?应用 RANSAC 后如何计算异常点和内点?
【发布时间】:2021-04-23 21:49:07
【问题描述】:

我浏览了下面的代码,想知道在使用 RANSAC 后如何计算异常点和异常点?你能指出一个好的代码是如何完成的吗?

第二个问题,哪种特征匹配算法更好: BFMatcher.knnMatch() 与测试比率或 bf = cv.BFMatcher(cv.NORM_HAMMING, crossCheck=True) 与最短距离?这个比较有什么参考吗?

    **# BFMatcher with default params
      bf = cv.BFMatcher()
      matches = bf.knnMatch(des1, des2, k=2)

     # Apply ratio test
     good_matches = []
     for m,n in matches:
         if m.distance < 0.75*n.distance:
           good_matches.append([m])
        
       # Draw matches
   img3=cv.drawMatchesKnn(img1,kp1,img2,kp2,good_matches,None,flags=cv.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS)
     cv.imwrite('matches.jpg', img3)
     # Select good matched keypoints
     ref_matched_kpts = np.float32([kp1[m[0].queryIdx].pt for m in good_matches])
     sensed_matched_kpts = np.float32([kp2[m[0].trainIdx].pt for m in good_matches])

     # Compute homography
     H, status = cv.findHomography(sensed_matched_kpts, ref_matched_kpts, cv.RANSAC,5.0)**

【问题讨论】:

    标签: opencv matching ransac


    【解决方案1】:

    统计异常值和内部值的数量

    # number of detected outliers: len(status) - np.sum(status)
    # number of detected inliers: np.sum(status)
    # Inlier Ratio, number of inlier/number of matches: float(np.sum(status)) / float(len(status))
    

    特征匹配算法

    我想说,如果您使用基于稀疏特征的算法(SIFT 或 SURF),BFMatcher.knnMatch() with Test ratio 是首选。而bf = cv.BFMatcher(cv.NORM_HAMMING, crossCheck=True) 用于基于二进制的算法(ORB、FAST 等)。我的建议是在您的项目中尝试这两种算法,以研究哪一种更好。 Good Reference

    【讨论】:

      猜你喜欢
      • 2018-04-09
      • 2015-10-13
      • 1970-01-01
      • 1970-01-01
      • 2019-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多