新浪博客

python:解决不能使用sift

2018-11-07 17:19阅读:
出现问题:Traceback (most recent call last):
File 'D:\hexinghua\hxh_python\hxh_matchTemplate\hxh_matchTemplate\test1.py', line 5, in SIFT()
File 'D:\hexinghua\hxh_python\hxh_matchTemplate\hxh_matchTemplate\test1.py', line 4, in SIFT
sift = cv2.xfeatures2d.SIFT_create()
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'
原因:
没有配置opencv_contrib,需要导入opencv_contrib
解决方法是安装opencv_contrib,pip install opencv-contrib-python,但这种方法不能解决该问题
我的解决方法是:先卸载opencv,再将opencv版本改为3.4.2。
pip install opencv-python==3.4.2.16
pip install opencv-contrib-python==3.4.2.16

我的更多文章

下载客户端阅读体验更佳

APP专享