我正在Python 3.6.2上的OpenCV中使用ORB在另一幅图像上找到形状的中心坐标(均在此处的附加图像上显示)。我不想要不正确的比赛,也不想错过比赛。图片中显示的匹配无效。
我的代码如下:
import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt
img1 = cv.imread('target2.jpg',0)
img2 = cv.imread('geo50.jpg',0) # trainImage
orb = cv.ORB_create(edgeThreshold=14, nfeatures=100,
scoreType=cv.ORB_FAST_SCORE,scaleFactor=1)
kp1, des1 = orb.detectAndCompute(img1,None)
kp2, des2 = orb.detectAndCompute(img2,None)
bf = cv.BFMatcher(cv.NORM_HAMMING, crossCheck=True)
matches = bf.match(des1,des2)
matches = sorted(matches, key = lambda x:x.distance)
img3 = img3 = cv.drawMatches(img1,kp1,img2,kp2,matches[:100],None,flags = 2)
plt.imshow(img3),plt.show()