opencv-contrib-python安装步骤及module object has no attribute ‘xfeatures2d’问题


contrib-python安装&module object has no attribute ‘xfeatures2d’问题


第一次写博客,主要参考了肥宅大神的博客,原文链接如下所示https://blog.****.net/a19990412/article/details/80933680#commentsedit

当python运行时,出现了module object has no attribute ‘xfeatures2d’
这样的问题,此时需要安装新的模块,即opencv-contrib-python
这个模块是opencv的附加模块,需要重新安装,
该文件下载网址https://pypi.org/project/opencv-contrib-python/3.2.0.7/#files
opencv-contrib-python安装步骤及module object has no attribute ‘xfeatures2d’问题

  1. 红色方框中release history(释放的历史),点击之后可以下载对应的版本,最新版模块也有。建议下载最古老的版本,因为貌似申请专利了,无法在新的版本里使用,我下载的是:
    opencv_contrib_python-3.2.0.7-cp27-cp27m-win_amd64.whl,可以使用,
    opencv_contrib_python-3.4.1.15-cp27-cp27m-win_amd64.whl这个版本,我试过,已经无法调用‘xfeatures2d’这个函数了。
    其中3.4.1.15是该模块的版本,cp27是python的2.7版本,win 64是windows系统64位。个人根据自己的电脑、python版本进行下载。

  2. 下载后,文件复制进入python安装后文件的Scripts下,如下图所示。
    opencv-contrib-python安装步骤及module object has no attribute ‘xfeatures2d’问题

  3. 接着,在上述界面同时按住shift键+鼠标右键。出现一个选择窗口,选择打开powershell窗口。进入下述界面
    注意:(这个步骤也可以通过win+R进入运行界面,输入cmd,具体可以百度)
    opencv-contrib-python安装步骤及module object has no attribute ‘xfeatures2d’问题
    ``在上述界面中将下图中的红框中进行复制,如下图所示,点击3.2.0.7后面的复制按钮
    opencv-contrib-python安装步骤及module object has no attribute ‘xfeatures2d’问题
    复制后,进入下面窗口,单击右键即可,如下图所示,
    opencv-contrib-python安装步骤及module object has no attribute ‘xfeatures2d’问题
    接着,按一下Enter键,即可进行安装。会出现英文安装结果。
    成功后,运行python程序,如成功运行,则ok,若还是存在问题,则先卸载所安装的文件,如下图所示,改为uninstall(不安装)即可。
    opencv-contrib-python安装步骤及module object has no attribute ‘xfeatures2d’问题
    卸载后,重新进入https://pypi.org/project/opencv-contrib-python/3.2.0.7/#files下载更老的版本,重新安装。