[英]How to get keypoint “within the homography”?
發生的情況是您正在考慮在第二張圖像中檢測到的所有關鍵點來計算可重復性,實際上只應使用單應性內的關鍵點。
我不明白如何獲得
具有單應性的關鍵點
有人可以解釋一下怎么做嗎?
編輯:
其實看evaluation.cpp
的代碼我覺得這個操作已經執行了。 其實看看:
float overlapThreshold;
bool ifEvaluateDetectors = thresholdedOverlapMask == 0;
if( ifEvaluateDetectors )
{
overlapThreshold = 1.f - 0.4f;
// remove key points from outside of the common image part
Size sz1 = img1.size(), sz2 = img2.size();
filterEllipticKeyPointsByImageSize( keypoints1, sz1 );
filterEllipticKeyPointsByImageSize( keypoints1t, sz2 );
filterEllipticKeyPointsByImageSize( keypoints2, sz2 );
filterEllipticKeyPointsByImageSize( keypoints2t, sz1 );
}
else
{
overlapThreshold = 1.f - 0.5f;
thresholdedOverlapMask->create( (int)keypoints1.size(), (int)keypoints2t.size(), CV_8UC1 );
thresholdedOverlapMask->setTo( Scalar::all(0) );
}
考慮默認情況下thresholdedOverlapMask=0
。 所以if
內的部分丟棄單應性外的點。 那是正確的嗎?
具有單應性的關鍵點這些點被視為結果單應矩陣的內點。 換句話說:
假設您正在使用 RANSAC 之類的估計技術來獲取您的同形異義矩陣,那么您的一些點將用於構建此同形異義詞。 其他的只是噪音(異常值)。 您需要知道哪些點不是噪聲,哪些點用於構建此同形異義詞。
如何在 OpenCV 中做到這一點?
cv::findHomography
函數具有以下簽名:
Mat findHomography(InputArray srcPoints, InputArray dstPoints, int method=0, double ransacReprojThreshold=3, OutputArray mask=noArray() );
參數OutputArray mask
就是您要查找的內容。 你可以這樣使用它:
std::vector<uchar> homograph_mask;
auto H= cv::findHomography(set_of_points, other_set_of_points, cv::RANSAC, RANSAC_THRESHOLSD, homograph_mask);
std::vector<std::pair<cv::Point,cv::Point>> points_within_the_homograph;
points_within_the_homograph.reserve(homograph_mask.size());
for(size_t i=0; i < homograph_mask.size();++i){
if(homograph_mask[i]==static_cast<uchar>(1)){
points_within_the_homograph.emplace_back(set_of_points[i],other_set_of_points[i]);
}
}
points_within_the_homograph.shrink_to_fit();
points_within_the_homograph
將包含一組在同形圖中的匹配點對(內點)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.