目录
一、准备工作
1、提前预装的库
2、预装库过程中遇到的问题
二、opencv_contrib安装
三、gflags安装
三、opencv安装
四、ARPACK 、 ARPACK++ 、 LAPACK安装
五、opencv版本查询
注意:OpenCV与OpenCV_Contrib版本要一致!
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
Ubuntu18.04无法定位libjasper-dev的解决办法
解决方法一:大部分回答都是添加下面的源
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev
还有回答查询是否有系统架构冲突的
dpkg --print-foreign-architectures
解决方法二:
sudo add-apt-repository "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe"
sudo apt update
sudo apt install libjasper1 libjasper-dev
特征点检测,当用SIFT检测器的时候,需要一个叫【opencv_contrib】的包,而且opencv_contrib的版本还要和OpenCV的版本相同。
地址:GitHub - opencv/opencv_contrib: Repository for OpenCV's extra modules
githup地址:GitHub - opencv/opencv_contrib: Repository for OpenCV's extra modules
https://github.com/opencv/opencv_contrib
安装gflags库是由于在opencv编译过程中报错,所以对其安装;
githup地址:https://github.com/gflags/gflags
git clone https://github.com/gflags/gflags.git
进入clone后的gflags目录,在此目录中创建build目录
mkdir build
在build目录下执行
cmake ..
执行make 编译
make
执行安装命令
make install
githup网址:https://github.com/opencv/opencv/tree/3.4
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules/ ..
~/opencv_contrib/modules/是opencv_contrib的目录,替换成自己的。
由于opencv和opencv_contrib版本虽然都是3.4的,但是opencv是3.4.10和opencv_contrib3.4有区别,所以报错,报错信息:error: sift' has not been declared return sift::create();
解决方法:重新下载opencv3.4版本,此报错解决;
源码编译opencv卡在IPPICV:ippicv_2020_lnx_intel64_20191018_general.tgz
下载地址:https://github.com/opencv/opencv_3rdparty/blob/ippicv/master_20191018/ippicv/ippicv_2020_lnx_intel64_20191018_general.tgz
保存路径我放在opencv主目录下;
修改opencv里相关配置文件:ippicv.cmake
opencv源码主目录下:
vi 3rdparty/ippicv/ippicv.cmake
修改(大约47行):
"https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_COMMIT}/ippicv/"
为手动下载的文件的本地路径:
"file:///home/opencv/source/" #(根据自己的路径填写)
重新cmake;
opencv编译安装
make -j8
sudo make install
sudo apt-get install liblapack-dev
sudo apt-get install libarpack2-dev
sudo apt-get install libarpack++2-dev
pkg-config --modversion opencv