简体   繁体   English

模块“cv2.cv2”没有属性“xfeatures2d”,模块“cv2.cv2”没有属性“SIFT”

[英]module 'cv2.cv2' has no attribute 'xfeatures2d' and module 'cv2.cv2' has no attribute 'SIFT'

My python version = 3.7.4 cv2 version= 4.2.0我的 python 版本 = 3.7.4 cv2 版本 = 4.2.0

These are my version on python and open cv, Im trying to use SIFT function and I got the famous error module cv2.cv2' has no attribute 'SIFT' , so I tried pip install opencv-contrib-python and also python -m pip install --user opencv-contrib-python , and I changed detector=cv2.SIFT() to detector=cv2.xfeatures2d.SIFT_create() and the error just changed to AttributeError: module 'cv2.cv2' has no attribute 'xfeatures2d'这些是我在 python 和 open cv 上的版本,我尝试使用 SIFT 函数,我得到了著名的错误模块cv2.cv2' has no attribute 'SIFT' ,所以我尝试了pip install opencv-contrib-pythonpython -m pip install --user opencv-contrib-python ,我将detector=cv2.SIFT()更改为detector=cv2.xfeatures2d.SIFT_create()并且错误刚刚更改为 AttributeError: module 'cv2.cv2' has no attribute 'xfeatures2d'

I Tried with similar questions that I found, but are not working for me, I dont find a recent question, thats why Im opening this new because maybe as the version were different it could be the reason doesnt work for me我尝试了我发现的类似问题,但对我不起作用,我没有找到最近的问题,这就是我打开这个新问题的原因,因为也许版本不同,这可能是对我不起作用的原因

What else could I do?我还能做什么?

SIFT and SURF are proprietary, patented algorithms. SIFT 和 SURF 是专有的专利算法。 You'd need to compile OpenCV and OpenCV-contrib from source, with non-free packages enabled, building the python libraries.您需要从源代码编译 OpenCV 和 OpenCV-contrib,启用非自由包,构建 python 库。 I wasn't able to get this working so I used pip to find an older version (3.4.2) that did not remove the non-free libraries.我无法使其正常工作,因此我使用 pip 查找未删除非自由库的旧版本 (3.4.2)。 I may have had to roll back python but I'm not sure.我可能不得不回滚 python,但我不确定。 I am using python 3.6.8我正在使用 python 3.6.8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM