module 'cv2.cv2' has no attribute 'xfeatures2d'解决方案

一、问题
module ‘cv2.cv2’ has no attribute ‘xfeatures2d’
二、原因
该算法已经申请专利,开源OpenCV没有版权,新的OpenCV去掉了这个算法。
三、解决方法
1.都在建议补一个安装包
pip install opencv-contrib-python
2.但是我在补完之后又出现下面这样的错误:
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’
于是百度找到另一个解决办法是:
pip uninstall opencv-python
#推荐使用豆瓣python源
pip install opencv-python3.4.2.16 -i “https://pypi.doubanio.com/simple/”
pip install opencv-contrib-python
3.4.2.16 -i “https://pypi.doubanio.com/simple/”
(转载来源:原文链接:https://blog.csdn.net/Allyli0022/article/details/87010050)

你可能感兴趣的:(module 'cv2.cv2' has no attribute 'xfeatures2d'解决方案)