我正試圖計算2張圖片之間的對應關係,而實際上我對通信點的數量感興趣,而不是通信本身,這樣我就可以起訴它以獲得最佳匹配圖像。這是我下面的代碼:在Opencv 2.4.6中篩選實現ubuntu
#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。我拍了一張測試圖像,並試圖逐個將圖像數據庫運行。但每次我做,我的匹配大小總是。請注意,測試圖像中的關鍵點也是。我試圖找到測試圖像的最佳匹配,但我沒有明白爲什麼會發生這種情況。所有與數據庫匹配的信函都給出了的結果。
這些是我的問題和疑問,請幫助我。 : -
- 如果以上使用的方法錯誤,我如何獲得匹配數?
道歉,如果問題是非常基本的,但你的幫助是非常appreicated。
我理解你的問題了嗎?你在問爲什麼你有163場比賽。 - >所以我認爲這是因爲你的關鍵點的數量。你有163個關鍵點,並且匹配器試圖在另一張圖片中尋找關鍵點,並且如果他能找到他將會接受的關鍵點。所以你的比賽數量取決於你的關鍵點數量。如果你有163個關鍵點,你會得到163個關鍵點。如果你總是擁有相同的測試圖像,你將會得到相同數量的匹配,因爲他會找到相同的關鍵點(希望;))。 – retinotop
@retinotop是的,我注意到了。但是dexcriptors的函數匹配不適用於這種方式嗎?所有的163都不可能總是進行比賽。這意味着,這種匹配的實現在Opencv中是錯誤的 –