Skip to content

Commit 0ef1196

Browse files
committed
Merge pull request #1514 from Sahloul:bug_fix/HarrisLaplace
2 parents c14ee71 + fa719d5 commit 0ef1196

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

modules/xfeatures2d/src/harris_lapace_detector.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,13 @@ class Pyramid
7373
* _DOG: if true, a DOG pyramid is build
7474
*/
7575
Pyramid::Pyramid(const Mat & img, int octavesN_, int layersN_, float sigma0_, int omin_, bool _DOG) :
76-
params(octavesN_, layersN_, sigma0_, omin_)
76+
params(
77+
//Need to set the octavesN parameter globally. See issue #1513
78+
MIN(octavesN_, int(floor(log((double)MIN(img.size().width, img.size().height)) / log(2.0f)))),
79+
layersN_,
80+
sigma0_,
81+
omin_
82+
)
7783
{
7884
build(img, _DOG);
7985
}
@@ -89,9 +95,6 @@ void Pyramid::build(const Mat& img, bool DOG)
8995
Size ksize(0, 0);
9096
int gsize;
9197

92-
Size imgSize = img.size();
93-
int minSize = MIN(imgSize.width, imgSize.height);
94-
int octavesN = MIN(params.octavesN, int(floor(log((double) minSize)/log((float)2))));
9598
float sigma0 = params.sigma0;
9699
float sigma = sigma0;
97100
int layersN = params.layersN + 3;
@@ -165,7 +168,7 @@ void Pyramid::build(const Mat& img, bool DOG)
165168
/*for every octave build layers*/
166169
sigma_prev = sigma;
167170

168-
for (octave = 0; octave < octavesN; octave++)
171+
for (octave = 0; octave < params.octavesN; octave++)
169172
{
170173
for (layer = 1; layer < layersN; layer++)
171174
{
@@ -411,7 +414,8 @@ void HarrisLaplaceFeatureDetector_Impl::detect(InputArray img, std::vector<KeyPo
411414
keypoints = std::vector<KeyPoint> (0);
412415

413416
/*Find Harris corners on each layer*/
414-
for (int octave = 0; octave <= numOctaves; octave++)
417+
//Use pyr.params.octavesN instead of numOctaves. See issue #1513
418+
for (int octave = 0; octave <= pyr.params.octavesN; octave++)
415419
{
416420
for (int layer = 1; layer <= num_layers; layer++)
417421
{

0 commit comments

Comments
 (0)