I wanted to use AKAZE, so I installed opencv3. I have python2.7.10 installed with pyenv. Please change to your own version where it is 2.7.10 below.
numpy
Install everything you think you need
$ sudo apt-get -y install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff4-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip
I was angry if I didn't have the authority, so
$ sudo chmod -R 777 /home/ubuntu/.pyenv/versions/2.7.10/lib/python2.7/site-packages/
I wanted to put numpy1.8 Install by specifying the version of numpy
$ pip install numpy==1.8
opencv Return the python version to system. I installed it without returning it and suffered a lot. No matter how hard you try, you will not be able to find cv2.so that will appear later.
$ pyenv global system
opencv3 installation
$ mkdir opencv
$ cd opencv
$ wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/3.0.0/opencv-3.0.0.zip
$ unzip opencv-3.0.0.zip
$ cd opencv-3.0.0/
$ mkdir build
$ cd build
$ make -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_opencv_java=OFF -D WITH_IPP=OFF -D WITH_1394=OFF -D WITH_FFMPEG=OFF -D BUILD_EXAMPLES=OFF -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_DOCS=OFF -D BUILD_opencv_python2=ON -D BUILD_opencv_python3=ON -D BUILD_opencv_video=OFF -D BUILD_opencv_videoio=OFF -D BUILD_opencv_videostab=OFF -D PYTHON_EXECUTABLE=$(which python) ..
$ make
$ sudo make install
You should now have something called cv2.so somewhere.
$ sudo find / -name cv2.so
I'll copy what I find so that python can read it.
$ sudo cp /home/ubuntu/opencv/opencv-3.0.0/build/lib/cv2.so /home/ubuntu/.pyenv/versions/2.7.10/lib/python2.7/site-packages/
Revert the python version.
$ pyenv global 2.7.10
Make sure you can import cv2.
$ python
>> import cv2
If there are no errors, it is successful.
Recommended Posts