OpenCV on Mac OSX Yosemite

From XPUB & Lens-Based wiki
Revision as of 16:22, 28 March 2015 by Ruben (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Installing OpenCV on OS X Yosemite (10.10)

update

Actually it turns out there is a much more easy way:

sudo port install opencv +python27

which handles all the pains...

I don't use the python from MacPorts by default but executing 'python2.7' instead of 'python' does the job ('/opt/local/bin/python2.7')

$ which python python2.7
/usr/bin/python
/opt/local/bin/python2.7

Old way of attempting it

Mainly thanks to this chap I was able to install OpenCV on my Mac Yosemite installation.

After using his walk trough I had the error when running some of the OpenCV samples:

AttributeError: 'module' object has no attribute 'CV_AA'

After some search it turned out to be the fact that OpenGL was not enabled. I had it checked, but for it to properly work QT should be enabled as well. So these are in the end the steps that should make it work:

  1. Download Cmake and drag to application directory.
  2. Download OpenCV beta zip and extract.
  3. Download MacPorts and install the qt5-mac package. (required for quite some nice examples)
  4. Go to the extracted folder of OpenCV and make a directory called StaticLibs
  5. Open Cmake 'Browse Source...' pick the path of the extracted zip 'Browse Build...' pick the newly created StaticLibs folder Hit 'Configure' (Default of 'Unix Makefiles' and 'Use default native compilers' is OK)
  6. Check:
    • WITH_QT
    • INSTALL_PYTHON_EXAMPLES (this definitely is optional)
  7. Uncheck:
    • BUILD_SHARED_LIBS
    • BUILD_TESTS
    • WITH_1394
  8. Fill in properly (some of these might already be filled in properly)
    • CMAKE_OSX_SYSROOT: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk (or another SDK path)
    • CMAKE_OSX_ARCHITECTURES: x86_64
    • QT_QMAKE_EXECUTABLE: /opt/local/bin/qmake (this is the qmake install from MacPorts) (??)
    • PYTHON2_EXECUTABLE: /usr/bin/python2.7
    • PYTHON2_PACKAGES_PATH: /Library/Python/2.7/site-packages
  9. Click Configure, then click Generate
  10. Open a terminal and type:
    • cd <path/to/your/opencv/staticlibs/folder/>
    • make (This will take awhile)
    • sudo make install