Ask Your Question
0

How to execute sift() in python 3.6

asked 2018-07-12 04:18:15 -0500

Aswini gravatar image

I m trying this bit of code. But always error for cv2.SIFT(). I m using python 3.6, windows 64 bit. I tried installing opencv contrib using anaconda prompt.

import cv2 import numpy as np

img = cv2.imread('home.jpg') gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

sift = cv2.SIFT() kp = sift.detect(gray,None)

img=cv2.drawKeypoints(gray,kp)

cv2.imwrite('sift_keypoints.jpg',img)

edit retag flag offensive close merge delete

Comments

above code is only valid for outdated opencv2.4, so - which opencv version do you use ?

berak gravatar imageberak ( 2018-07-12 04:20:14 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-07-12 04:30:44 -0500

berak gravatar image

SIFT and SURF were moved to opencv_contrib with opencv3, also the api changed:

>>> help(cv2.xfeatures2d) # new submodule
sift = cv2.xfeatures2d.SIFT_create()
surf = cv2.xfeatures2d.SURF_create()

you'll probably also need to update your cv2, and NOT use conda, but pip here:

pip install opencv-contrib-python

(the conda packages are badly maintained or outdated )

edit flag offensive delete link more

Comments

berak gravatar imageberak ( 2018-07-12 04:34:44 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-07-12 04:18:15 -0500

Seen: 14 times

Last updated: Jul 12