Ubuntu 16.04 LTS 安装OpenCV3.2

前端之家收集整理的这篇文章主要介绍了Ubuntu 16.04 LTS 安装OpenCV3.2前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

实不相瞒,折腾opencv真是要了我电脑的老命,google了一大圈终于找到了一个及其省事的方法,就是使用github上的脚本,简直一键安装啊,真是感谢作者啊,我这里放出原链接OpenCV3.2一键安装脚本

如果大家不想麻烦的的话我把它复制过来了,还把里面的apt-get换成了apt,这个其实没什么大区别,就是多了个进度条,官方推荐使用apt来代替apt-get,我的这个需要大家提前安装好Java环境。

使用的话就是新建一个install.sh文件,把下面的这些复制进去,保存,加执行权限chmod u+x install.sh,再sudo ./install.sh就可以自动安装了,这个是从源码安装的所以时间可能会比较长。

#!/bin/bash
#NSTALL OPENCV ON UBUNTU OR DEBIAN #
######################################

# | THIS SCRIPT IS TESTED CORRECTLY ON |
# |----------------------------------------------------|
# | OS | OpenCV | Test | Last test |
# |----------------|--------------|------|-------------|
# | Ubuntu 16.04.2 | OpenCV 3.2.0 | OK | 20 May 2017 |
# | Debian 8.8 | OpenCV 3.2.0 | OK | 20 May 2017 |
# | Debian 9.0 | OpenCV 3.2.0 | OK | 25 Jun 2017 |

# 1. KEEP UBUNTU OR DEBIAN UP TO DATE

sudo apt -y update
sudo apt -y upgrade
sudo apt -y dist-upgrade
sudo apt -y autoremove


# 2. INSTALL THE DEPENDENCIES

# Build tools:
sudo apt install -y build-essential cmake

# GUI (if you want to use GTK instead of Qt,replace 'qt5-default' with 'libgtkglext1-dev' and remove '-DWITH_QT=ON' option in CMake):
sudo apt install -y qt5-default libvtk6-dev

# Media I/O:
sudo apt install -y zlib1g-dev libjpeg-dev libwebp-dev libpng-dev libtiff5-dev libjasper-dev libopenexr-dev libgdal-dev

# Video I/O:
sudo apt install -y libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev yasm libopencore-amrnb-dev libopencore-amrwb-dev libv4l-dev libxine2-dev

# Parallelism and linear algebra libraries:
sudo apt install -y libtbb-dev libeigen3-dev

# Python:
sudo apt install -y python-dev python-tk python-numpy python3-dev python3-tk python3-numpy

# Java:
# 我的就这里和原来的不太一样,因为我的电脑原来安装了Java的环境了
# sudo apt install -y ant default-jdk 
# Documentation:
sudo apt install -y doxygen


# 3. INSTALL THE LIBRARY (YOU CAN CHANGE '3.2.0' FOR THE LAST STABLE VERSION)

sudo apt install -y unzip wget
wget https://github.com/opencv/opencv/archive/3.2.0.zip
unzip 3.2.0.zip
rm 3.2.0.zip
mv opencv-3.2.0 OpenCV
cd OpenCV
mkdir build
cd build
cmake -DWITH_QT=ON -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DBUILD_EXAMPLES=ON -DENABLE_PRECOMPILED_HEADERS=OFF ..
make -j4
sudo make install
sudo ldconfig


# 4. EXECUTE SOME OPENCV EXAMPLES AND COMPILE A DEMONSTRATION

# To complete this step,please visit 'http://milq.github.io/install-opencv-ubuntu-debian'.
原文链接:https://www.f2er.com/ubuntu/351619.html

猜你在找的Ubuntu相关文章