Compile and install opencv4.0.0 and opencv_contrib4.0.0 on Ubuntu20.04

Download opencv-4.0.0.zip and opencv_contrib-4.0.0.zip

https://download.csdn.net/download/wanchengkai/86947474

terminal input

apt update

apt install -y cmake g++ unzip//安装cmake,g++,unzip

Then 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

enter directory

cd opencv-4.0.0

mkdir build

cd build

cmake in the build path

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.0.0/modules ..

When it shows Configuring done

After Generating done

Start compiling:

make

This is because some files have not been downloaded, not only boostdesc_bgm.i here, but also

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

Solution: Download the missing files and copy them to the \opencv_contrib-4.0.0\modules\xfeatures2d\src directory

Then compile make

Put the file under 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

Copy it to the opencv_contrib-4.0.0/modules/xfeatures2d/test/ file.

Will opencv_contrib-4.0.0/modules/xfeatures2d/test/test_features2d.cpp under the file

#include "features2d/test/test_detectors_regression.impl.hpp"

#include "features2d/test/test_descriptors_regression.impl.hpp"

Change to:

#include "test_detectors_regression.impl.hpp"

#include "test_descriptors_regression.impl.hpp"

Will be under the opencv_contrib-4.0.0/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp file

#include "features2d/test/test_detectors_invariance.impl.hpp"

#include "features2d/test/test_descriptors_invariance.impl.hpp"

Change to:

#include "test_detectors_invariance.impl.hpp"

#include "test_descriptors_invariance.impl.hpp"

compile again

make   ---》OK

make install

Opencv is installed in the /usr/local directory,

Contents of the /usr/local directory before installation:

Guess you like

Origin blog.csdn.net/wanchengkai/article/details/127790400