我想要遵循opencv教程here。不幸的是,它在flann.knnMatch(des1,des2,k = 2)失败。这里是我的代码:OpenCV和Python:KnnMatch参数的问题
import cv2
import time
import numpy as np
im1 = cv2.imread('61_a.tif')
im2 = cv2.imread('61_b.tif')
surf = cv2.SURF(500,3,4,1,0)
print "Detect and Compute"
kp1 = surf.detect(im1,None)
kp2 = surf.detect(im2,None)
des1 = surf.compute(im1,kp1)
des2 = surf.compute(im2,kp2)
MIN_MATCH_COUNT = 5
FLANN_INDEX_KDTREE = 0
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
search_params = dict(checks = 50)
flann = cv2.FlannBasedMatcher(index_params,search_params)
matches = flann.knnMatch(des1,des2,k=2)
我得到的错误:
matches = matcher.knnMatch(des1,des2,k