OpenCV 3 in Python 2.7 gives error while using Brute-Force Matcher -


i'm using opencv 3 python 2.7 on windows.

here's code i'm working with:

import numpy np import cv2 matplotlib import pyplot plt img1 = cv2.imread('feature.jpg',0)   img2 = cv2.imread('large-pic.jpg',0) orb = cv2.orb_create() # cv2.orb() doesn't work mentioned in documentation  kp1, des1 = orb.detectandcompute(img1,none) kp2, des2 = orb.detectandcompute(img2,none) bf = cv2.bfmatcher(cv2.norm_hamming, crosscheck=true) matches = bf.match(des1,des2) matches = sorted(matches, key = lambda x:x.distance)  img3 = np.zeros((1,1)) img4 = cv2.drawmatches(img1,kp1,img2,kp2,matches[:10],img3,flags=2) plt.imshow(img4) 

while trying implement brute force feature matching using orb descriptors, following error after plt.imshow(img4):

traceback (most recent call last):   file "<pyshell#18>", line 1, in <module>     plt.imshow(img4)    file "c:\python27\lib\site-packages\matplotlib\pyplot.py", line 2368, in imshow     ret = ax.imshow(x, cmap, norm, aspect, interpolation, alpha, vmin, vmax, origin, extent, shape, filternorm, filterrad, imlim, resample, url, **kwargs)    file "c:\python27\lib\site-packages\matplotlib\axes.py", line 6734, in imshow im.set_data(x)   file "c:\python27\lib\site-packages\matplotlib\image.py", line 412, in set_data     raise typeerror("image data can not convert float") typeerror: image data can not convert float 

what reason ?

according this, should do:

img3 = cv2.drawmatches(img1,kp1,img2,kp2,matches[:10], flags=2) plt.imshow(img3),plt.show() 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -