FREAK特征原理:
/*
*@function FREAK_Detect.cpp
*@brief 使用FREAK特征检测并匹配目标
*@author ltc
*@date 19:31 Thursday,December 3rd,2015
*/
#include<opencv2\core\core.hpp>
#include<opencv2\highgui\highgui.hpp>
#include<opencv2\features2d\features2d.hpp>
#include<opencv2\calib3d\calib3d.hpp>
#include<opencv2\nonfree\nonfree.hpp>
#include<iostream>
using namespace std;
using namespace cv;
int main(int argc,char* argv[])
{
Mat queryImage,trainImage;
queryImage=imread("1.jpg",IMREAD_COLOR);
trainImage=imread("2.jpg",IMREAD_COLOR);
if(queryImage.empty() || trainImage.empty())
{
return -1;
}
vector<KeyPoint> queryKeyPoint,trainKeyPoint;
Mat queryDescriptor,trainDescriptor;
SurfFeatureDetector freakDetector;
freakDetector.detect(trainImage,trainKeyPoint);
freakDetector.detect(queryImage,queryKeyPoint);
FREAK freakDescriptorExactor;
freakDetector.compute(queryImage,queryKeyPoint,queryDescriptor);
freakDetector.compute(trainImage,trainKeyPoint,trainDescriptor);
drawKeypoints(queryImage,queryKeyPoint,queryImage);
drawKeypoints(trainImage,trainKeyPoint,trainImage);
imshow("query",queryImage);
imshow("train",trainImage);
vector<DMatch> matches;
BFMatcher matcher(NORM_L2);
matcher.match(queryDescriptor,trainDescriptor,matches);
Mat image_match;
drawMatches(queryImage,queryKeyPoint,trainImage,trainKeyPoint,matches,image_match);
imshow("image_match",image_match);
waitKey(0);
return 0;
}
匹配结果: