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

时间:2021-05-19

一、软件需求

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环境变量配置

  • 打开vs2019,新建一个空项目,打开属性管理器(视图-属性管理器\视图-其他-属性管理器)
  • 双击 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.libopencv_aruco410d.libopencv_bgsegm410d.libopencv_bioinspired410d.libopencv_calib3d410d.libopencv_ccalib410d.libopencv_core410d.libopencv_datasets410d.libopencv_dnn410d.libopencv_dnn_objdetect410d.libopencv_dpm410d.libopencv_face410d.libopencv_features2d410d.libopencv_flann410d.libopencv_fuzzy410d.libopencv_gapi410d.libopencv_hfs410d.libopencv_highgui410d.libopencv_imgcodecs410d.libopencv_imgproc410d.libopencv_img_hash410d.libopencv_line_descriptor410d.libopencv_ml410d.libopencv_objdetect410d.libopencv_optflow410d.libopencv_phase_unwrapping410d.libopencv_photo410d.libopencv_plot410d.libopencv_quality410d.libopencv_reg410d.libopencv_rgbd410d.libopencv_saliency410d.libopencv_shape410d.libopencv_stereo410d.libopencv_structured_light410d.libopencv_superres410d.libopencv_surface_matching410d.libopencv_text410d.libopencv_tracking410d.libopencv_video410d.libopencv_videoio410d.libopencv_videostab410d.libopencv_ximgproc410d.libopencv_xobjdetect410d.libopencv_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的解决办法

    参考博客

    到此这篇关于详解VS2019+OpenCV-4-1-0+OpenCV-contrib-4-1-0的文章就介绍到这了,更多相关VS2019 OpenCV OpenCV-contrib 内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!

    声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

    相关文章