Compiling OpenCV on Snow Leopard

by Mike 11. November 2009 00:48
After spending too much time pulling my hair out trying to compile OpenCV 2.0 on Snow Leopard, I thought I'd share what finally worked for me (well, mostly.)

NOTE: I'm just learning about OpenCV as a whole so these instructions may not work for your needs.

  1. Pull the latest OpenCV from svn (build 2275 was version used at the time):

    • svn co http://opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/trunk opencv
    • cd opencv/opencv
  2. Create & move to the build directory

    • mkdir build
    • cd build
  3. Base configuration - run 'cmake ..'
  4. Specific Configuration - run 'ccmake .'
  5. Press 't' to toggle advanced mode on
  6. Change CMAKE_CXX_COMPILER to '/usr/bin/g++-4.0'
  7. Change CMAKE_C_COMPILER to '/usr/bin/gcc-4.0'

    Make sure to disable FFMPEG support (note, this may cause issues for some people, but this was the only way I could make this work.) You may also want to build the examples and look at some other options.

  8. Press 'c' to run the configure, then 'g' to generate the configuration. You may receive a message about needing to redo the ccmake as the CMAKE*COMPILER lines were changed. This is ok, just make sure the FFMPEG support is disabled.
  9. Run 'make -j8'

    Once finished, this should give you working binaries in the /bin folder. You may want to test these before installing. NOTE: I have not yet gotten a full 'make test' to return all results passed.

  10. If desired, install the code with 'sudo make install'

Of course, once I got this working I haven't had much time to play with it. But the facedetection program and several of the other examples work as expected on my MBP. One other note, if by chance you use my EyePatch program, make sure the camera is actually enabled or things won't work.

Tags:

Comments

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen