Ask Your Question
0

I have a problem with module SIFT (python)

asked 2018-01-09 16:11:24 -0600

Hi! I use Python 3.6 and OpenCV 3.4, I try to find epipolar geometry using script from tutorial (http://opencv-python-tutroals.readthe...) I know that there is a problem with SIFT module so I try to change it and that is part of my script:

import cv2

img1 = cv2.imread('DSC_0001.jpg',cv2.COLOR_RGB2GRAY) #queryimage # left image

img2 = cv2.imread('DSC_0002.jpg',cv2.COLOR_RGB2GRAY) #trainimage # right ima

kp1, des1 = cv2.xfeatures2d_SIFT.detectAndCompute(img1, None)

kp2, des2 = cv2.xfeatures2d_SIFT.detectAndCompute(img2, None)

But there is an error: TypeError: descriptor 'detectAndCompute' requires a 'cv2.Feature2D' object but received a 'numpy.ndarray'

I don't understand what I should give there as Fearure2D and I will be glad for any help :]

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-01-09 20:05:09 -0600

supra56 gravatar image
sift = cv2.xfeatures2d.SIFT_create()
(kps1, descs1) = sift.detectAndCompute(img1, None)

sift = cv2.xfeatures2d.SIFT_create()
(kps2, descs2) = sift.detectAndCompute(img2, None)
edit flag offensive delete link more

Comments

1

Thank you! Now it's work. I also tried to write it like that but probably I forgot to use () at the begining - like always stupid mistake - that's why it didn't work and I thought it was bigger problem :]

nantalia gravatar imagenantalia ( 2018-01-10 08:50:32 -0600 )edit

@nantalia, can you vote for answer?

supra56 gravatar imagesupra56 ( 2018-01-10 10:15:40 -0600 )edit

Because api is newest library version from OpenCV3.1.x, but not older version 3.0.0. Same thing happened to me when I moved to 3.1.0.

supra56 gravatar imagesupra56 ( 2018-01-10 10:19:19 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-01-09 16:11:24 -0600

Seen: 3,205 times

Last updated: Jan 09 '18