How do I convert the image data to float? Or is there something wrong with the code?

Asked

Viewed 75 times

0

I’m testing a code and I had problems: I can’t see the image. The message that appears is: Typeerror: Image data cannot be converted to float (picture data cannot be converted to float)

CODE:

from matplotlib import pyplot as plt
import numpy as np
import cv2

img1 = cv2.imread('teste8/inco.png',0)          # queryImage
img2 = cv2.imread('teste8/incoRec.png',0) # trainImage

# Initiate SIFT detector
orb = cv2.ORB_create()

# find the keypoints and descriptors with SIFT
kp1, des1 = orb.detectAndCompute(img1,None)
kp2, des2 = orb.detectAndCompute(img2,None)

# create BFMatcher object
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)

# Match descriptors.
matches = bf.match(des1,des2)

# Sort them in the order of their distance.
matches = sorted(matches, key = lambda x:x.distance)

# Draw first 10 matches.
img3 = cv2.drawMatches(img1,kp1,img2,kp2,matches,None, flags=2)

plt.imshow(img3),plt.show()
  • The site is en please ask the question in en

  • I’m testing a code and I had problems: I can’t see the image. The message that appears is: Typeerror: Image data cannot be converted to float (picture data cannot be converted to float) Could not fix this, please help me Google translator said hello! xD

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.