小太阳01231 小太阳01231
关注数: 1 粉丝数: 3 发帖数: 16 关注贴吧数: 21
opencv特征匹配出错 #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; }匹配就出错,哪位大神帮忙解决一下????
1 下一页