Opencv安装

linux下openCV3.1 安装过程

准备

1. 更新系统

sudo apt-get update
sudo apt-get upgrade

2. 安装底包

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

3. 下载opencv3.1

1
2
3
4
#下载主题(Github)
git clone https://github.com/opencv/opencv.git
#下载扩展包
git clone https://github.com/opencv/opencv_contrib.git

安装

4.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 ..

其中会出现ippicv_2019_lnx_intel64_general_20180723.tgz无法下载导致的错误

ippicv下载地址

然后将文件放在../opencv-3.2.0/3rdparty/ippicv/downloads/linux-xx/文件夹下 重新Cmake

5.Build

make -j7 # runs 7 jobs in parallel

6.isntall

sudo make install

使用

C++编译时需添加如下命令,以链接openCV: pkg-config --cflags --libs opencv

点击刷新