1
不繪製匹配。 Opencv 3.0,完全更新的Ubuntu。代碼運行但不顯示任何匹配。測試區域直接剪切並從圖像中複製以匹配。Opencv。 cv2.drawMatches()不繪製匹配。 Opencv 3.0
import numpy as np
import cv2
cv2.ocl.setUseOpenCL(False)
img1 = cv2.imread('images/ingrassroi.png',0)
img2 = cv2.imread('images/ingrass.png',0)
img3 = img1.copy()
# Initiate ORB detector
orb = cv2.ORB_create()
# compute the descriptors with ORB
kp1, des1 = orb.detectAndCompute(img1,None)
kp2, des2 = orb.detectAndCompute(img2,None)
# create BFMatcher object
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
# Match descriptors.
matches = bf.match(des1,des2)
# Sort them in the order of their distance.
matches = sorted(matches, key = lambda x:x.distance)
# Draw first 10 matches.
img3 = cv2.drawMatches(img1,kp1,img2,kp2,matches[:10],None, flags=2)
cv2.imshow("Matches",img3)
cv2.waitKey(-1)