Image data cannot convert to float
The error is for the following line in the code:- plt.imshow(img3), plt.show() Please find the attachments. One of the two attachments contains the source code, whereas the second contains the Traceback Error.
Text Version of Code.:-
import numpy as np
import cv2
from matplotlib import pyplot as plt
img1 = cv2.imread('../CarData/TestImages/test-0.pgm',0)# queryImage
img2 = cv2.imread('../CarData/TestImages/test-1.pgm',0) # trainImage
# Initiate SIFT detector
#sift = cv2.SIFT()
#Initiate the ORB detector
orb = cv2.ORB_create()
# find the keypoints and descriptors with SIFT
#kp1, des1 = sift.detectAndCompute(img1,None)
#kp2, des2 = sift.detectAndCompute(img2,None)
# find the keypoints and descriptors with ORB
kp1, des1 = orb.detectAndCompute(img1,None)
kp2, des2 = orb.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:
if m.distance < 0.75*n.distance:
good.append([m])
# cv2.drawMatchesKnn expects list of lists as matches.
img_temp = np.zeros((1,1))
img3 = cv2.drawMatchesKnn(img1,kp1,img2,kp2,good,img_temp,flags=2)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
plt.imshow(img3),plt.show()
not enough info, even for my crystal ball ..
opencv / numpy versions ? (above prog works fine with opencv3.1.0/numpy1.10.2)