sudo cp ../../opencv_contrib-4.5.1/modules/xfeatures2d/include/opencv2/* -r ../../opencv_contrib-4.5.1/modules/sfm/include/opencv2/
安装唯一报错的地方
/home/ljx/vscode/opencv/opencv_contrib-4.5.1/modules/sfm/src/simple_pipeline.cpp:44:10: fatal error: opencv2/xfeatures2d.hpp: No such file or directory
#include <opencv2/xfeatures2d.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
modules/sfm/CMakeFiles/opencv_sfm.dir/build.make:230: recipe for target 'modules/sfm/CMakeFiles/opencv_sfm.dir/src/simple_pipeline.cpp.o' failed
make[2]: *** [modules/sfm/CMakeFiles/opencv_sfm.dir/src/simple_pipeline.cpp.o] Error 1
CMakeFiles/Makefile2:6337: recipe for target 'modules/sfm/CMakeFiles/opencv_sfm.dir/all' failed
make[1]: *** [modules/sfm/CMakeFiles/opencv_sfm.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
首先你的下载安装包,我这里有现成的,直接下就行,当然你也可以去github上去找。
下载地址:https://download.csdn.net/download/weixin_46151178/77515806
mkdir opencv && cd opencv
unzip opencv_contrib-4.5.1.zip
unzip opencv-4.5.1.zip
unzip zhangcaijiang-opencv_3rdparty-contrib_xfeatures2d_boostdesc_20161012.zip
unzip zhangcaijiang-opencv_3rdparty-contrib_xfeatures2d_vgg_20160317.zip
cd opencv-4.5.1
mkdir build
cd build
sudo cp ../../zhangcaijiang-opencv_3rdparty-contrib_xfeatures2d_boostdesc_20161012/opencv_3rdparty/* ../../opencv_contrib-4.5.1/modules/xfeatures2d/src/
sudo cp ../../zhangcaijiang-opencv_3rdparty-contrib_xfeatures2d_vgg_20160317/opencv_3rdparty/* ../../opencv_contrib-4.5.1/modules/xfeatures2d/src/
sudo make -j8
sudo make install
/home/ljx/opencv-4.5.1/opencv-4.5.1/samples/cpp/example_cmake
sudo cmake .
sudo make
sudo ./opencv_example