整理自http://blog.csdn.net/yehuohan/article/details/51327465
1、安裝依賴庫
sudo apt-get install build-essential
# 必須的,gcc編譯環境
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
# 必須的,包括cmake等工具
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
# 可選的,看個人需要,總共5M左右
2、從官網下載 源碼 在官網下載:http://opencv.org/downloads.html 或著用git clone:
cd ~/opencv310
# opencv310為自己建的,源碼將放在這裏
git clone https://github.com/Itseez/opencv.git
git clone https://github.com/Itseez/opencv_contrib.git
3、cmake 解壓opencv-3.1.0.zip
cd opencv-3.1.0
mkdir build
cmake時ippicv_linux_20151201.tgz總是不能成功下載,故cmake之前將 ./downloads/linux-808b791a6eac9ed78d32a7666804320e 文件拷貝至 ./opencv-3.1.0/3rdparty/ippicv/ 路徑下 (先執行一次cmake 命令生成文件路徑,在將ippicv_linux_20151201.tgz複制進去) ippicv_linux_20151201.tgz下載鏈接: https://pan.baidu.com/s/1hWwR8VtHRwKNRmOilskmwA 密碼: kvdz
cd opencv-3.1.0/build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
# 生成後的Makefile在build文件夾中,而需要的CMakeLists.txt在 ".."中,即上一級文件夾中(opencv-3.1.0)
如果要安裝包含opencv_contrib模塊的,則執行以下語句: 把opencv_contrib-master.zip放在opencv-3.1.0下,解壓
cd opencv-3.1.0/build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-master/modules/ ..
# “../opencv_contrib-master/modules/是opencv_contrib-master解壓後的路徑
4、安裝opencv 在opencv3.1.0/build下
# 4個線程編譯,查看cpu核數量
# grep "model name" /proc/cpuinfo | wc -l
make -j4
# 安裝
sudo make install
測試安裝是否成功,查看這篇: ubuntu opencv3.1 編譯demo報錯 http://blog.csdn.net/u011440558/article/details/78213796
ubuntu 14.04 64位安裝Opencv3.1.0+包含opencv_contrib模塊
解決辦法: 在opencv-3.1.0/modules/python/common.cmake首行添加如下代碼:
find_package(HDF5)
include_directories(${HDF5_INCLUDE_DIRS})
OK… 參考:https://github.com/opencv/opencv/issues/6016
opencv添加軟連接到virtualenv環境
參考http://blog.csdn.net/isuker/article/details/52459992
安裝pip和virtualenv:
sudo apt-get install python-pip python-dev python-virtualenv
創建 Virtualenv 虛擬環境:
virtualenv no-site-packages seg-env
ln -s /usr/local/lib/python2.7/dist-packages/cv2.so /home/ly/seg-env/lib/python2.7/site-packages
OK…
Ubuntu14.04 64位+Python3.4環境下安裝opencv3.0的方法
http://blog.csdn.net/qingyuanluofeng/article/details/51558270
opencv3.2在安裝CUDA後cmake報錯:
參考:https://blog.csdn.net/CV_YOU/article/details/79950671 打開opencv文件下面的CMakelis.txt文件,將裏面有關cuda選項都調為OFF(然後將有cuda有關的判斷操作給注釋了)。
cmake -D WITH_LAPACK=OFF -D CMAKE_BUILD_TYPE=RELEASE -D WITH_TBB=ON -D BUILD_opencv_gpu=OFF -D CUDA_GENERATION=Kepler -D WITH_V4L=ON -D CUDA_ARCH_BIN=6.1 -D CUDA_ARCH_PTX=6.1 -D CMAKE_INSTALL_PREFIX=/usr/local/opencv320 ..
卸載opencv
卸載opencv3.1.0: Going to the "build" folder directory of opencv from terminal, and execute the following:
1. $ sudo make uninstall
2. $ cd ..
3. $ sudo rm -r build
4. $ sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*
5. sudo apt-get –purge remove opencv-doc opencv-data python-opencv