@yanbo01haomiao
2020-07-21T18:45:51.000000Z
字数 1720
阅读 880
记录
1.gitclone下载源码到工作空间,直接拉取最新的版本即可
git clone https://github.com/opencv/opencv.git
或者在官方release中下载source,这样比较快。
可选安装opencv_contrib
git clone https://github.com/opencv/opencv_contrib.git
2.更新
sudo apt-get update
sudo apt-get upgrade
网上的预安装方法是命令安装二进制版本的opencv然后卸掉,之后在使用源码安装。
这里一次性安装依赖项:这里如果是18环境请看参考文章第二篇,我的环境为ubuntu16。请按照自己的环境安装。
# 移除系统中已存在的依赖
sudo apt-get remove x264 libx264-dev
# 安装需要依赖
sudo apt-get install build-essential checkinstall cmake pkg-config yasm
sudo apt-get install git gfortran
sudo apt-get install libjpeg8-dev libjasper-dev libpng12-dev
# 下面根据版本选择安装
# Ubuntu 14.04
sudo apt-get install libtiff4-dev
# Ubuntu 16.04
sudo apt-get install libtiff5-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev
sudo apt-get install libxine2-dev libv4l-dev
sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
sudo apt-get install qt5-default libgtk2.0-dev libtbb-dev
sudo apt-get install libatlas-base-dev
sudo apt-get install libfaac-dev libmp3lame-dev libtheora-dev
sudo apt-get install libvorbis-dev libxvidcore-dev
sudo apt-get install libopencore-amrnb-dev libopencore-amrwb-dev
sudo apt-get install x264 v4l-utils
# 可选安装
sudo apt-get install libprotobuf-dev protobuf-compiler
sudo apt-get install libgoogle-glog-dev libgflags-dev
sudo apt-get install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen
下载完成进入目录建立一个新的目录mkdir build, 进入build目录,执行cmake ..
mkdir build
cd build
cmake ..
make
sudo make install
这一步如果出现问题,说明有依赖项没有安装完全。
3.遇到问题:
如果在make过程中出现
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
需要删除编译环境中的所有文件,重复第2步即可。
参考文章:
1.opencv3安装
https://www.learnopencv.com/install-opencv3-on-ubuntu/
2.opencv4在ubuntu18.04中安装
https://www.learnopencv.com/install-opencv-4-on-ubuntu-18-04/
3.opencv3.4.4在ubuntu18.04中安装
https://www.learnopencv.com/install-opencv-3-4-4-on-ubuntu-18-04/