Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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/
-- Set runtime path of "/usr/local/lib/" 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?