module ‘cv2.cv2‘ has no attribute ‘xfeatures2d_SIFT‘错误

在使用OpenCV和Python进行图片全景拼接时遇到模块'cv2.cv2'缺少属性'xfeatures2d_SIFT'的问题。解决方法包括将`sift = cv.xfeatures2d_SIFT().create()`改为`sift = cv.xfeatures2d.SIFT_create()`,确保安装了opencv-contrib-python模块,如果仍然报错,可能需要降级到opencv-python 3.4.2.16和opencv-contrib-python 3.4.2.16版本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用于opencv+python图片全景拼接出现的问题

问题1:module 'cv2.cv2' has no attribute 'xfeatures2d_SIFT'问题

解决方法:把sift = cv.xfeatures2d_SIFT().create() 换成sift = cv.xfeatures2d.SIFT_create()

问题2:module 'cv2.cv2' has no attribute 'xfeatures2d'问题

解决方法:需要导入opencv-contrib-python模块,导入语句:pip install opencv-contrib-python。(注意:记得先关闭python再重新打开,否则在运行的时候还会出现以上错误)

具体导入方法请看连接:https://blog.csdn.net/weixin_43837871/article/details/88897272

问题3:导入opencv-contrib-python模块后,还出现sift = cv.xfeatures2d.SIFT_create()
cv2.error: OpenCV(4.0.0) 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没有版权,新的OpenC

评论 22
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值