OpenCV on Mac OSX Yosemite: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "== Installing OpenCV on OS X Yosemite (10.10) == Mainly thanks to [http://blogs.wcode.org/2014/10/howto-install-build-and-use-opencv-macosx-10-10/ this chap] I was able to in...")
 
No edit summary
 
Line 1: Line 1:
== Installing OpenCV on OS X Yosemite (10.10) ==
== Installing OpenCV on OS X Yosemite (10.10) ==
=== update ===
Actually it turns out there is a much more easy way:
<source lang="bash">sudo port install opencv +python27</source>
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')
<source lang="bash">$ which python python2.7
/usr/bin/python
/opt/local/bin/python2.7</source>
=== Old way of attempting it ===


Mainly thanks to [http://blogs.wcode.org/2014/10/howto-install-build-and-use-opencv-macosx-10-10/ this chap] I was able to install OpenCV on my Mac Yosemite installation.
Mainly thanks to [http://blogs.wcode.org/2014/10/howto-install-build-and-use-opencv-macosx-10-10/ this chap] I was able to install OpenCV on my Mac Yosemite installation.
Line 10: Line 24:
# Download Cmake and drag to application directory.
# Download Cmake and drag to application directory.
# Download OpenCV beta zip and extract.
# Download OpenCV beta zip and extract.
# Download MacPorts and install the ''qt5-mac'' package.
# Download MacPorts and install the ''qt5-mac'' package. (required for quite some nice examples)
# Go to the extracted folder of OpenCV and make a directory called ''StaticLibs''
# Go to the extracted folder of OpenCV and make a directory called ''StaticLibs''
# Open Cmake 'Browse Source...' pick the path of the extracted zip 'Browse Build...' pick the newly created StaticLibs folder
# 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)
# Check:
# Check:
#* WITH_QT
#* WITH_QT
#* WITH_FFMPEG (I guess this is optional)
#* INSTALL_PYTHON_EXAMPLES (this definitely is optional)
#* INSTALL_PYTHON_EXAMPLES (this definitely is optional)
# Uncheck:
# Uncheck:
Line 24: Line 37:
#* CMAKE_OSX_SYSROOT: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk (or another SDK path)
#* 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
#* CMAKE_OSX_ARCHITECTURES: x86_64
#* QT_QMAKE_EXECUTABLE: /opt/local/bin/qmake (this is the qmake install from MacPorts)
#* QT_QMAKE_EXECUTABLE: /opt/local/bin/qmake (this is the qmake install from MacPorts) (??)
#* PYTHON2_EXECUTABLE: /usr/bin/python2.7
#* PYTHON2_EXECUTABLE: /usr/bin/python2.7
#* PYTHON2_PACKAGES_PATH: /Library/Python/2.7/site-packages
#* PYTHON2_PACKAGES_PATH: /Library/Python/2.7/site-packages
Line 32: Line 45:
#* make (This will take awhile)
#* make (This will take awhile)
#* sudo make install
#* sudo make install
Enjoy! R

Latest revision as of 16:22, 28 March 2015

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