Fork me on GitHub

Ubuntu16.04安装OpenCV3.3教程

摘要:搭建OpenCV3.3的过程

安装依赖环境

1
2
3
4
5
6
7
$ sudo apt-get install build-essential libopencv-dev
$ 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 # 处理图像所需的包
$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev
$ sudo apt-get install libxvidcore-dev libx264-dev # 处理视频所需的包
$ sudo apt-get install libatlas-base-dev gfortran # 优化opencv功能
$ sudo apt-get install ffmpeg

获取源代码

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

编译源代码

1
2
3
4
5
6
7
8
9
$ cd opencv

$ mkdir build

$ cd build

$ cmake ..

$ make -j 10

替换旧版本

1
$ sudo make install

编译出错的处理

执行cmake的时候,可能会出现下面的错误信息:

1
2
3
4
5
6
7
8
9
10
CMake Error at CMakeLists.txt:11 (message):


FATAL: In-source builds are not allowed.

You should create separate directory for build files.



-- Configuring incomplete, errors occurred!

则是在代码根目录下直接执行过 cmake,导致根目录下生成了 CMakeCache.txt,需要删除 CMakeCache.txt再次执行编译即可。

-------------本文结束感谢阅读-------------