1.编译环境安装:
sudo apt-get install build-essential
2.必需安装包:
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
3.可选安装包(建议安装):
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
4.下载OpenCV3.1.0:
wget https://github.com/Itseez/opencv/archive/3.1.0.zip
或者
git clone git://github.com/Itseez/opencv.git
5.安装OpenCV3.1.0:
cd ~/opencv-3.1.0
mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j7 && sudo make install
6.安装OpenCV3.1.0的可能错误:
(1)如果安装了cuda8.0,可能会报错,报错内容如下:
opencv3.1.0/modules/cudalegacy/src/graphcuts.cpp:274:146:error....
在其他文件也可能出现类似的错误。出现错误的地方在cuda上。解决方案是找到opencv3.1.0/modules/cudalegacy/src/graphcuts.cpp文件,将下面的一行:
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
改为
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION>=8000)
(2)如果报这样的Warning:
Unsupported gpu architecture 'compute_11'
可以忽略,或者在编译的时候:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D CUDA_GENERATION=Kepler ..