diff --git a/FriedLiver/Source/Bundler.cpp b/FriedLiver/Source/Bundler.cpp index 8d0f892c..818945ff 100644 --- a/FriedLiver/Source/Bundler.cpp +++ b/FriedLiver/Source/Bundler.cpp @@ -58,7 +58,7 @@ void Bundler::initSift(unsigned int widthSift, unsigned int heightSift, bool isL { if (isLocal) { m_sift = new SiftGPU; - m_sift->SetParams(widthSift, heightSift, false, 150, GlobalAppState::get().s_sensorDepthMin, GlobalAppState::get().s_sensorDepthMax); + m_sift->SetParams(widthSift, heightSift, false, GlobalBundlingState::get().s_maxNumKeysPerImage, GlobalAppState::get().s_sensorDepthMin, GlobalAppState::get().s_sensorDepthMax); m_sift->InitSiftGPU(); } else { diff --git a/FriedLiver/Source/SiftGPU/SiftPyramid.cpp b/FriedLiver/Source/SiftGPU/SiftPyramid.cpp index c4fe4c6c..e92dba0c 100644 --- a/FriedLiver/Source/SiftGPU/SiftPyramid.cpp +++ b/FriedLiver/Source/SiftGPU/SiftPyramid.cpp @@ -245,12 +245,21 @@ void SiftPyramid::LimitFeatureCount(int have_keylist) else { int i = 0, num_to_erase = 0; + //remove remaining levels before the number of features drops below the threshold. while (_featureNum - _levelFeatureNum[i] > _FeatureCountThreshold) { num_to_erase += _levelFeatureNum[i]; _featureNum -= _levelFeatureNum[i]; _levelFeatureNum[i++] = 0; } + //clamp number of features in the last contributing level. + if (_featureNum > _FeatureCountThreshold) + { + int num_to_erase_last = _featureNum - _FeatureCountThreshold; + num_to_erase += num_to_erase_last; + _featureNum -= num_to_erase_last; + _levelFeatureNum[i] -= num_to_erase_last; + } } } @@ -745,7 +754,7 @@ void SiftPyramid::CreateGlobalKeyPointList(float4* d_keypoints, const float* d_d //if needed, eliminate lower level keypoints first std::vector numKeysPerLevel(n, 0); int cur = 0; - const bool bHasMax = maxNumKeyPoints == (unsigned int)-1; + const bool bHasMax = maxNumKeyPoints != (unsigned int)-1; for (int i = n - 1; i >= 0; i--) { if (!bHasMax) numKeysPerLevel[i] = _levelFeatureNum[i]; else { diff --git a/FriedLiver/zParametersBundlingDefault.txt b/FriedLiver/zParametersBundlingDefault.txt index 7b899a8f..7d26d25b 100644 --- a/FriedLiver/zParametersBundlingDefault.txt +++ b/FriedLiver/zParametersBundlingDefault.txt @@ -29,7 +29,7 @@ s_denseOverlapCheckSubsampleFactor = 4; s_maxNumImages = 1200; s_submapSize = 10; -s_maxNumKeysPerImage = 1024; +s_maxNumKeysPerImage = 150; s_useLocalDense = true; s_numOptPerResidualRemoval = 1;