Ubuntu 安装 opencv2.4.9

安装工具

sudo apt-get install git
sudo apt-get install g++
sudo apt-get install vim

下载Opencv

opencv2.9

解压

unzip opencv-2.4.9.zip
cd opencv-2.4.9
mkdir release

安装依赖库

sudo apt-get install build-essential cmake libgtk2.0-dev pkg-config python-dev python-numpy libavcodec-dev libavformat-dev libswscale-dev  

在opencv的官方文档也有说明:

  1. GCC 4.4.x or later. This can be installed with:sudo apt-get install build-essential
  2. CMake 2.6 or higher;
  3. Git;
  4. GTK+2.x or higher, including headers (libgtk2.0-dev);
  5. pkg-config;
  6. Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy);
  7. ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev;
  8. [optional] libdc1394 2.x;
  9. [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev.
    ff-dev, libjasper-dev.

进入目录生成MakeFile文件

cd releaase

安装所有的lib文件都会被安装到/usr/local目录下

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
  • 如果遇到Unsupported gpu architecture 'compute_11'的错误,解决方法为:
  • cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D CUDA_GENERATION=Kepler ..
  • (参考:http://blog.csdn.net/sysuwuhongpeng/article/details/45485719)

Ubuntu 安装 opencv2.4.9_第1张图片

构建和安装

make

出现的问题(1):/home/lingck/opencv-2.4.9/modules/gpu/src/nvidia/core/NCVPixelOperations.hpp(129): error: a storage class is not allowed in an explicit specialization

 解决办法:http://download.csdn.net/download/solomon1558/9581114这个地址下载NCVPixelOperations.hpp文件替换掉opencv文件夹中的源文件即可

出现的问题(2):make[2]: *** [modules/gpu/CMakeFiles/opencv_gpu.dir/src/graphcuts.cpp.o] 错误 1

  解决办法:打开graphcuts.cpp文件,修改graphcuts.cpp里面的

#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) 
为:

#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000)

Ubuntu 安装 opencv2.4.9_第2张图片

make install

Ubuntu 安装 opencv2.4.9_第3张图片

加载动态连接库

sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'

sudo ldconfi

你可能感兴趣的:(Ubuntu 安装 opencv2.4.9)