VS2019+opencv 4.1.0+contribute 4.1.0配置

1.下载opencv 4.1.0+contribute 4.1.0的源码

2.新建一个文件夹opencv410,在该目录下新建文件夹source和build,把代码都解压放到一个source中。

3. 打开cmake,配置好目录,然后点击configure,这个过程会等好久,然后会出现下图中的红色。在红色中找到蓝色框住的两项。在nonfree中勾选对号,在下面加上contribute/modules的地址。再点击configure,直到所有红框变白。最后点击generate

4.用vs生成项目在build下有OpenCV.sln 点击生成->批生成->选中ALL_BUILD与INSTALL,然后生成。(编译生成需要花一定的时间)

5. 编译成功之后make目录中就会有install目录,该目录就是opencv的函数库

6. 配置opencv的环境变量,在PATH中添加*\build\install\x64\vc16\bin

 

 

(1) 创建空的C++工程;

(2) 打开该工程的属性,配置VC++目录中的包含目录与库目录

(3) 链接器->输入->添加依赖库,这里为D:\opencv410\build\install\x64\vc16\lib的lib文件,其中release是不带d的lib文件,debug是带d的lib文件。

PS:文件比较多,可以在cmd中输入dir /b *d.lib>debug.txt  dir /b *412.lib>release.txt,方可得到debug和release模式不同的依赖项。

 

7. 测试sift特征

(1) 创建.cpp相关代码文件;

(2) 代码如下:

 

#include <opencv2/opencv.hpp>

 

#include <iostream>

 

 

using namespace cv;

 

using namespace std;

 

 

int main(int argc, char** argv) {

 

Mat box = imread("1.png");

 

Mat box_in_sence = imread("2.png");

 

 

// 创建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("result.png", img_matches);

 

waitKey(0);

 

return 0;

 

}

(3) 效果图

 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值