编译器版本:c++11
cmake版本:3.5.1
选择:Linux x86_64 cmake-3.14.1-Linux-x86_64.sh
将cmake-3.14.1-Linux-x86_64.sh拷贝考ubuntu中,执行该脚本;
按下空格键,直到出现授权提示,输入y,回车;
选择安装目录,输入y,回车(如果输入n,则不会创建带有版本信息的子目录)
参考博客:
https://blog.csdn.net/luteresa/article/details/79916064
下载地址
opencv4:https://github.com/opencv
opencv_contrib:https://github.com/opencv/opencv_contrib/tags
sudo apt-get install build-essential pkg-config
sudo apt-get install libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev
sudo apt-get install libgtk-3-dev
sudo apt-get install libatlas-base-dev gfortran
参考博客:https://blog.csdn.net/ivan_ljf/article/details/59479566
下载源码:git clone git://github.com/xianyi/OpenBLAS
安装gfortran: sudo apt-get install gfortran
编译:make FC=gfortran
安装:sudo make install (将OpenBLAS安装到/opt下)
执行以下命令完成安装
sudo ln -s /opt/OpenBLAS/lib/libopenblas.so /usr/lib/libblas.so.3
sudo ln -s /opt/OpenBLAS/lib/liblapack.so.3 /usr/lib/liblapack.so.3
sudo rm /usr/lib/libblas.so.3
sudo rm /usr/lib/liblapack.so.3
sudo ln -s /etc/alternatives/libblas.so.3 /usr/lib/libblas.so.3
sudo ln -s /etc/alternatives/liblapack.so.3 /usr/lib/liblapack.so.3
/usr/lib$ ls libblas.so.3 -alh
lrwxrwxrwx 1 root root 30 7月 30 2018 libblas.so.3 -> /etc/alternatives/libblas.so.3
zet@zet-VirtualBox:/usr/lib$ ls liblapack.so.3 -alh
lrwxrwxrwx 1 root root 32 7月 30 2018 liblapack.so.3 -> /etc/alternatives/liblapack.so.3
添加源码目录
添加编译目录
点击【Configure】后配置编译选项
* BUILD_JPEG
* BUILD_PNG
* BUILD_SHARED_LIBS
* BUILD_opencv_world
* WITH_GTK_2_X
* WITH_QT
* BUILD_TESTS //为了加快编译,可以不编译测试代码
* OPENCV_ENABLE_NONFREE
* CMAKE_INSTALL_PREFIX //选择安装目录
配置opencv_contrib-4.0.1相关的
* OPENCV_EXTRA_MODULES_PATH //设置opencv_contrib-4.0.1/modules目录
* BUILD_opencv_cvv //去掉,否则会报错:undefined reference to `vtable for cvv::qtutil::Signal’
(https://blog.csdn.net/fb_help/article/details/80633049)
在cmake-gui中选中Advanced(高级),输入CMAKE_CXX_FLAGS,设置值为-L/home/laoer/qt/Qt5.6.3/5.6.3/gcc_64/lib
(如果该设置不起作用,可以尝试将qt库路径/home/laoer/qt/Qt5.6.3/5.6.3/gcc_64/lib添加到环境变量中
在~/.bashrc中添加export LD_LIBRARY_PATH=/home/laoer/qt/Qt5.6.3/5.6.3/gcc_64/lib:$LD_LIBRARY_PATH)
配置时会下载:ippicv_2019_win_intel64_20180723_general.zip
因为网络原因下载很慢甚至失败,下面是手动下载的步骤:
在https://download.csdn.net/download/leon_yy/10803916下载,
将下载的文件拷贝到/home/zet/tools/opencv/opencv-4.0.1-depend目录下(根据自己环境设置)
然后修改配置文件opencv源码中3rdparty/ippicv/ippicv.cmake
将47行的
“https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_COMMIT}ippicv/”
改为手动下载的文件的本地路径
“file:/home/zet/tools/opencv/opencv-4.0.1-depend”(根据自己环境设置)
重新【Configure】,界面不显示红色表明配置成功
点击【Generate】后在build目录中生成Makefile,
make
1)boostdesc.cpp:653:37: fatal error: boostdesc_bgm.i: No such file or directory
解决方法:https://github.com/opencv/opencv_contrib/issues/1301
在构建目录下CMakeDownloadLog.txt中搜索boostdesc_bgm.i,有它的下载地址,下载后,拷贝到opencv_contrib/modules/xfeatures2d/src/ 路径下
}
//注意安装目录是cmake-gui中设置的CMAKE_INSTALL_PREFIX