2017-09-13 90 views
0

由於我是openCV和計算機視覺的新手,請隨身攜帶。我試圖從兩個圖像中獲取匹配特徵點,以便進一步處理。我通過引用由FLANN提供的SURF特徵匹配的example來編寫以下代碼,但在ORB中。ORB功能與C++中的FLANN相匹配

這裏是代碼:

#include "opencv2/video/tracking.hpp" 
#include "opencv2/imgproc.hpp" 
#include "opencv2/videoio.hpp" 
#include "opencv2/highgui.hpp" 
#include "opencv2/features2D.hpp" 


using namespace cv; 
using namespace std; 



int main(int argc, char** argv) 
{ 
Mat im_left, im_right; 
Mat descriptor_1, descriptor_2; 

vector<KeyPoint> keypoints_1, keypoints_2; 

im_left = imread("im_left.png", IMREAD_GRAYSCALE); 
im_left = imread("im_right.png", IMREAD_GRAYSCALE); 

Ptr<ORB> detector = ORB::create(); 
vector<DMatch> matches; 
FlannBasedMatcher matcher; 
Ptr<DescriptorExtractor> extractor; 


detector->detect(im_right, keypoints_1, descriptor_1); 
detector->detect(im_left, keypoints_2, descriptor_2); 

matcher.match(descriptor_1, descriptor_2, matches); 

Mat img_match; 

drawMatches(im_left, keypoints_1, im_right, keypoints_2, matches, img_match); 
imshow("Matches", img_match); 



waitKey(10000); 
return 0; 
} 

但是,這將引發異常錯誤說:

在0x00007FF97D3B9E08在PROJECT1.EXE

未處理的異常:微軟C++異常:CV ::內存位置異常0x0000009E5D4FE3B0。發生

可能是我的代碼充滿了廢話,欣賞有人能幫我解決這個問題。

感謝您提前!

+0

';'是一個壞習慣進入如果你現在可以停下來,你可能會在將來避免很多麻煩。 'std ::'前綴是有原因的:它避免了與你自己的類,結構和變量的衝突。 – tadman

+1

[這裏](https://github.com/ahmetozlu/open_source_markerless_augmented_reality/wiki/Markerless-Augmented-Reality-Tutorial)是無標記增強現實項目的教程(用C++編程)。這個項目有未來的匹配部分和更多關於圖像匹配的東西,它可以幫助你。 [This](https://www.youtube.com/watch?v=nPfR5ACrqu0)是該項目的演示視頻。 – Ozlu

+0

謝謝Olzu,請檢查:)非常感謝你! – Althaf

回答