It appears the new module is installed correctly. I'm able to import cv2 in both Python versions. However neither recognise the new features the module is supposed to add.
>>> cv2.SURF()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'SURF'
>>> cv2.xfeatures2d.SURF()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'xfeatures2d'
I encountered this same issue. I'm using python 2.7.6 and OpenCv 3.0 with the additional non-free modules. I do have xfeatures2d present in available modules and can import it, however it was as though xfeatures2d didn't contain SIFT or SURF. No matter how I called them it was the same Error:
"AttributeError: 'module' object has no attribute 'SIFT'
I tried the different name spaces suggested, and only recently noticed this detail and GOT IT WORKING!
$ python
>>>import cv2
>>>help(cv2.xfeatures2d)
You'll notice that it replies that it is now referred to as...
FUNCTIONS
SIFT_create(...)
and
SURF_create(...)
So very simply - the namespace is NOT "cv2.SIFT()" or "cv2.xfeatures2d.SIFT" but rather
This does not really answer the question. If you have a different question, you can ask it by clickingAsk Question. You can also add a bounty to draw more attention to this question once you have enough reputation. –
RiggsFollyJan 26 '15 at 18:38
2
Thanks @RiggsFolly, but this could actually, potentially, answer the question. –
RobbertJan 27 '15 at 8:03
1
@Sovtek - thanks for submitting your findings! I'll have a look at this solution later this week, when I continue work on the OpenCV project. If it does solve the issue for me, I'll mark your answer as Accepted. –
RobbertJan 27 '15 at 8:05
1
gave you a vote for the help(cv2.xfeatures2d). Worked for me. –
Yonatan SimsonMay 8 '17 at 11:53
Another possibility (and the easiest one I found!) is to install the 2.4.9 release which already include SIFT and SURF algorithm. You just have to do then
Thanks for chiming in Jprog. I did end up using 2.4 for now (2.4.10 actually). I won't mark this as an accepted answer though, as it does not solve the issue in OpenCV 3. –
RobbertJan 13 '15 at 9:16
Thanks @berak (you seem to answer all OpenCV questions I come across). I have triedxfeatures2d but it gives the same error - no such attribute - on both Python 2 and 3. It also doesn't explain why PyCharm is autocompleting correctly. –
RobbertSep 26 '14 at 12:23
can it be, you got 2 pythons in your box ? –
berakSep 26 '14 at 12:25
Correct, I have both Python 2.7 and 3.4, just to test which version works, since OpenCV 3 is still in alpha. Both are able to load OpenCV correctly (though I have to change EXPORTPATH accordingly) and call regular cv2 properties. –
RobbertSep 26 '14 at 12:28
PyCharm was probably picking up autocomplete from an older OpenCV installation, considering the new namespace in OpenCV 3. When I reload the modules in PyCharm, autocomplete no longer works. –
RobbertSep 26 '14 at 12:45
1
I've been dealing with this issue myself. It looks like xfeatures2d is flat-out broken in the alpha/beta releases. It's building properly (at least according to the build log), but the python API is not built at all. –
Fake NameNov 29 '14 at 0:26
https://stackoverflow.com/questions/26059134/adding-modules-from-opencv-contrib-to-opencvAdding modules from opencv_contrib to OpenCVI'm trying to add the xfeatures2d module from opencv_contrib to an ...