如何获取关键点"within the homography"?
How to get keypoint "within the homography"?
参考this answer to this question:
What is happening is that you're considering all the keypoints
detected in the second image for the calculation of repeatability and
actually only the keypoints within the homography should be used.
我不明白如何获得
keypoints withing 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
里面的部分舍弃了单应性外面的点。对吗?
keypoints withing the homography
Those are points that considered as inliers for the result Homograph Matrix. In other words:
假设你正在使用像 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
将包含一组在同形异义词(内点)内的匹配点对。
参考this answer to this question:
What is happening is that you're considering all the keypoints detected in the second image for the calculation of repeatability and actually only the keypoints within the homography should be used.
我不明白如何获得
keypoints withing 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
里面的部分舍弃了单应性外面的点。对吗?
keypoints withing the homography Those are points that considered as inliers for the result Homograph Matrix. In other words:
假设你正在使用像 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
将包含一组在同形异义词(内点)内的匹配点对。