2021-08-30AttributeError: ‘module‘ object has no attribute ‘xfeatures2d‘

环境

ubuntu18.04+opencv3.2.0

在运行代码过程中缺少contrib模块,报错

Traceback (most recent call last):
  File "flann_match_locate.py", line 33, in <module>
    sift = cv2.xfeatures2d.SIFT_create()
AttributeError: 'module' object has no attribute 'xfeatures2d'

在网上搜索解决办法,如下

pip install opencv-contrib-python==3.3.0.10

显示:
ERROR: Could not find a version that satisfies the requirement opencv-contrib-python3.3.0.10 (from versions: none)
ERROR: No matching distribution found for opencv-contrib-python
3.3.0.10

解决办法

试了很多网上的办法,都行不通。
自己尝试了一下以下方法,可行。

打开网址:

https://pypi.org/project/opencv-contrib-python/#history

在这里插入图片描述

选择自己需要的contrib版本,点击Download files进行下载;
在这里插入图片描述终端运行:
pip install opencv-contrib-python… .whl文件

续:

回家后在个人电脑上尝试装了一下,发现很简单就装上了。
笔记本上是周末新装的ubuntu18.04
终端输入:

pip3 install opencv-python==3.4.2.16 -i https://pypi.tuna.tsinghua.edu.cn/simple/

然后:

pip3 install opencv-contrib-python==3.4.2.16 -i https://pypi.tuna.tsinghua.edu.cn/simple/

直接就安装成功了,可能还是受到环境配置的影响吧。
最后放一张测试contrib模块的匹配图,用了SURF。
在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值