簡體   English   中英

OpenCV密集特征檢測器

[英]OpenCV Dense feature detector

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

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

我不太了解上述構造函數中的參數。 這是什么意思 ? 閱讀有關它的opencv 文檔也無濟於事。 在文檔中,參數為:

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等的含義是什么? 您如何知道密集采樣的網格或網格間距等。

我也使用帶有密集檢測器的opencv,我想我可以為您提供一些幫助。 我不確定我要說什么,但是經驗告訴我。

當我使用密集檢測器時,我會通過那里灰度圖像。 檢測器制作一些閾值濾波器,其中opencv使用灰度最小值與來轉換圖像。 灰階比閾值高的像素將被視為黑點,而其他像素則為白點。 在閾值越來越大的循環中重復執行此操作。 因此,參數initFeatureScale確定執行此循環所需的第一個閾值,featureScaleLevels參數指示此閾值在一個循環迭代與下一個循環之間要大多少,featureScaleMul是計算下一個閾值的乘數。

無論如何,如果您正在尋找最佳參數來使用密集檢測器來檢測任何特定點,那么您將提供我為此而設計的程序。 它在github中被解放了。 這是一個程序,您可以在其中測試某些檢測器(密集檢測器就是其中之一),並通過一個用戶界面(只要您在執行程序時就可以更改檢測器參數)來檢查其參數是否更改。 您將看到檢測到的點將如何變化。 要嘗試,只需單擊鏈接 ,然后下載文件。 您可能需要幾乎所有文件來執行程序。

事先道歉,我主要使用Python,所以我會避免使用C ++來掩飾自己。

DenseFeatureDetector填充帶有KeyPoints的向量,以傳遞給計算特征描述符。 這些關鍵點具有一個點向量及其標度集。 在文檔中,比例是關鍵點的像素半徑。

關鍵點在傳遞給DenseFeatureVector的圖像矩陣的寬度和高度上均勻分布。

現在來看參數:

initFeatureScale設置初始KeyPoint特征半徑(以像素為單位)(據我所知這沒有效果)

featureScaleLevels數overwhich我們希望使關鍵點

用於initFeatureScale超過featureScaleLevels featureScaleMuliplier比例調節,這種規模的調整也可以應用於邊界(initImgBound)和步長大小(initxystep)。 因此,當我們設置featureScaleLevels> 1時,該乘數將應用於連續的比例,以調整特征比例,階梯和圖像周圍的邊界。

initXyStep移動列和行的步長(以像素為單位)。 我希望自我解釋。

initImgBound行/列邊界區域可以忽略圖像(像素)周圍的內容,因此,一個initImgBound為10的100x100圖像將在圖像的中央80x80部分中創建關鍵點。

VariantXyStepWithScale布爾值,如果我們有多個featureScaleLevels ,我們想使用featureScaleMultiplier來調整步長。

variableImgBoundWithScale布爾值,與variableXyStepWithScale一樣,但應用於邊框。


這是來自OpenCV 2.4.3源中detectors.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中(不確定在哪個版本上將其刪除)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM