I need Open CV to do some image processing and visualization. Open CV seems to be an equivalent of Matlab "Image Processing Toolbox". However, it turns out that it's a huge headache to install Open CV 3 in Anaconda Python 3.6 environment due to the dependency issues. After extensive web search I found
this site. I tested it in my MacBookAir and it seems to be working well.
1. Setup
Linux
$ sudo apt install gcc g++ git libjpeg-dev libpng-dev libtiff5-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev pkg-config cmake libgtk2.0-dev libeigen3-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev sphinx-common libtbb-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libopenexr-dev libgstreamer-plugins-base1.0-dev libavcodec-dev libavutil-dev libavfilter-dev libavformat-dev libavresample-dev
OSX
$ brew install git cmake pkg-config jpeg libpng libtiff openexr eigen tbb
2. Download OpenCV (http://opencv.org/)
$ cd ~/Downloads
$ unzip opencv-3.2.0.zip
$ cd opencv-3.2.0
3. Cmake configuration: OpenCV for Python 3
$ mkdir release
$ cd release
$ sudo cmake -DBUILD_TIFF=ON -DBUILD_opencv_java=OFF -DWITH_CUDA=OFF -DENABLE_AVX=ON -DWITH_OPENGL=ON -DWITH_OPENCL=ON -DWITH_IPP=OFF -DWITH_TBB=ON -DWITH_EIGEN=ON -DWITH_V4L=ON -DWITH_VTK=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_opencv_python2=OFF -DCMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") -DPYTHON3_EXECUTABLE=$(which python3) -DPYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") -DPYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") ..
4. Compile and install OpenCV source
$ sudo make -j4
$ sudo make install
5. Fix a couple of things (for Linux only)
$ mv libstdc++.so.6 libstdc++.so.6.bak
$ mv libgomp.so.1 libgomp.so.1.bak
6. Test installation
$ python3
>>> import cv2
>>>