这里主要对openCV官网的《Installation in Linux》文档进行了翻译和解释
原文见:https://docs.opencv.org/3.4.1/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation
Required Packages(需求包)
GCC 4.4.x or later
CMake 2.6 or higher
Git
GTK+2.x or higher, including headers (libgtk2.0-dev)
pkg-config
Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy)
ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev
[optional] libtbb2 libtbb-dev
[optional] libdc1394 2.x
[optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev, libdc1394-22-dev
需要的命令,官网也提供了:
[compiler] sudo apt-get install build-essential
[required]sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
[optional]sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
第一行是编译器,第二行是必须包,第三号是可选的
第二步是下载源码,包括GIT和.zip包下载,zip源码链接为:http://github.com/opencv/opencv
解压后,切换到源码目录
新建build目录
mkdirbuild
cd ./build
使用cmake生成Makefile文件
#如果要支持Python3接口的话,就PYTHON_DEFAULT_EXECUTABLE=$(whichpython3),否则可以不写这个
cmake-D CMAKE_BUILD_TYPE=RELEASE -D PYTHON_DEFAULT_EXECUTABLE=$(which python3) CMAKE_INSTALL_PREFIX=/usr/local ..
然后就是make和make install
make -j8
sudo make install
安装后的测试,请见下一节