I'm getting this error when trying to use cv.ExtractSURF:
cv2.error: OpenCV was built without SURF support
I found the solution for c++ in this topic:
OpenCV SURF function is not implemented
but how can I use it in python ?
---Edit---
When I try to run the example find_obj.py which uses cv2.SURF(800) I get the following error:
AttributeError: 'module' object has no attribute 'SURF'
It seems that some functions are moved to "nonfree" module and that module is removed from the latest OpenCV package on FC18. Until this will be resolved, I made downgrade OpenCV library on my 64bit FC18 from version 2.4.3 to version 2.3.1. With downgraded library, all my python code started to work as it worked on FC17. Here is link to my post where I have described complete "downgrade" procedure:
http://www.redips.net/linux/downgrade-opencv-fedora18/
OK this happens because I use Fedora 18 (and I installed it with yum):
http://forums.fedoraforum.org/showthread.php?t=287847
Related
I get an attribute error if I use the function:
def faceDetection():
if results.detections:
for detection in results.detection:
print(id, detection)
AttributeError: type object 'SolutionOutputs' has no attribute
'detections'
is the error I get if I try running, specifically it calls it on the results.detections: line
it works fine in this youtube tutorial
at 1:43:56
I don't really know how to read the github code but here's the link
I do have
mpFD = mp.solutions.face_detection # FD = face_detection
fD = mpFD.FaceDetection()
defined before the function already.
Is this an issue with my code or is it something else?
This error depends on the Python version you are using. You need to use the version minimum Python 3.9 but most probably you are using Python 3.6.
It would be better to create an environment with conda by specifying Python version and install mediapipe in there and try to run your code again. The error will disappear.
Here is an example how to establish environment to run mediapipe examples.
It wasn't a problem with the mediapipe library, but I hadn't initialized results as the faceDetections solutions, but I had results as a value for the hands solution module.
I'm new to OpenCV and trying to use SIFT and SURF for a project.
On my laptop I have OpenCV version= 4.5.1.48 and also added OpenCV-contrib-python of version 4.5.1.48
currently the problem I'm facing is the error I'm getting after following the documentation SIFT works perfectly after following documentation but SURF isn't working and giving me error for following codes
code 1
surf = cv.xfeatures2d.SURF_create()
AttributeError: module 'cv2.cv2' has no attribute 'xfeatures2d'
code 2
surf = cv2.SURF_create()
AttributeError: module 'cv2.cv2' has no attribute 'SURF_create'
After reading many answers on Stack overflow I changed version of OpenCV and did many things but nothing is working for me
I'm new to this please someone guide me through this
I read about the patent expiring too but nothing is working in my case pls tell me if im wrong somewhere
Thanks in advance
OpenCV version= 4.5.1.48
this is probably from pypi, and does not contain any "nonfree" code
(SURF is still patented, if you absolutely need that, you have to build from src (with contrib modules), using the OPENCV_ENABLE_NONFREE=ON cmake flag)
however, since the SIFT patent expired last year, use that instead
sift = cv2.SIFT_create() # it's in main, no more xfeatures2d
btw, dont install both opencv-python, and opencv-contrib-python, only the latter (else the former will "shadow" it, and you cannot use contrib modules. this is the reason for AttributeError: module 'cv2.cv2' has no attribute 'xfeatures2d')
For patent reasons, opencv 4.5.1.48 does not include the whole algorithm
You can use Python3.6 (or Python3.7 maybe OK) and install opencv-pyhton==3.4.2.16 and opencv-contrib-python==3.4.2.16, then you can use the function that:
surf = cv2.xfeatures2d.SURF_create()
or
sift = cv2.xfeatures2d.SIFT_create()
I'm trying to run this example, but getting the following error:
AttributeError: module 'skimage.filters' has no attribute 'gaussian_filter'
I checked the documentation, here, and see that filters has gaussian_filter. What might be wrong?
Thanks.
gaussian_filter has been removed in skimage 0.14.0 (see the release notes - http://scikit-image.org/docs/stable/api_changes.html). You should now use skimage.filters.gaussian (http://scikit-image.org/docs/0.14.x/api/skimage.filters.html#skimage.filters.gaussian).
I had a similar problem with the mahotas module, which was because of the version. Un-installed and re-installed an older version resolved the problem
I am trying to follow the tutorial given in:
https://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_video/py_bg_subtraction/py_bg_subtraction.html
While trying the third example (BackgroundSubtractorGMG) I get this error:
AttributeError: 'module' object has no attribute 'createBackgroundSubtractorGMG'
I got the same error for the earlier examples. But I followed the explanation given in this post. some how, the same trick did not work here.
If there is some one who has managed to solve it, please help me out.
Using Python 2.7.3 & opencv 2.4.6.1 on Ubuntu 12.04
In OpenCV 3.0.0-dev, you have to compile with the contrib repos and then it's in the bgsegm sub-module. I.e. just call cv2.bgsegm.createBackgroundSubtractorGMG()
cv2.bgsegm.createBackgroundSubtractorGMG()
cv2.createBackgroundSubtractorMOG2()
cv2.bgsegm.createBackgroundSubtractorMOG(),
**this worked for me **
oh dear, that's another one of those stories ...
with 2.4.6, you only can use BackgroundSubtractorMOG from python. (full stop)
as of 2.4.8, it seems, the BackgroundSubtractorMOG2 problem got fixed, but the BackgroundSubtractorGMG is still missing.
with both versions, you use a plain constructor to create one.
in 3.0 (master), they changed the syntax, you now have to call 'createBackgroundSubtractorGMG', 'createBackgroundSubtractorMOG2' and such (that's what your tutorial might be refering to). but now you can use all 3 versions at least.
so in any way, if you want to use BackgroundSubtractorMOG2 , you'll have to update to 2.4.8, if you need BackgroundSubtractorGMG, you'll need 3.0 (which is 'bleeding edge' in a way, but the new interface has the far better control over the params needed, imho).
bgsegm was in contrib module of opencv, but after the update I am not sure.
But still,
if you have not built contrib module:
pip install opencv-contrib-python
Make sure no console is running that has imported cv2 while you execute your installing process.
Run the cmd as Administration
It worked for me.
I'm trying to create Descriptor extractor using FREAK. but
at the following line:
freakExtractor = cv2.DescriptorExtractor_create('FREAK')
I get an error saying:
freakExtractor = cv2.DescriptorExtractor_create('FREAK')
AttributeError: 'module' object has no attribute 'DescriptorExtractor_create'
can someone tell me what is the exact problem and why i'm getting this error?
I'm using ubuntu 12.10 with opencv 2.4.3 and python 2.7.
I think,
cv2.DescriptorExtractor_create('FREAK')
is not a part of python interface, just use the latest opencv for that then it will work or you simply can write the code in c++ which is availabe in that version in c++.