利用特征点(Brief,ORB,SIFT)进行图像匹配,模板匹配

头文件

在VS2010+OpenCV2.3.1 
#include "StdAfx.h"
#include "opencv2/core/core.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
//#include <opencv2/legacy/legacy.hpp>
#include <vector>
#include <iostream>
#include <fstream>
#include <math.h>

using namespace cv;
using namespace std;
void getMatchLR(string imgpath);
void getMatchDT(string imgpath);
//void getSURFFeature(string imgpath);
void getORBFeature(string imgpath);
void MatchTemplate(string imgname);
void MatchTemplateORB(string imgname);
void MatchTemplateSIFT(string imgname);
void testMatch();

static string imgdir = "E:\\input_resize\\";
static string Matchsavedir = "E:\\macth_result\\";
static string TemplateDir = "E:\\template_resize\\";
//static string ORBsavedir = "ORB_result\\";
IplImage mat_src_lpl;
IplImage OutImage_lpl;
IplImage TemplateIpl;

IplImage* dst_left;
IplImage* dst_right;
IplImage *src;
IplImage *TemplateIplPtr;

Mat mat_src;
Mat OutImage;
Mat TemplateMat;
在UBUNTU12.04UTL+opencv2.4.
#include "opencv2/core/core.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <opencv2/legacy/legacy.hpp>
#include <vector>
#include <iostream>
#include <fstream>
#include <math.h>

主函数

int main()
{

	string imgname = "07_in.jpg";
	//testMatch();
	MatchTemplateSIFT(imgname);
	//getMatchLR(imgname);

	return 0;
}


SIFT

利用SIFT特征进行模板匹配,template1为一个物体的小图,然后在一张含有多个同样物体的大图上进行匹配。

在大图上滑窗处理,得到每一个滑窗的特征,进行匹配,计算距离均值,作为一个灰度值,最后生成一个大图。

特征子,描述符,匹配方法分别为:

new SiftFeatureDetector
new SiftDescriptorExtractor;
BruteForceMatcher<L2(float)>

详细代码

void MatchTemplateSIFT(string imgname)
{
	vector<KeyPoint> LeftKey;
	vector<KeyPoint> RightKey;
	Mat LeftDescriptor;
	Mat RightDescriptor;
	vector<DMatch> Matches;
	//vector<double> me
  • 2
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值