|
|
|
@ -79,7 +79,7 @@ from matplotlib import pyplot as plt |
|
|
|
|
img1 = cv.imread('myleft.jpg',0) #queryimage # left image |
|
|
|
|
img2 = cv.imread('myright.jpg',0) #trainimage # right image |
|
|
|
|
|
|
|
|
|
sift = cv.SIFT() |
|
|
|
|
sift = cv.SIFT_create() |
|
|
|
|
|
|
|
|
|
# find the keypoints and descriptors with SIFT |
|
|
|
|
kp1, des1 = sift.detectAndCompute(img1,None) |
|
|
|
@ -93,14 +93,12 @@ search_params = dict(checks=50) |
|
|
|
|
flann = cv.FlannBasedMatcher(index_params,search_params) |
|
|
|
|
matches = flann.knnMatch(des1,des2,k=2) |
|
|
|
|
|
|
|
|
|
good = [] |
|
|
|
|
pts1 = [] |
|
|
|
|
pts2 = [] |
|
|
|
|
|
|
|
|
|
# ratio test as per Lowe's paper |
|
|
|
|
for i,(m,n) in enumerate(matches): |
|
|
|
|
if m.distance < 0.8*n.distance: |
|
|
|
|
good.append(m) |
|
|
|
|
pts2.append(kp2[m.trainIdx].pt) |
|
|
|
|
pts1.append(kp1[m.queryIdx].pt) |
|
|
|
|
@endcode |
|
|
|
|