Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Image data cannot convert to float

The error is for the following line in the code:- plt.imshow(img3), plt.show()

click to hide/show revision 2
retagged

updated 2016-03-07 03:38:21 -0600

berak gravatar image

Image data cannot convert to float

The error is for the following line in the code:- plt.imshow(img3), plt.show()

Image data cannot convert to float

The error is for the following line in the code:- plt.imshow(img3), plt.show()plt.show() Please find the attachments. One of the two attachments contains the source code, whereas the second contains the Traceback Error. BFMatchingthree.png BFMatching_three.png

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. 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() BFMatchingthree.png BFMatching_three.png

click to hide/show revision 5
No.5 Revision

updated 2016-03-08 03:31:33 -0600

berak gravatar image

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

plt img1 = cv2.imread('../CarData/TestImages/test-0.pgm',0)# queryImage img2 = cv2.imread('../CarData/TestImages/test-1.pgm',0) # trainImage

trainImage # Initiate SIFT detector

sift = cv2.SIFT()

Initiate detector #sift = cv2.SIFT() #Initiate the ORB detector

detector orb = cv2.ORB_create()

cv2.ORB_create() # find the keypoints and descriptors with SIFT

kp1, SIFT #kp1, des1 = sift.detectAndCompute(img1,None)

kp2, sift.detectAndCompute(img1,None) #kp2, des2 = sift.detectAndCompute(img2,None)

sift.detectAndCompute(img2,None) # find the keypoints and descriptors with ORB

ORB kp1, des1 = orb.detectAndCompute(img1,None) kp2, des2 = orb.detectAndCompute(img2,None)

orb.detectAndCompute(img2,None) # BFMatcher with default params

params bf = cv2.BFMatcher() matches = bf.knnMatch(des1,des2, k=2)

k=2) # Apply ratio test

test good = [] for m,n in matches: if m.distance < 0.75*n.distance: good.append([m])

good.append([m]) # cv2.drawMatchesKnn expects list of lists as matches.

matches. img_temp = np.zeros((1,1)) img3 = cv2.drawMatchesKnn(img1,kp1,img2,kp2,good,img_temp,flags=2)


cv2.drawMatchesKnn(img1,kp1,img2,kp2,good,img_temp,flags=2) ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- plt.imshow(img3),plt.show()

plt.imshow(img3),plt.show() BFMatchingthree.png BFMatching_three.png