linux下openCV3.1安装过程

准备

参考openCV3.1官方安装指导

  1. 更新系统
sudo apt-get update
sudo apt-get upgrade
  1. 安装底包
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
  1. 下载openCV3.1
cd ~/<此处替换为下载目录>

下载主体(github链接):

git clone https://github.com/opencv/opencv.git

下载扩展包(github链接)(可选):

git clone https://github.com/opencv/opencv_contrib.git

安装

  1. Cmake
cd ~/opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..

若安装扩展包,则还需运行:

cmake -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..
  1. Build
make -j7 # runs 7 jobs in parallel

至此安装完成!

使用

C++编译时需添加如下命令,以链接openCV:

`pkg-config --cflags --libs opencv`

如:

g++ test.cpp `pkg-config --cflags --libs opencv` -o test

你可能感兴趣的:(linux下openCV3.1安装过程)