/*
#include <iostream>
#include "opencv2/core.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/imgproc.hpp"
#include"opencv2/xfeatures2d.hpp"
using namespace cv;
using namespace std;
using namespace cv::xfeatures2d;
using namespace cv::ml;
int main()
{
Mat a = imread("21.jpg"); //读取灰度图像
Mat b = imread("22.jpg");
Ptr<SURF> surf; //创建方式和2中的不一样
surf = SURF::create(800);
BFMatcher matcher;
Mat c, d;
vector<KeyPoint>key1, key2;
vector<DMatch> matches;
surf->detectAndCompute(a, Mat(), key1, c);
surf->detectAndCompute(b, Mat(), key2, d);
matcher.match(c, d, matches); //匹配
sort(matches.begin(), matches.end()); //筛选匹配点
vector< DMatch > good_matches;
int ptsPairs = std::min(50, (int)(matches.size() * 0.15));
cout << ptsPairs << endl;
for (int i = 0; i < ptsPairs; i++)
{
good_matches.push_back(matches[i]);
}
Mat outimg;
drawMatches(a, key1, b, key2, good_matches, outimg, Scalar::all(-1), Scalar::all(-1),vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS); //绘制匹配点
imshow("out", outimg);
waitKey(0);
std::vector<Point2f> obj;
std::vector<Point2f> scene;
#include <iostream>
#include "opencv2/core.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/imgproc.hpp"
#include"opencv2/xfeatures2d.hpp"
using namespace cv;
using namespace std;
using namespace cv::xfeatures2d;
using namespace cv::ml;
int main()
{
Mat a = imread("21.jpg"); //读取灰度图像
Mat b = imread("22.jpg");
Ptr<SURF> surf; //创建方式和2中的不一样
surf = SURF::create(800);
BFMatcher matcher;
Mat c, d;
vector<KeyPoint>key1, key2;
vector<DMatch> matches;
surf->detectAndCompute(a, Mat(), key1, c);
surf->detectAndCompute(b, Mat(), key2, d);
matcher.match(c, d, matches); //匹配
sort(matches.begin(), matches.end()); //筛选匹配点
vector< DMatch > good_matches;
int ptsPairs = std::min(50, (int)(matches.size() * 0.15));
cout << ptsPairs << endl;
for (int i = 0; i < ptsPairs; i++)
{
good_matches.push_back(matches[i]);
}
Mat outimg;
drawMatches(a, key1, b, key2, good_matches, outimg, Scalar::all(-1), Scalar::all(-1),vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS); //绘制匹配点
imshow("out", outimg);
waitKey(0);
std::vector<Point2f> obj;
std::vector<Point2f> scene;