Ubuntu16.04下安装OpenCV

一、系统环境

Ubuntu:16.04

Linux kernel:4.4.0-130-generic

gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11) 

二、OpenCV3.0.0安装

解决环境依赖

       根据官网安装的教程 https://docs.opencv.org/trunk/d7/d9f/tutorial_linux_install.html,选择3.0.0版本的安装教程,官网给出要求的依赖包为

Required Packages

  • GCC 4.4.x or later
  • CMake 2.8.7 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

依次系统的配置是否满足要求(主要是GCC是否满足),其余依赖包使用如下命令安装:

 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

 获取OpenCV源码与编译安装

cd ~/
wget https://github.com/Itseez/opencv/archive/3.0.0-beta.zip
git clone https://github.com/Itseez/opencv_contrib.git

查看opencv和opencv_contrib两个文件夹大小

vslyu@vslyu-Lenovo-G510:/media/vslyu$ du -sh opencv-3.0.0-beta/
185M	opencv-3.0.0-beta/
vslyu@vslyu-Lenovo-G510:/media/vslyu$ du -sh opencv_contrib/
231M	opencv_contrib/

保证 opencv 文件夹所挂载的磁盘剩余空间大小在6GiB以上,进入opencv文件夹:

cd ~/opencv
mkdir build
cd build

 在build文件下输入如下指令配置CMakeLists.txt文件:

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..

等待配置完成后,开始编译:

你可能感兴趣的:(Ubuntu,OpenCV,OpenCV)