7

右上角无内容匹配

我修改了 OpenCV 演示应用程序“matching_to_many_images.cpp”,以从网络摄像头(右)查询图像(左)到帧。第一张图片的右上角出了什么问题?

我们认为这与我们遇到的另一个问题有关。我们从一个空数据库开始,我们只添加唯一的(与我们数据库中的特征不匹配的特征)但是在只添加了三个特征之后,我们得到了所有新特征的匹配......

我们正在使用: SurfFeatureDetector surfFeatureDetector(400,3,4); SurfDescriptorExtractor surfDescriptorExtractor; FlannBasedMatcher flannDescriptorMatcher;

完整代码可在以下网址找到:http: //www.copypastecode.com/71973/

4

3 回答 3

10

I think this has to do with the border keypoints. The detector detects the keypoints, but for the SURF descriptor to return consistent values it needs pixel data in a block of pixels around it, which is not available in the border pixels. You can use the following snippet to remove border points after keypoints are detected but before descriptors are computed. I suggest using borderSize of 20 or more.

removeBorderKeypoints( vector<cv::KeyPoint>& keypoints, const cv::Size imageSize, const boost::int32_t borderSize )
{
    if( borderSize > 0)
    {
        keypoints.erase( remove_if(keypoints.begin(), keypoints.end(),
                               RoiPredicatePic((float)borderSize, (float)borderSize,
                                            (float)(imageSize.width - borderSize),
                                            (float)(imageSize.height - borderSize))),
                     keypoints.end() );
    }
}

Where RoiPredicatePic is implemented as:

struct RoiPredicatePic
{
    RoiPredicatePic(float _minX, float _minY, float _maxX, float _maxY)
    : minX(_minX), minY(_minY), maxX(_maxX), maxY(_maxY)
    {}

    bool operator()( const cv::KeyPoint& keyPt) const
    {
        cv::Point2f pt = keyPt.pt;
        return (pt.x < minX) || (pt.x >= maxX) || (pt.y < minY) || (pt.y >= maxY);
    }

    float minX, minY, maxX, maxY;
};

Also, approximate nearest neighbor indexing is not the best way to match features between pairs of images. I would suggest you to try other simpler matchers.

于 2011-05-31T05:59:22.810 回答
4

您的方法完美无缺,但由于错误地调用了 drawMatches 函数,它显示了错误的结果。

你的错误调用是这样的:

drawMatches(image2, image2Keypoints, image1, image1Keypoints, matches, result);

正确的调用应该是:

drawMatches(image1, image1Keypoints, image2, image2Keypoints, matches, result);
于 2011-12-09T16:26:54.703 回答
3

我遇到了同样的问题。令人惊讶的是,该解决方案与边界点或 KNN 匹配器无关。只需要一个不同的匹配策略来从过多的匹配中过滤掉“好的匹配”。

使用 2 NN 搜索,以及以下条件 -

如果 distance(1st match) < 0.6*distance(2nd match) 则第一个匹配是“好匹配”。

过滤掉所有不满足上述条件的匹配,只为“好的匹配”调用 drawMatches。瞧!

于 2012-02-26T19:07:57.470 回答