Python+OpenCV 3 - cant use SIFT

对着背影说爱祢 提交于 2019-12-04 11:48:21

问题


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.


回答1:


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() 


来源:https://stackoverflow.com/questions/26855753/pythonopencv-3-cant-use-sift

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!