1
  • My code on Google Colab
import cv2 as cv

image = cv.imread("/content/drive/My Drive/Image.bmp")
gray_image = cv.cvtColor(image,cv.COLOR_BGR2GRAY)

sift = cv.xfeatures2d_SIFT.create()
keyPoints = sift.detect(image,None)

output = cv.drawKeypoints(image,keyPoints,None)

cv.imshow("FEATURES DETECTED",output)
cv.imshow("NORMAL",image)

cv.waitKey(0)
cv.destroyAllWindows()
  • ERROR

*AttributeError Traceback (most recent call last) in () 4 gray_image = cv.cvtColor(image,cv.COLOR_BGR2GRAY) 5 ----> 6 sift = cv.xfeatures2d_SIFT.create() 7 keyPoints = sift.detect(image,None) 8

  • AttributeError: module 'cv2.cv2' has no attribute 'xfeatures2d_SIFT'
RashidLadj_Winux
  • 810
  • 1
  • 6
  • 17
VaishabhJalmi
  • 11
  • 1
  • 4
  • Check here: https://www.pyimagesearch.com/2015/07/16/where-did-sift-and-surf-go-in-opencv-3/ – iGian Oct 22 '20 at 05:56
  • These algos are patented. ORB is not bad though and you might consider giving it a try. – bfris Oct 22 '20 at 21:30
  • He thanks I saw that link already that's not for Windows. About SURF and SIFT algorithm we can't use them in python contributing? Is there any other method I can use please suggest. – VaishabhJalmi Oct 23 '20 at 06:19

1 Answers1

4

the first thing to do is see the exact version you are using, all just running:

print (cv2 .__ version__)

if version = 4.4.0 then sift = cv2.SIFT_create ()

if version = 4.3.x then sift = cv2.xfeatures2d.SIFT_create ()

if Version = 4.2.x or 4.1.xu 4.0.x, then SIFT will not work, it is not taken into consideration during the construction of the python package, the activation of the open-contrib module as well as the use of algorithms non free have not been activated.

on google colab you can install the opencv version you want by simply using a pip command preceded by an exclamation point "!" and specify the opencv version as follows:

!pip install opencv-contrib-python==4.4.0.44

Note: As I write this, the last available version of openv in C ++ is version 4.5.0 , and the latest version of opencv python package is 4.4.0.44

RashidLadj_Winux
  • 810
  • 1
  • 6
  • 17