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. 查看HBase表在HDFS中的文件结构(转发)

    转自:http://greatwqs.iteye.com/blog/1839232

  2. .data()与.detach()的区别

    .data()和.detach()都可以获取Variable内部的Tensor,但.detach()更加安全 https://zhuanlan.zhihu.com/p/38475183

  3. 专业版12.0试用,打开演示账套,提示“列名FPlatver无效”

    你好,我代表研发来说明一下这个问题:一.产生的原因:由于KIS产品今年陆续都增加了应用平台,前期平台兼容性还有些问题,如果一台电脑有多个不同版本的平台,就会产生冲突,因此报错.1.可能您的机器装了多个 ...

  4. TCP/IP||Traceroute

    1.概述 由Van jacobson编写的工具,用于探索tcp/ip协议,使用ICMP报文和首部TTL字段,TTL字段由发送端设置一个8bit字段,初始值为RFC指定,当前值为64, 每个处理数据的路 ...

  5. c++ 屏幕截图指定窗口句柄后台截图返回位图句柄

    /根据窗口句柄后台截图保存成BMP位图文件并且显示到picture 控件上 void GetScreenBmp(HWND hwnd, int left, int top, int width, int ...

  6. 洛谷$P1935$ [国家集训队]圈地计划 网络流

    正解:最小割 解题报告: 传送门 就文理分科模型嘛$QwQ$?所以就,跑个最小割呗,然后就做完辣?仔细想想细节发现并麻油那么简单嗷$QwQ$ 先考虑如果没有这个$k\cdot C_{i,j}$的贡献就 ...

  7. 远程管理服务器--批量管理服务器,vps

    一般大型的企事业单位都有自己的服务器,但是服务器一般都放在机房,辐射较大,噪音大,如何能有效的避免这一情况呢?哈哈,那就来个远程桌面,远程操作服务器吧. 一.使用 iis7远程连接管理工具工具下载官网 ...

  8. MyBatis原理-架构流程

    一 .MyBatis原理架构图 Mybatis的功能架构分为三层: API接口层:提供给外部使用的接口API,开发人员通过这些本地API来操纵数据库.接口层一接收到调用请求就会调用数据处理层来完成具体 ...

  9. selenium自动化测试之--验证码处理

    由于登录反爬措施的越来越麻烦,甚至出现了12306这种看图识物的无敌验证码,我只能说,我选择死亡.这就衍生出了使用selenium来获取获取cookies. 因为经常会出现验证码,导致我们ui自动化测 ...

  10. 从零开始Go语言-GoLand(编译器)-Windows(平台)

    本文章适合那些想入门Go语言,却又不知道如何搭建自己的第一个HelloWorld的同学. 推荐几个Go语言相关学习网站: C语言中文网: http://c.biancheng.net/golang/ ...