opencv4.4.0和opencv_contrib-4.4.0以及编译过程中缺少的文件
链接:https://pan.baidu.com/s/11D6G3TbRY_-oNYlP4FDnTA
提取码:26yc
sudo apt install libavcodec-dev libavformat-dev libswscale-dev libavresample-dev
sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt install libxvidcore-dev x264 libx264-dev libfaac-dev libmp3lame-dev libtheora-dev
sudo apt install libfaac-dev libmp3lame-dev libvorbis-dev
sudo apt install libopencore-amrnb-dev libopencore-amrwb-dev
将opencv_contrib-4.4.0移到opencv-4.4.0
cp -r opencv_contrib-4.4.0 opencv-4.4.0
cd opencv-4.4.0
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=~/opencv44/ -DBUILD_JAVA=OFF -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.4.0/modules -DWITH_CUDA=1 -DENABLE_FAST_MATH=1 -DCUDA_FAST_MATH=1 -DWITH_CUBLAS=1 -DOPENCV_GENERATE_PKGCONFIG=ON -DWITH_GSTREAMER=ON -DCUDA_GENERATION=Pascal ..
编译安装的地址是~/opencv44/,需要修改一下
make -j
make install
vim ~/.bashrc
export PKG_CONFIG_PATH=/home/cxzx/opencv44/lib/pkgconfig
export LD_LIBRARY_PATH=/home/cxzx/opencv44/lib
source ~/.bashrc
/home/cxzx/opencv-4.4.0/opencv_contrib-4.4.0/modules/xfeatures2d/src/vgg.cpp:490:41: fatal error: vgg_generated_120.i: No such file or directory
/home/cxzx/opencv-4.4.0/opencv_contrib-4.4.0/modules/xfeatures2d/src/boostdesc.cpp:654:37: fatal error: boostdesc_bgm.i: No such file or directory
解决方法
我提供百度云盘中的文件boostdesc.tar.gz解压
cd /home/cxzx/boostdesc
cp * ../opencv-4.4.0/opencv_contrib-4.4.0/modules/xfeatures2d/src/
fatal error: opencv2/xfeatures2d.hpp: No such file or directory
然后将opencv-4.4.0/opencv_contrib-4.4.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-4.4.0/opencv_contrib-4.4.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"
fatal error: opencv2/xfeatures2d.hpp: No such file or directory
cd /home/cxzx/opencv-4.4.0
vim CMakeLists.txt
添加
INCLUDE_DIRECTORIES("/home/cxzx/opencv-4.4.0/opencv_contrib-4.4.0/modules/xfeatures2d/include")
解决这三个问题就可以编译成功了