Ask Your Question

elham.gharibi's profile - activity

2016-04-07 09:55:22 -0600 asked a question hi,I want to write a python code using "freak" descriptor methods.I wrote this code
import sys
import cv2
import cv2.xfeatures2d
import numpy as np
from matplotlib import pyplot as plt
sys.path.append('/usr/lib/python2.7/site-packages')
img_bgr=cv2.imread('sc2.png')
img_gray=cv2.cvtColor(img_bgr,cv2.COLOR_BGR2GRAY)
template=cv2.imread('template.png',0)
freakExtractor = cv2.xfeatures2d.FREAK_create()
kp1,des1=freakExtractor.compute(img_bgr.png,None)
kp2,des2=freakExtractor.compute(template.png,None)
bf=cv2.BFMatcher()
matches=bf.knnmatch(des1,des2,k=2)
matches=sorted(matches,key=lambda x:x.distance)
img3=cv2.drawMatchesKnn(img1,kp1,img2,kp2,matches,None,flags=2)
plt.imshow(img3),plt.imshow()
cv2.waitKey(0)
cv2.destroyAllWindows()

Error: Traceback (most recent call last): File "test3.py", line 15, in <module> matches=bf.knnmatch(des1,des2,k=2) AttributeError: 'cv2.BFMatcher' object has no attribute 'knnmatch'