【问题标题】:OpenCV Dense feature detectorOpenCV 密集特征检测器
【发布时间】:2015-06-04 14:54:37
【问题描述】:

我正在使用 openCV 进行一些密集的特征提取。例如,代码

DenseFeatureDetector detector(12.f, 1, 0.1f, 10);

上面构造函数中的参数我不是很懂。这是什么意思 ?阅读关于它的 opencv documentation 也无济于事。在文档中,参数是:

DenseFeatureDetector( float initFeatureScale=1.f, int featureScaleLevels=1,
                          float featureScaleMul=0.1f,
                          int initXyStep=6, int initImgBound=0,
                          bool varyXyStepWithScale=true,
                          bool varyImgBoundWithScale=false );

他们应该做什么?即 scale、initFeatureScale、featureScaleLevels 等是什么意思?您如何知道密集采样的网格或网格间距等。

【问题讨论】:

标签: c++ opencv descriptor


【解决方案1】:

我也在使用带有密集检测器的 opencv,我想我可以帮助你一些事情。我不确定我要说什么,但经历让我明白了这一点。

当我使用密集检测器时,我将灰度图像传递到那里。检测器制作了一些阈值过滤器,其中 opencv 使用灰度最小值来转换图像。灰度等级高于阈值的像素将被设为黑点,其他像素为白点。这个动作在一个循环中重复,阈值会越来越大。因此,参数 initFeatureScale 确定了执行此循环的第一个阈值, featureScaleLevels 参数指示在一次循环迭代和下一次循环迭代之间此阈值大多少,而 featureScaleMul 是计算下一个阈值的乘数。

无论如何,如果您正在寻找使用密集检测器检测任何特定点的最佳参数,您会提供我为此制作的程序。它在 github 中被解放出来。这是一个程序,您可以在其中测试一些检测器(密集检测器就是其中之一)并检查如果您更改它们的参数,它是如何工作的,这要归功于用户界面,只要您正在执行程序,您就可以更改检测器参数。您将看到检测到的点将如何变化。要试用它,只需单击link,然后下载文件。您可能需要几乎所有文件来执行程序。

【讨论】:

  • 非常感谢您花时间解释参数。但是,我不再从事该项目,目前正在从事不同的领域。谢谢你的时间:)
【解决方案2】:

提前道歉,我主要使用 Python,所以我会避免引用 C++ 让自己尴尬。

DenseFeatureDetector 使用 KeyPoints 填充向量以传递给计算特征描述符。这些关键点有一个点向量和它们的比例集。在文档中,scale 是关键点的像素半径。

关键点在传递给 DenseFeatureVector 的图像矩阵的宽度和高度上均匀分布。

现在讨论论点:

initFeatureScale 以像素为单位设置初始 KeyPoint 特征半径(据我所知,这没有影响)

featureScaleLevels 我们希望在其上制作关键点的尺度数

featureScaleMuliplier initFeatureScale 在 featureScaleLevels 上的缩放调整,这种缩放调整也可以应用于边界(initImgBound)和步长(initxystep)。因此,当我们设置 featureScaleLevels>1 时,这个乘数将应用于连续的尺度,以调整特征尺度、步长和图像周围的边界。

initXyStep 以像素为单位移动列和行步长。我希望不言自明。

initImgBound 要忽略图像周围的行/列边界区域(像素),因此 initImgBound 为 10 的 100x100 图像将在图像的中心 80x80 部分创建关键点。

varyXyStepWithScale 布尔值,如果我们有多个 featureScaleLevels,我们是否要使用 featureScaleMultiplier 调整步长。

varyImgBoundWithScale 布尔值,如 varyXyStepWithScale,但应用于边框。


这里是 OpenCV 2.4.3 源代码中检测器.cpp 中的 DenseFeatureDetector 源代码,它可能比我的话解释得更好:

DenseFeatureDetector::DenseFeatureDetector( float _initFeatureScale, int _featureScaleLevels,
                                      float _featureScaleMul, int _initXyStep,
                                      int _initImgBound, bool _varyXyStepWithScale,
                                      bool _varyImgBoundWithScale ) :
    initFeatureScale(_initFeatureScale), featureScaleLevels(_featureScaleLevels),
    featureScaleMul(_featureScaleMul), initXyStep(_initXyStep), initImgBound(_initImgBound),
    varyXyStepWithScale(_varyXyStepWithScale), varyImgBoundWithScale(_varyImgBoundWithScale)
{}


void DenseFeatureDetector::detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask ) const
{
    float curScale = static_cast<float>(initFeatureScale);
    int curStep = initXyStep;
    int curBound = initImgBound;
    for( int curLevel = 0; curLevel < featureScaleLevels; curLevel++ )
    {
        for( int x = curBound; x < image.cols - curBound; x += curStep )
        {
            for( int y = curBound; y < image.rows - curBound; y += curStep )
            {
                keypoints.push_back( KeyPoint(static_cast<float>(x), static_cast<float>(y), curScale) );
            }
        }

        curScale = static_cast<float>(curScale * featureScaleMul);
        if( varyXyStepWithScale ) curStep = static_cast<int>( curStep * featureScaleMul + 0.5f );
        if( varyImgBoundWithScale ) curBound = static_cast<int>( curBound * featureScaleMul + 0.5f );
    }

    KeyPointsFilter::runByPixelsMask( keypoints, mask );
}

您可能期望计算调用会根据 DenseFeatureDetector 生成的关键点,使用相关关键点检测算法(例如角度)计算其他关键点特征。不幸的是,Python 下的 SIFT 并非如此——我没有研究过其他特征检测器,也没有研究过 C++ 中的行为。

另请注意,DenseFeatureDetector 不在 OpenCV 3.2 中(不确定它在哪个版本中被删除)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-21
    • 2013-07-02
    • 2011-07-11
    • 2018-04-21
    • 2016-05-19
    • 1970-01-01
    • 2011-11-06
    • 1970-01-01
    相关资源
    最近更新 更多