cannot import xfeatures2d in OpenCV 3- Python binding
I am trying to access SIFT and SURF features from opencv 3 in python. As suggested by other people, I followed the installation of opencv_contrib. Some of the logs of the installation are:
[ 82%] Built target opencv_xfeatures2d
...
Installing: /usr/local/lib/libopencv_xfeatures2d.so
-- Set runtime path of "/usr/local/lib/libopencv_xfeatures2d.so.3.0.0" to "/usr/local/lib"
-- Installing: /usr/local/include/opencv2/xfeatures2d.hpp
-- Installing: /usr/local/include/opencv2/xfeatures2d/cuda.hpp
-- Installing: /usr/local/include/opencv2/xfeatures2d/nonfree.hpp
After that I import cv2 in python but could not import xfeatures2d.
>>> import cv2
>>> cv2.xfeatures2d.SIFT_create()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'xfeatures2d'
Also, cv2.__version__
gives '2.4.8'! How can I fix this?
this means, that opencv got built, and also the opencv_contrib parts, but maybe not the python wrappers. can you look again at the cmake output ? somewhere at the top is a list of enabled / disabled modules.
also, python version ? are there more than 1 python install on your box ?
@krips89: I guess, you have an opencv 2.4.8 version installed and your import cv2 still points to that, so you'd need to deinstall that and make sure your PYTHON_PATH points to the correct folder (containing the new cv2.so file). Please report back! In the near future I also want to migrate to OCV 3.0 (unfortunately currently too many features are still missing there which makes it barely usable for me)