Commit e45887e1 authored by ab-dragon's avatar ab-dragon Committed by Alexander Alekhin
Browse files

Merge pull request #2301 from ab-dragon:conditionally_compute_dog_pyramid

Build DoG Pyramid if useProvideKeypoints is false

The buildDoGPyramid operation need not be performed unconditionally. In cases where it is not needed, both memory and speed performance can be improved
parent 94d1b9bc
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1147,19 +1147,20 @@ void SIFT_Impl::detectAndCompute(InputArray _image, InputArray _mask,
    }

    Mat base = createInitialImage(image, firstOctave < 0, (float)sigma);
    std::vector<Mat> gpyr, dogpyr;
    std::vector<Mat> gpyr;
    int nOctaves = actualNOctaves > 0 ? actualNOctaves : cvRound(std::log( (double)std::min( base.cols, base.rows ) ) / std::log(2.) - 2) - firstOctave;

    //double t, tf = getTickFrequency();
    //t = (double)getTickCount();
    buildGaussianPyramid(base, gpyr, nOctaves);
    buildDoGPyramid(gpyr, dogpyr);

    //t = (double)getTickCount() - t;
    //printf("pyramid construction time: %g\n", t*1000./tf);

    if( !useProvidedKeypoints )
    {
        std::vector<Mat> dogpyr;
        buildDoGPyramid(gpyr, dogpyr);
        //t = (double)getTickCount();
        findScaleSpaceExtrema(gpyr, dogpyr, keypoints);
        KeyPointsFilter::removeDuplicatedSorted( keypoints );