CoCalc Shared Filesopencv.sagewsOpen in CoCalc with one click!
Authors: Tim Clemans SMC, Harald Schilly, William A. Stein, alwaysleaveanote alwaysleaveanote
Views : 39
print 'a'
a
import cv2
import numpy as np import cv2 from matplotlib import pyplot as plt img1 = cv2.imread('test_frames/00100.png',0) # queryImage img2 = cv2.imread('test_frames/00080.png',0) # trainImage # Initiate SIFT detector sift = cv2.xfeatures2d.SIFT_create() # find the keypoints and descriptors with SIFT kp1, des1 = sift.detectAndCompute(img1,None) kp2, des2 = sift.detectAndCompute(img2,None) # BFMatcher with default params bf = cv2.BFMatcher() matches = bf.knnMatch(des1,des2, k=2) # Apply ratio test good = [] for m,n in matches: good.append([m]) # cv2.drawMatchesKnn expects list of lists as matches. img3 = cv2.drawMatchesKnn(img1,kp1,img2,kp2,good,None,flags=2) plt.imshow(img3),plt.show()
(<matplotlib.image.AxesImage object at 0x7f957b31fc90>, None)
cv2.xfeatures2d.
<module 'cv2.xfeatures2d' (built-in)>
BriefDescriptorExtractor_create