【发布时间】: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)**
【问题讨论】: