AttributeError: module 'cv2' has no attribute 'xfeatures2d'

一、问题

module 'cv2.cv2' has no attribute 'xfeatures2d'
二、原因

该算法已经申请专利,开源OpenCV没有版权,新的OpenCV去掉了这个算法。

 
三、解决方案
1、推荐解决办法

    pip uninstall opencv-python
    #推荐使用豆瓣python源
    pip install opencv-python==3.4.2.16 -i "https://pypi.doubanio.com/simple/"
    pip install opencv-contrib-python==3.4.2.16 -i "https://pypi.doubanio.com/simple/"

2、不推荐的算法

    pip uninstall opencv-python
    #推荐使用豆瓣python源
    pip install opencv-contrib-python -i "https://pypi.doubanio.com/simple/"

不推荐的原因:去掉opencv-python,会造成系列其他问题。引入的头文件名字也会改变。

原文:https://blog.csdn.net/linghugoolge/article/details/85229411 

猜你喜欢

转载自blog.csdn.net/Allyli0022/article/details/87010050