0

I'm trying to install OpenCV 3.1.0 for Python from source on OSX following this article. Long story short, I'm at the point of creating the make file using the following declarations:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local 
-D PYTHON2_PACKAGES_PATH=~/.virtualenvs/cv/lib/python2.7/site-packages 
-D PYTHON2_LIBRARY=/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin 
-D PYTHON2_INCLUDE_DIR=/usr/local/Frameworks/Python.framework/Headers 
-D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=ON 
-D BUILD_EXAMPELS=ON 
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..

The resultant build information I get includes this:

    --   OpenCV modules:
    --     To be built:                 core flann imgproc ml photo reg
 surface_matching video dnn fuzzy imgcodecs shape videoio highgui objdetect plot
 superres ts xobjdetect xphoto bgsegm bioinspired dpm face features2d
 line_descriptor saliency text calib3d ccalib datasets rgbd stereo
 structured_light tracking videostab xfeatures2d ximgproc aruco optflow
 stitching python2
    --     Disabled:                    world contrib_world
    --     Disabled by dependency:      -
    --     Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java python3 viz cvv hdf matlab sfm

Most notably: xfeatures2d

I then run make -j4 and then sudo make install to install the compiled OpenCV 3.1.0 package. The output includes:

-- Installing: /usr/local/lib/libopencv_xfeatures2d.3.1.0.dylib
-- Up-to-date: /usr/local/lib/libopencv_xfeatures2d.3.1.dylib
-- Up-to-date: /usr/local/lib/libopencv_xfeatures2d.dylib
-- Up-to-date: /usr/local/include/opencv2/xfeatures2d.hpp
-- Up-to-date: /usr/local/include/opencv2/xfeatures2d/cuda.hpp
-- Up-to-date: /usr/local/include/opencv2/xfeatures2d/nonfree.hpp

Immediately after, I run python for the interpreter, then import cv, cv2.xfeatures2d and get:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'xfeatures2d'

I don't understand why the extra packages added by opencv-contrib aren't being included in the installation. cmake says they're being included, but they aren't.

5
  • 1
    Try using cmake_gui. That way you'll actually be able to change things dynamically without having to edit huge commands manually. Also, did you test to see if any of the other contrib modules work? Were there any errors during building?
    – MattDMo
    May 7, 2016 at 23:04
  • @MattDMo None of the other contrib modules work. All of their dylib files can be found in my /usr/local/lib folder. I don't recall seeing any errors during building, but it seems that some linking error has occurred. I'll try graphical cmake and report back. May 7, 2016 at 23:08
  • @MattDMo Yeah, that didn't really do anything. May 7, 2016 at 23:23
  • I actually don't recall if I ever got contrib to build on OS X. It was a couple of years ago that I last tried, then gave up and used the MacPorts version. It doesn't include contrib that I recall, but it's (relatively) easy to install if you have a good developer system set up already, otherwise it'll take forever to install all the prerequisites. Sorry I can't help further - good luck!
    – MattDMo
    May 8, 2016 at 1:42
  • @MattDMo Thanks for trying! I guess I'll just have to do it on my Linux machine.
    – Zulfe
    May 8, 2016 at 14:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.