报错:AttributeError: module ‘cv2.cv2‘ has no attribute ‘xfeatures2d‘(已解决)

原因是opencv4.4因为专利的原因opencv已经不包含整个算法了。所以需要下载opencv4.4.0的版本。
进入https://pypi.tuna.tsinghua.edu.cn/simple/opencv-python/
下载所需的版本,比如windows 64位,Python 3.7 下载
报错:AttributeError: module ‘cv2.cv2‘ has no attribute ‘xfeatures2d‘(已解决)

如果不对应很有可能安装不起来。
下载完成后,打开prompt。
报错:AttributeError: module ‘cv2.cv2‘ has no attribute ‘xfeatures2d‘(已解决)
首先先卸载opencv:pip uninstall opencv-python
报错:AttributeError: module ‘cv2.cv2‘ has no attribute ‘xfeatures2d‘(已解决)

再cd到*下载的地址,输入pip install opencv_python-4.4.0.46-cp37-cp37m-win_amd64.whl
在这里插入图片描述

即可完成opencv的版本更换。