我的环境可以进行科学上网,编译的时候就不会出现各种下载错误~
1.安装依赖
sudo apt-get install -y libjpeg-dev libpng-dev libtiff5-dev libjasper-dev libdc1394-22-dev libeigen3-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev sphinx-common libtbb-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libopenexr-dev libgstreamer-plugins-base1.0-dev libavutil-dev libavfilter-dev libavresample-dev
sudo apt-get install -y build-essential cmake git libgtk2.0-dev libgtk-3-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
如果提示找不到libfaac-dev软件包
sudo apt-add-repository "deb http://us.archive.ubuntu.com/ubuntu trusty main multiverse"
sudo apt update
sudo apt install libjasper1 libjasper-dev
如果提示找不到libjasper-dev软件包
sudo apt-add-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev
2. 下载源码
cd ~/<my_working_directory> #my_working_directory是你保存opencv和opencv_contrib的文件夹
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
mv opencv_contrib/ opencv/ #将opencv_contrib移动到opencv目录里
3.编译
cd opencv
mkdir