我正在尝试计算 2 个图像之间的对应关系,实际上我对对应点的数量感兴趣,而不是对应关系本身,这样我就可以起诉它以获得最佳匹配图像。这是我的以下代码:
#include<iostream>
#include<vector>
#include<string>
#include "cv.h"
#include "highgui.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/legacy/legacy.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include "opencv2/nonfree/features2d.hpp"
#include<stdio.h>
using namespace cv;
using namespace std;
int main(int argc, char **argv)
{
Mat A = imread("/home/itachi/iTaggproj/frame6.jpg",CV_LOAD_IMAGE_COLOR);
Mat src = imread("/home/itachi/iTaggproj/dataformatch/frame0.jpg",CV_LOAD_IMAGE_COLOR);
SiftFeatureDetector detector( 0.05, 5.0 );
SiftDescriptorExtractor extractor( 3.0 );
vector<KeyPoint>keypoints1,keypoints2;
detector.detect( A, keypoints1 );
detector.detect( src, keypoints2 );
int key1 = keypoints1.size();
int key2 = keypoints2.size();
printf("Keypoint1=%d \nKeypoint2=%d", key1, key2);
// Feature descriptor computation
Mat descriptor1,descriptor2;
extractor.compute( A, keypoints1, descriptor1 );
extractor.compute( src, keypoints2, descriptor2 );
//match points to get correspondence
// BFMatcher matcher(NORM_L2);
FlannBasedMatcher matcher;
vector<DMatch>matches;
matcher.match( descriptor1, descriptor2, matches );
cout<<endl<<matches.size()<<endl;
return 0;
}
我从link1和link2获得了我的代码。我所有的图像都是 320X240。我拍摄了一张测试图像,并尝试在图像数据库中一张一张地运行它。但每次我这样做时,我的匹配大小总是163。请注意,测试图像中的关键点也是163。我正在尝试为测试图像找到最佳匹配,但我不明白为什么会发生这种情况。所有与数据库匹配的对应关系都给出163的结果。
这些是我的问题和疑问,请帮助我。:-
- 如果上面使用的方法错误,如何获得匹配数?
抱歉,如果问题非常基本,但非常感谢您的帮助。