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

遇到该问题时,网友多是建议补个包,即pip install opencv-contrib-python
我在补完之后又出现下面这样的错误:
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’
将opencv版本退到3.4.2即可解决,卸载之前的包(pip uninstall opencv-python),然后
pip install opencv-python==3.4.2.16
pip install opencv-contrib-python==3.4.2.16
注意以上两条命令==左右没有空格

又报错误:

  'module' object has no attribute 'xfeatures2d'

原因:opencv将SIFT等算法整合到xfeatures2d集合里面了。

siftDetector=cv2.SIFT()

变更后为

siftDetector= cv2.xfeatures2d.SIFT_create()

又报:

TypeError: Required argument 'outImage' (pos 3) not found

im=cv2.drawKeypoints(img_RGB,kp,flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
变更后为im=cv2.drawKeypoints(img_RGB,kp,img,flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)

SURF:

import cv2
 
img = cv2.imread('cat.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
 
surf = cv2.xfeatures2d.SURF_create()
kp = surf.detect(gray, None)
 
img = cv2.drawKeypoints(gray, kp, img)
 
cv2.imshow("img", img)
 
k = cv2.waitKey(0)
if k & 0xff == 27:
    cv2.destroyAllWindows()

 

AttributeError: module 'cv2' has no attribute 'SIFT'解决总结的更多相关文章

  1. python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?

    python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...

  2. 【pycharm】pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法

    pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法 解决方法: 在pycharm的安装目 ...

  3. [开发技巧]·AttributeError: module 'pywt' has no attribute 'wavedec'解决方法

    [开发技巧]·AttributeError: module 'pywt' has no attribute 'wavedec'解决方法 1.卸载 pywt pip uninstall pywt 2.安 ...

  4. pygame模块使用时出现AttributeError: module ‘pygame’ has no attribute '…'错误解决方法

    pygame模块使用时出现AttributeError: module 'pygame' has no attribute '-'错误解决方法 首先在pygame中存在init()模块,出现这样的问题 ...

  5. Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法

    最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...

  6. AttributeError: module '__main__' has no attribute 'main'解决方法

    在终端运行.py文件时报错:AttributeError: module '__main__' has no attribute 'main' 原因:在PyCharm里运行python程序需要添加 i ...

  7. 提示AttributeError: 'module' object has no attribute 'HTTPSHandler'解决方法

    今天在新机器上安装sqlmap,运行提示AttributeError: 'module' object has no attribute 'HTTPSHandler' 网上找了找资料,发现一篇文章ht ...

  8. OpenCV 学习笔记 05 人脸检测和识别 AttributeError: module 'cv2' has no attribute 'face'

    1 环境设置: win10 python 3.6.8 opencv 4.0.1 2 尝试的方法 在学习人脸识别中,遇到了没有 cv2 中没有 face 属性.在网上找了几个方法,均没有成功解决掉该问题 ...

  9. cv2.SIFT() AttributeError: 'module' object has no attribute 'SIFT' OpenCV Python can't use SURF, SIFT

    参考链接: https://stackoverflow.com/questions/18561910/opencv-python-cant-use-surf-sift For recent infor ...

随机推荐

  1. Java 学习笔记(8)——匿名对象与内部类

    一般在编写代码时可能会遇到这样的场景--在某些时候,我需要定义并某个类,但是只会使用这一次,或者是某个类对象只会使用一次,为它们专门取名可能会显的很麻烦.为了应对这种情况,Java中允许使用匿名对象和 ...

  2. 聊聊多线程哪一些事儿(task)之 一

    多线程,一个多么熟悉的词汇,作为一名程序员,我相信无论是从事什么开发语言,都能够轻轻松松说出几种实现多线程的方式,并且在实际工作种也一定用到过多线程,比如:定时器.异步作业等等,如果你说你没有用过多线 ...

  3. 【原创】(十四)Linux内存管理之page fault处理

    背景 Read the fucking source code! --By 鲁迅 A picture is worth a thousand words. --By 高尔基 说明: Kernel版本: ...

  4. switch多值匹配骚操作,带你涨姿势!

    我们都知道 switch 用来走流程分支,大多情况下用来匹配单个值,如下面的例子所示: /** * @from 微信公众号:Java技术栈 * @author 栈长 */ private static ...

  5. vc调用mysql数据库操作例子

    这里归纳了C API可使用的函数 函数 描述 mysql_affected_rows() 返回上次UPDATE.DELETE或INSERT查询更改/删除/插入的行数. mysql_autocommit ...

  6. c++简单实现二叉树

    专业术语: 节点 父节点 根节点 子孙 堂兄弟 深度: 从根节点到最底层节点的层数称为深度 叶子节点: 没有子节点的节点称为叶子节点 非终端节点: 实际就是非叶子节点 度: 子节点的个数称为度 树的分 ...

  7. Jmeter-Ant 生成测试报告配置步骤

    1.配置java环境变量(不会的可以自行百度) 2.安装jmeter 3.安装ant,配置ant环境变量 4.将JMeter所在目录下extras子目录里的ant-JMeter-1.1.1.jar复制 ...

  8. 「洛谷P1233」木棍加工 解题报告

    P1233 木棍加工 题目描述 一堆木头棍子共有n根,每根棍子的长度和宽度都是已知的.棍子可以被一台机器一个接一个地加工.机器处理一根棍子之前需要准备时间.准备时间是这样定义的: 第一根棍子的准备时间 ...

  9. UCI 人口收入数据分析(python)

    一.项目介绍 UCI上有许多免费的数据集可以拿来练习,可以在下面的网站找寻 http://archive.ics.uci.edu/ml/datasets.html 这次我使用的是人口收入调查,里面会有 ...

  10. HashMap中的位运算

    二进制基础回顾 以下操作相对正整数的二进制而言,对非整数不太适用. 二进制转十进制   在二进制中,位权是2的幂,所以每一位所代表的权值从右到左分别为2^(1-1) .2^(2-1) .... . 2 ...