level 1
小太阳01231
楼主
#include "opencv2/core/core.hpp"
#include "highgui.h"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/xfeatures2d.hpp>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
//待匹配的两幅图像,其中img1包括img2,也就是要从img1中识别出img2
Mat img1 = imread("panda.jpg");
Mat img2 = imread("panda1.jpg");
vector<KeyPoint> key_points1, key_points2;
Mat descriptors1, descriptors2, mascara;
Ptr<Feature2D> f2d = xfeatures2d::SIFT::create();
f2d->detectAndCompute(img1, mascara,key_points1,descriptors1);
f2d->detectAndCompute(img2, mascara, key_points2, descriptors2);
double t1 = (double)getTickCount();
f2d->detect(img1, key_points1);
t1 = ((double)getTickCount() - t1) / getTickFrequency();
double t2 = (double)getTickCount();
f2d->compute(img1, key_points1, descriptors1);
t2 = ((double)getTickCount() - t2) / getTickFrequency();
cout << descriptors1.size() << endl;
cout << descriptors2.size() << endl;
//实例化暴力匹配器——BFMatcher
BFMatcher matcher;
//定义匹配器算子
vector<DMatch> matches;
//实现描述符之间的匹配,得到算子matches
matcher.match(descriptors1, descriptors2, matches); //一匹配就出错,别的地方都是正常的没有问题
cout << "特征提取时间:" << t1 << "s" << endl;
cout << "特征描述时间:" << t2 << "s" << endl;
//cout << "特征点匹配时间:" << t3 << "s" <<endl;
waitKey(0);
return 0;
}匹配就出错,哪位大神帮忙解决一下????
2018年04月03日 06点04分
1
#include "highgui.h"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/xfeatures2d.hpp>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
//待匹配的两幅图像,其中img1包括img2,也就是要从img1中识别出img2
Mat img1 = imread("panda.jpg");
Mat img2 = imread("panda1.jpg");
vector<KeyPoint> key_points1, key_points2;
Mat descriptors1, descriptors2, mascara;
Ptr<Feature2D> f2d = xfeatures2d::SIFT::create();
f2d->detectAndCompute(img1, mascara,key_points1,descriptors1);
f2d->detectAndCompute(img2, mascara, key_points2, descriptors2);
double t1 = (double)getTickCount();
f2d->detect(img1, key_points1);
t1 = ((double)getTickCount() - t1) / getTickFrequency();
double t2 = (double)getTickCount();
f2d->compute(img1, key_points1, descriptors1);
t2 = ((double)getTickCount() - t2) / getTickFrequency();
cout << descriptors1.size() << endl;
cout << descriptors2.size() << endl;
//实例化暴力匹配器——BFMatcher
BFMatcher matcher;
//定义匹配器算子
vector<DMatch> matches;
//实现描述符之间的匹配,得到算子matches
matcher.match(descriptors1, descriptors2, matches); //一匹配就出错,别的地方都是正常的没有问题
cout << "特征提取时间:" << t1 << "s" << endl;
cout << "特征描述时间:" << t2 << "s" << endl;
//cout << "特征点匹配时间:" << t3 << "s" <<endl;
waitKey(0);
return 0;
}匹配就出错,哪位大神帮忙解决一下????