SurfFeatureDetector

SurfFeatureDetector是包含在opencv2/nonfree/features2d.hpp中,所以应该include这个头文件。

类SurfFeatureDetector中,利用类内的detect函数可以检测出SURF特征的关键点,保存在vector容器中。

 使用 DescriptorExtractor 接口来寻找关键点对应的特征向量. 特别地:
使用 SurfDescriptorExtractor 以及它的函数 compute 来完成特定的计算.

 将之前的vector变量变成向量矩阵形式保存在Mat中

使用 类BruteForceMatcher 中的match来匹配两幅图像的特征向量。
使用函数 drawMatches 来绘制检测到的匹配点


#include "opencv/cv.h"
#include "opencv/highgui.h"
#include "opencv2/nonfree/features2d.hpp"
#include "opencv2/legacy/legacy.hpp"

using namespace std;
using namespace cv;
int main()
{
Mat pic1=imread("./45.jpg");
Mat pic2=imread("./46.jpg");

vector<KeyPoint> keypointpic1,keypointpic2;
SurfFeatureDetector detector(400);

detector.detect(pic1,keypointpic1);
detector.detect(pic2,keypointpic2);

SurfDescriptorExtractor surfdesc;
Mat dst1,dst2;
surfdesc.compute(pic1,keypointpic1,dst1);
surfdesc.compute(pic2,keypointpic2,dst2);

BruteForceMatcher<L2<float> > matcher;
vector<DMatch> matches;
matcher.match(dst1,dst2,matches);

nth_element(matches.begin(),matches.begin()+24,matches.end());
matches.erase(matches.begin()+25,matches.end());

Mat showmatch;
drawMatches(pic1,keypointpic1,pic2,keypointpic2,matches,showmatch,Scalar(80,80,80));

imshow("ss",showmatch);
waitKey(0);


}



  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Farmwang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值