下载opencv-4.0.0.zip和opencv_contrib-4.0.0.zip
https://download.csdn.net/download/wanchengkai/86947474
终端输入
apt update
apt install -y cmake g++ unzip//安装cmake,g++,unzip
然后解压opencv-4.0.0.zip,opencv_contrib-4.0.0.zip
unzip opencv-4.0.0.zip
unzip opencv_contrib-4.0.0.zip
进入目录
cd opencv-4.0.0
mkdir build
cd build
在build路径下cmake
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..
当显示Configuring done
Generating done后
开始编译:
make
这是因为一些文件没有下载下来,不只此处的boostdesc_bgm.i,还有
boostdesc_bgm_bi.i
boostdesc_bgm_hd.i
boostdesc_binboost_064.i
boostdesc_binboost_128.i
boostdesc_binboost_256.i
vgg_generated_120.i
vgg_generated_64.i
vgg_generated_80.i
vgg_generated_48.i
解决办法:下载缺失的文件,拷贝到\opencv_contrib-4.0.0\modules\xfeatures2d\src目录中
再编译make
将opencv/modules/features2d/test/文件下的
test_descriptors_invariance.impl.hpp
test_descriptors_regression.impl.hpp
test_detectors_invariance.impl.hpp
test_detectors_regression.impl.hpp
test_invariance_utils.hpp
拷贝到opencv_contrib-4.0.0/modules/xfeatures2d/test/文件下。
将opencv_contrib-4.0.0/modules/xfeatures2d/test/test_features2d.cpp文件下的
#include "features2d/test/test_detectors_regression.impl.hpp"
#include "features2d/test/test_descriptors_regression.impl.hpp"
改成:
#include "test_detectors_regression.impl.hpp"
#include "test_descriptors_regression.impl.hpp"
将opencv_contrib-4.0.0/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp文件下的
#include "features2d/test/test_detectors_invariance.impl.hpp"
#include "features2d/test/test_descriptors_invariance.impl.hpp"
改成:
#include "test_detectors_invariance.impl.hpp"
#include "test_descriptors_invariance.impl.hpp"
再次编译
make ---》OK
make install
Opencv被安装到/usr/local目录下,
安装之前的/usr/local目录内容: