Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python+OpenCV 3 - cant use SIFT

I compiled OpenCV 3 & opencv_contrib from latest source code. Installed it into site-packages folder for Python 2.7. I can follow all of the tutorials at http://docs.opencv.org/trunk/doc/py_tutorials/py_feature2d/py_matcher/py_matcher.html except the ones involving SIFT.

Here is the error I get:

Traceback (most recent call last):
  File "C:\Projects\icu\ex01.py", line 9, in <module>
    sift = cv2.SIFT()
AttributeError: 'module' object has no attribute 'SIFT'

Please help. I searched & searched & searched and cant find anything related to Opencv3.

Oh, and I used Visual Studio 2013 to build it.

like image 345
Maxim Avatar asked Nov 11 '14 00:11

Maxim


People also ask

Is SIFT available in OpenCV?

SIFT in OpenCV Note that these were previously only available in the opencv contrib repo, but the patent expired in the year 2020. So they are now included in the main repo.

Can I use OpenCV with Python 3?

The nice thing with OpenCV is that it comes with a complete Python 3 library. The latest GeeXlab 0.29. 17.0 for Windows 64-bit comes with Python 3.8. 2 and OpenCV 4.2.

Which version of OpenCV has SURF?

To get access to the original SIFT and SURF implementations found in OpenCV 2.4. X, you'll need to pull down both the opencv and opencv_contrib repositories from GitHub and then compile and install OpenCV 3 from source.


1 Answers

as of 3.0, SIFT, SURF, BRIEF and FREAK were moved to a seperate opencv_contrib repo.

you will have to download that, add it to your main cmake settings (please see the README there), and rebuild the main opencv repo. after 'make install' your python should have a new cv2.pyd, that contains those again. then:

# note the additional namespace:
sift = cv2.xfeatures2d.SIFT_create() 
like image 192
berak Avatar answered Nov 02 '22 15:11

berak