opencv 4.5编译

opencv 4.5.0编译大坑

  • 先来简述一下opencv 450编译过程遇到的坑
    • 1.boostdesc_bgm.i,vgg_generated_48.i等文件的缺失
    • 2.在用VS编译过程报错找不到test_descriptors_invariance.impl.hpp等文件
    • 3.开始opencv 4.5.0编译教学:

先来简述一下opencv 450编译过程遇到的坑

1.boostdesc_bgm.i,vgg_generated_48.i等文件的缺失

在用VS去编译opencv 4.5.0的源码的时候,可能会遇到报检测不到boostdesc_bgm.i等文件。从https://files.cnblogs.com/files/arxive/boostdesc_bgm.i%2Cvgg_generated_48.i%E7%AD%89.rar

链接: boostdesc_bgm.i等文件.
路径下载后将文件夹内的文件放入opencv_contrib/modules/xfeatures2d/src/ 路径下即可

2.在用VS编译过程报错找不到test_descriptors_invariance.impl.hpp等文件

无法打开包括文件: “features2d/test/test_detectors_invariance.impl.hpp”: No such file or directory

将以下文件(文件不是在你下载的opencv\modules\features2d\test\ 里,就是在opencv_contrib-4.5.0\opencv_contrib-4.5.0\modules\xfeatures2d\test\ 中)放入opencv_contrib-4.5.0\modules\xfeatures2d\test\ 里(在你编译生成的文件夹中的\modules\features2d\中也最好新建个test文件夹,将内容粘贴过去)

test_descriptors_invariance.impl.hpp
test_descriptors_regression.impl.hpp
test_detectors_invariance.impl.hpp
test_detectors_regression.impl.hpp
test_features2d.cpp
test_invariance_utils.hpp
test_rotation_and_scale_invariance.cpp

修改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”
修改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”

3.开始opencv 4.5.0编译教学:

1.首先去opencv官网下载opencv的源码(或exe文件),以及对应的contrib源码
opencv 4.5.0.
opencv 4.5.0_contrib.

2.使用cmake进行编译,我的IDE是VS2015,configure一下

opencv 4.5编译_第1张图片

把OPENCV_EXTRA_MODULES_PATH 输入到opencv_contrib-4.5.0\opencv_contrib-4.5.0\modules文件夹下,并且勾选OPENCV_ENABLE_NONFREE
opencv 4.5编译_第2张图片
勾选BUILD_opencv_world(不然会生成很多很多的lib和dll)
opencv 4.5编译_第3张图片
然后继续configure直到红色全部消失,点击generate生成

opencv 4.5编译_第4张图片
生成后点击open project,或者自己到文件夹下打开opencv.sln文件
opencv 4.5编译_第5张图片
opencv 4.5编译_第6张图片
编译之
编译成功后,头文件在install中的include文件夹
opencv 4.5编译_第7张图片
lib文件在lib文件夹中对应的debug 或 release下,opencv_world450d.lib或opencv_world450.lib
opencv 4.5编译_第8张图片

dll文件在bin下的debug或release下的opencv_world450d.dll或opencv_world450.dll
opencv 4.5编译_第9张图片

你可能感兴趣的:(opencv)