sift = cv2.xfeatures2d.SIFT_create() not working e

2019-03-19 04:05发布

问题:

So I am trying to use:

sift = cv2.xfeatures2d.SIFT_create()

and it is coming up with this error:

cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv_contrib\modules\xfeatures2d\src\sift.cpp:1207: error: (-213:The function/feature is not implemented) 
This algorithm is patented and is excluded in this configuration; Set OPENCV_ENABLE_NONFREE CMake 
option and rebuild the library in function 'cv::xfeatures2d::SIFT::create'

I am using Python 3.5.0 and opencv(3.4.3) and I am just using idle. This occured after I tried to install TensorFlow and I have tried looking around and have installed opencv-contrib-python but I am still getting the same error. Thank you in advance and I apologise if I have not included enough info

回答1:

I had the same problem. I change other opencv-python and opencv-contrib-python version, and solve this problem. Here is the history version about opencv-python.

https://pypi.org/project/opencv-python/#history, and i use the following code :

pip install opencv-python==3.4.2.16

pip install opencv-contrib-python==3.4.2.16

Edit

For Anaconda User just this instead of pip

conda install -c menpo opencv

this will install cv2 3.4.1 and everything you need to run SIFT

good luck~



回答2:

It may be due to a mismatch of opencv version and opencv-contrib version. If you installed opencv from the source using CMake, and the source version is different from the version of opencv-contrib-python, uninstall the current opencv-contrib-python and do pip install opencv-contrib-python==<version of the source>.X or an another compatible version. One version setup that I have running is opencv source (3.2), opencv-python (3.4.0.14) and opencv-contrib-python (3.4.2.17)