2015-10-29 40 views
3

我正在玩OpenCV 3.0及其panorama sample如何使用BestOf2NearestMatcher匹配掩碼

它的作品,現在我想了解和優化它一步一步爲我的用例。 英特爾發佈了一款適合我需求的article

他們說匹配可以通過比較只有相鄰的圖像來改善。

下面的代碼:

vector<MatchesInfo> pairwise_matches;  
BestOf2NearestMatcher matcher(try_cuda, match_conf); 
matcher(features, pairwise_matches); 
matcher.collectGarbage(); 

應改爲:

vector<MatchesInfo> pairwise_matches; 
BestOf2NearestMatcher matcher(try_cuda, match_conf); 
Mat matchMask(features.size(),features.size(),CV_8U,Scalar(0)); 
for (int i = 0; i < num_images -1; ++i) 
{ 
    matchMask.at<char>(i,i+1) =1; 
} 
matcher(features, pairwise_matches,matchMask); 
matcher.collectGarbage(); 

但是,這並不工作,因爲匹配()需要在OpenCV中3.0和UMat一個UMat不具有at()功能。

我也試過:

matcher(features, pairwise_matches,matchMask.getUMat(ACCESS_READ)); 

但這也不起作用。

如果有人能夠解釋如何使用Matcher與掩碼或者可以將其遷移到OpenCV 3.0,我會非常棒。

+0

你是什麼意思'getUMat'不起作用?編譯時錯誤? – fireant

回答

2

您可以使用BestOf2NearestRangeMatcherrange_width=2這應該比使用蒙版更快,因爲內部循環會更短,請參閱the code here

+0

Thx我會檢查一下。 – FlanschiFox