过程中的所有命令:
//安装依赖
sudo apt-get install libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev build-essential qt5-default ccache libv4l-dev libavresample-dev libgphoto2-dev libopenblas-base libopenblas-dev doxygen pylint libvtk6-dev
sudo tar -xzvf opencv-4.1.2.tar.gz
sudo tar -xzvf opencv-contrib-4.1.2.tar.gz
sudo cp -r opencv_contrib-4.1.2 opencv-4.1.2
cd opencv-4.1.2
sudo mkdir build
cd build
sudo cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=~/opencv-4.1.2/opencv_contrib-4.1.2/modules/ ..
sudo make -j4
sudo make install
sudo ldconfig -v
问题记录:
sudo make -j4进行链接时遇到了两个文件找不到的问题:
1.fatal error: boostdesc_bgm.i: No such file or directory
问题描述:
/home/tellw/opencv-4.1.2/opencv_contrib-4.1.2/modules/xfeatures2d/src/boostdesc.cpp:654:20: fatal error: boostdesc_bgm.i: No such file or directory
#include "boostdesc_bgm.i"
^~~~~~~~~~~~~~~~~
compilation terminated.
原因:下载文件失败
根据参考链接[3]和[4]写出如下脚本:
cd ~/opencv-4.1.2/opencv_contrib-4.1.2/modules/xfeatures2d/src
wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_lbgm.i
wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_256.i
wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_128.i
wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_binboost_064.i
wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm_hd.i
wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm_bi.i
wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/34e4206aef44d50e6bbcd0ab06354b52e7466d26/boostdesc_bgm.i
wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_120.i
wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_64.i
wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_48.i
wget https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d/vgg_generated_80.i
2.fatal error: features2d/test/test_detectors_regression.impl.hpp: No such file or directory
问题描述:
/home/tellw/opencv-4.1.2/opencv_contrib-4.1.2/modules/xfeatures2d/test/test_features2d.cpp:51:10: fatal error: features2d/test/test_detectors_regression.impl.hpp: No such file or directory
#include "features2d/test/test_detectors_regression.impl.hpp"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
根据参考链接[2]写出如下命令:
sudo cp -r ~/opencv-4.1.2/modules/features2d ~/opencv-4.1.2/build
继续链接即可
参考链接:
[1] Ubuntu下opencv3.3和opencv_contrib的编译安装
[2] ubuntu build make error #1950
[3] fatal error: boostdesc_bgm.i: No such file or directory #1301