Copying the instructions from my awesome robotics professor Paul Ruvolo from here so I don’t lose these steps:
To install OpenCV, go ahead and type each of these steps into your terminal window. Note that the “make” step will take forever, so go grab some popcorn or tea once you get there.
$ wget https://github.com/Itseez/opencv/archive/2.4.11.zip
$ unzip 2.4.11.zip
$ cd opencv-2.4.11
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_BUILD_TYPE=RELEASE \
$ make -j2
$ sudo make install
In a nutshell, we download OpenCV 2.4 to the temporary folder, build it, make with two CPU cores, then install. It seems like those cmake parameters are actually pretty important to get stuff working!