$ sudo apt-get update $ sudo apt-get upgrade $ sudo rpi-update $ sudo reboot
$ sudo apt-get install build-essential git cmake pkg-config $ sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev $ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev $ sudo apt-get install libxvidcore-dev libx264-dev $ sudo apt-get install libgtk2.0-dev $ sudo apt-get install libatlas-base-dev gfortran
$ sudo apt-get install python2.7-dev python3-dev $ wget https://bootstrap.pypa.io/get-pip.py $ sudo python get-pip.py $ pip install numpy
$ wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.1.0.zip $ unzip 3.1.0.zip $ wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.1.0.zip $ unzip opencv_contrib.zip
$ cd opencv-3.1.0 $ mkdir build $ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=<OpenCV Contrib Path>/modules -D BUILD_EXAMPLES=ON ..
Example
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=~/vendor/opencv_contrib-3.1.0/modules -D BUILD_EXAMPLES=ON ..
If compilation terminated successfully, you will see something like the following standard out.
-- Python 2: -- Interpreter: /usr/bin/python2.7 (ver 2.7.3) -- Libraries: /usr/lib/libpython2.7.so (ver 2.7.3) -- numpy: /usr/lib/pymodules/python2.7/numpy/core/incl ude (ver 1.6.2) -- packages path: lib/python2.7/dist-packages -- -- Python 3: -- Interpreter: /usr/bin/python3 (ver 3.2.3) -- Libraries: /usr/lib/libpython3.2mu.so (ver 3.2.3) -- numpy: /usr/lib/python3/dist-packages/numpy/core/in clude (ver 1.6.2) -- packages path: lib/python3.2/dist-packages
$ make -j4 $ sudo make install $ sudo ldconfig
Then you can see if OpenCV has been installed successfully with the following command.
$ python >>> import cv2 >>> cv2.__version__ '3.1.0'
S.Yatsuzuka