Installing OpenCV 3.0.0 with opencv_contribs on Mac OS X Yosemite for python, anaconda, ipython notebooks, and jupyter 

Installing OpenCV is easy unless you want Version 3 (currently 3.0.0) with opencv_contribs for Python on Mac OS X (Yosemite).
If you don’t want any of this, brew is your friend. But if you do you have to build it from scratch and that seems virtually impossible in some cases.
Even though I’m a computer scientist, I’m not a systems level person and try to stay away from low-level installs where I can. However, I need OpenCV 3, so there was no choice. It cost me a few days of my life that I’ll never get back, but I finally I got it to work thanks to all the information that is on the web.
There are (at last) two very good installation tutorials on the web that may work for you:
I first followed the one on pyimagesearch for a few days and tried to resolve the problems I had with it, but ultimately gave up (despite its author very generously trying to help). The second one (with a minor modification) led to the solution.
My main problem seemed to be with the Eigen library (linear Algebra). In various blog posts I noticed that a number of others had the same problem. If you have the same problem, you will encounter this error during the main build phase (make):
/Users/bernd/opencv_contrib/modules/rgbd/src/odometry.cpp:41:10: fatal error: 
      'unsupported/Eigen/MatrixFunctions' file not found
#include <unsupported/Eigen/MatrixFunctions>
This error persisted, despite installing and reinstalling Eigen (via brew). In the end it turned out that the compilation was not even using the brew installation of Eigen, but probably another broken one that is hanging around somewhere on my system, unbeknownst to me. I think this is the case, because some but not all (!) Eigen files where found during the compilation. Those that were found were not the ones in the brew installation (because I could rename these without any change).
This problem was the same regardless which installation instructions I was following.
Ultimately I decided to switch Eigen support off and compile without it. Arguably not the most elegant solution, but elegance can wait for a while. For now i need it to work. This solved the problem with the learnopencv tutorial, but produced a new, different set of problems with the pyimagesearch tutorial.
So here is the procedure that worked for me.
  • follow the instructions in this blog entry:
  • if you run into trouble with this error:  ‘unsupported/Eigen/MatrixFunctions’ file not found start over with cmake but this time add the option
    -D WITH_EIGEN=OFF to the cmake options
  • Add the following line to your ~/.bash_profile as the last line (assuming your opencv build was done in ~/opencv/build) :
    export  DYLD_LIBRARY_PATH= ~/opencv/build/lib:$DYLD_LIBRARY_PATH
  • this worked for me for python 2.7 (brew installation), anaconda python 2.7 and iPython notebooks
  • If you use the Pycharm IDE (highly recommended) you will also have to set DYLD_LIBRARY_PATH=~/opencv/build/lib in the runtime configuration within Pycharm
Good luck and thanks to all the good folks who posted about this before me, specifically Satya Mallick and Adrian Rosenbrock who created the tutorials listed above. Even tough my final solution seems fairly straight forward, it was a long, meandering path to get there. All the information on the web helped a lot!