Ask Your Question

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)



edit retag flag offensive close merge delete


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

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


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

Question Tools

1 follower


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

Seen: 664 times

Last updated: Jul 12