亲宝软件园·资讯

展开

VS2019 OpenCV OpenCV-contrib 详解VS2019+OpenCV-4-1-0+OpenCV-contrib-4-1-0

Kratze-Jayue 人气:0

一、软件需求

VS2019社区版、win10操作系统、opencv4.1.0、opencv_contrib_4.1.0、cmake3.15.3

VS2019社区版(免费) 下载地址
OpenCV4.1.0 下载地址
OpenCV_contrib_4.1.0 下载地址
CMAKE 下载地址

二、CMAKE编译

在 D:\opencv_4.1.0 目录下创建个newbuild文件夹

进入cmake,配置OpenCV_4.1.0

配置OpenCV_contrib_4.1.0

注意:第2步操作时后面的路径不要手打

三、VS2019编译

进入 D:\opencv_4.1.0\newbuild 目录 找到 OpenCV.sln 双击

四、系统环境变量配置

右键电脑-属性 -> 高级系统设置 ->环境变量 -> 系统变量 -> path

点击新建 填入 D:\opencv_4.1.0\newbuild\install\x64\vc16\bin

五、VS2019环境变量配置

  1. 打开vs2019,新建一个空项目,打开属性管理器(视图-属性管理器\视图-其他-属性管理器)
  2. 双击 Microsoft.Cpp.x64.user

配置包含目录(通用属性-VC++目录-包含目录),库目录(通用属性-VC++目录-库目录)

在包含目录中添加

D:\opencv_4.1.0\newbuild\install\include

D:\opencv_4.1.0\newbuild\install\include\opencv2

库目录中添加

D:\opencv_4.1.0\newbuild\install\x64\vc16\lib

配置附加依赖项(链接器-输入-附加依赖项)

获取链接器的方法

opencv_world410d.lib
opencv_aruco410d.lib
opencv_bgsegm410d.lib
opencv_bioinspired410d.lib
opencv_calib3d410d.lib
opencv_ccalib410d.lib
opencv_core410d.lib
opencv_datasets410d.lib
opencv_dnn410d.lib
opencv_dnn_objdetect410d.lib
opencv_dpm410d.lib
opencv_face410d.lib
opencv_features2d410d.lib
opencv_flann410d.lib
opencv_fuzzy410d.lib
opencv_gapi410d.lib
opencv_hfs410d.lib
opencv_highgui410d.lib
opencv_imgcodecs410d.lib
opencv_imgproc410d.lib
opencv_img_hash410d.lib
opencv_line_descriptor410d.lib
opencv_ml410d.lib
opencv_objdetect410d.lib
opencv_optflow410d.lib
opencv_phase_unwrapping410d.lib
opencv_photo410d.lib
opencv_plot410d.lib
opencv_quality410d.lib
opencv_reg410d.lib
opencv_rgbd410d.lib
opencv_saliency410d.lib
opencv_shape410d.lib
opencv_stereo410d.lib
opencv_structured_light410d.lib
opencv_superres410d.lib
opencv_surface_matching410d.lib
opencv_text410d.lib
opencv_tracking410d.lib
opencv_video410d.lib
opencv_videoio410d.lib
opencv_videostab410d.lib
opencv_ximgproc410d.lib
opencv_xobjdetect410d.lib
opencv_xphoto410d.lib

六、程序验证

#include <opencv2/opencv.hpp>
#include <iostream>
 
using namespace cv;
using namespace std;
 
int main(int argc, char** argv) {
	Mat box = imread("1.jpg");
	Mat box_in_sence = imread("2.jpg");
 
	// 创建AKAZE
	auto akaze_detector = AKAZE::create();
	vector<KeyPoint> kpts_01, kpts_02;
	Mat descriptors1, descriptors2;
	akaze_detector->detectAndCompute(box, Mat(), kpts_01, descriptors1);
	akaze_detector->detectAndCompute(box_in_sence, Mat(), kpts_02, descriptors2);
 
	// 定义描述子匹配 - 暴力匹配
	Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create(DescriptorMatcher::BRUTEFORCE);
	std::vector< DMatch > matches;
	matcher->match(descriptors1, descriptors2, matches);
 
	// 绘制匹配
	Mat img_matches;
	drawMatches(box, kpts_01, box_in_sence, kpts_02, matches, img_matches);
	imshow("AKAZE-Matches", img_matches);
	imwrite("D:/result.png", img_matches);
 
	waitKey(0);
	return 0;
}

七、VS2019属性页没有Microsoft.Cpp.x64.user解决办法

可以查看我写过的另一篇博客 VS2019属性管理器没有Microsoft.Cpp.x64.user的解决办法

参考博客

加载全部内容

相关教程
猜你喜欢
用户评论