$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install build-essential cmake pkg-config
$ sudo apt-get install libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev
$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
$ sudo apt-get install libxvidcore-dev libx264-dev
$ sudo apt-get install libgtk-3-dev
$ sudo apt-get install libatlas-base-dev gfortran
$ sudo apt-get install python2.7-dev python3.5-dev
OpenCV官网上有linux版本的源码包可以下载,不过最好是从git上下载,这样可以保证下载得到的是最新的代码:
wget -O opencv.zip [https://github.com/Itseez/opencv/archive/3.2.0.zip](https://github.com/Itseez/opencv/archive/3.2.0.zip)
unzip opencv.zip
进入到OpenCV的文件夹中,创建一个build目录,进行编译:
cd opencv-3.2.0
mkdir build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -4j
sudo make install
python
>>>import cv2
>>>cv2.__version_
'3.2.0'
“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill
标 题:linux安装opencv