sheikha
sheikha

Reputation: 13

SIFT in python 2.7.9 and opencv2 doesn't work

I tried a simple program to implement sift

import cv2
import numpy as np

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

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

img=cv2.drawKeypoints(gray,kp)

cv2.imshow('img', img)
cv2.waitKey(0)
cv2.destroyAllWindows()

but am getting an error

Traceback (most recent call last): File "sift.py", line 7, in sift = cv2.SIFT() AttributeError: 'module' object has no attribute 'SIFT'

i tried replacing this line with sift = cv2.xfeatures2d.SIFT_create()

and still error

Traceback (most recent call last): File "sift.py", line 7, in sift = cv2.xfeatures2d.SIFT_create() AttributeError: 'module' object has no attribute 'xfeatures2d'

please help!

Upvotes: 0

Views: 773

Answers (1)

P.Gupta
P.Gupta

Reputation: 585

The problem is with your version of OpenCV. This Method is available for OpenCV 3.0 and above.

You can check the documentation. It has features2d

Upvotes: 0

Related Questions