文章

Ubuntu 安装 OpenCV

依赖项安装

1
2
3
4
5
6
7
8
9
10
sudo apt-get update  
sudo apt-get install -y build-essential cmake pkg-config  
sudo apt-get install -y libjpeg-dev libpng-dev libtiff-dev  
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libv4l-dev  
sudo apt-get install -y libxvidcore-dev libx264-dev  
sudo apt-get install -y libgtk2.0-dev libgtk-3-dev  
sudo apt-get install -y libatlas-base-dev gfortran  
sudo apt-get install -y python3-dev python3-numpy  
sudo apt-get install -y libtbb2 libtbb-dev libdc1394-22-dev  
sudo apt-get install -y libopencv-dev

下载 OpenCV 源码

1
2
3
4
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git  

# opencv opencv_contrib 检出同一个版本

编译 OpenCV

cmake配置过程中,需要下载依赖包。设置代理:

1
2
export http_proxy=http://192.168.9.165:10809
export https_proxy=http://192.168.9.165:10809
  1. 编译选项OPENCV_EXTRA_MODULES_PATH设置extra模块路径:~/tmp/opencv/opencv_contrib/modules
  2. OpenCV还依赖其他第三方库:TBB、Eigen、VTK 等。可以先安装上。

参考

本文由作者按照 CC BY 4.0 进行授权