简体   繁体   English

如何在“单应性内”获得关键点?

[英]How to get keypoint “within the homography”?

Referring to 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.发生的情况是您正在考虑在第二张图像中检测到的所有关键点来计算可重复性,实际上只应使用单应性内的关键点。

I don't understand how to get the我不明白如何获得

keypoints withing the homography具有单应性的关键点

Someone can explain how to do it?有人可以解释一下怎么做吗?

EDIT:编辑:

Actually looking at the code of evaluation.cpp I think that this operation is already performed.其实看evaluation.cpp的代码我觉得这个操作已经执行了。 In fact, looking at:其实看看:

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) );
}

Consider that thresholdedOverlapMask=0 by default.考虑默认情况下thresholdedOverlapMask=0 So the part inside the if discard the point outside the homography.所以if内的部分丢弃单应性外的点。 Is that correct?那是正确的吗?

keypoints withing the homography Those are points that considered as inliers for the result Homograph Matrix.具有单应性的关键点这些点被视为结果单应矩阵的内点。 In other words:换句话说:

Supposing you are using an estimation technique like RANSAC to get your Homograph Matrix, some of your points will be used to construct this Homograph.假设您正在使用 RANSAC 之类的估计技术来获取您的同形异义矩阵,那么您的一些点将用于构建此同形异义词。 The others are just a noise(outliers).其他的只是噪音(异常值)。 You need to know which of your points that are not noise and that were used to construct this Homograph.您需要知道哪些点不是噪声,哪些点用于构建此同形异义词。


How to do that in OpenCV?如何在 OpenCV 中做到这一点?

The cv::findHomography function has the following signature: cv::findHomography函数具有以下签名:

Mat findHomography(InputArray srcPoints, InputArray dstPoints, int method=0, double ransacReprojThreshold=3, OutputArray mask=noArray() );

The parameter OutputArray mask is what you are looking for.参数OutputArray mask就是您要查找的内容。 You can use it like this:你可以这样使用它:

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 will contain a set of pairs of matched points that are within the Homograph (inliers). points_within_the_homograph将包含一组在同形图中的匹配点对(内点)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM