From 80947f2a82abb620628c5d7d68b2946b78cba637 Mon Sep 17 00:00:00 2001 From: Patrick Stotko Date: Tue, 16 Oct 2018 09:04:32 +0200 Subject: [PATCH 1/2] Fix wrong key point limit check and clamp the number of features in the last contributing level --- FriedLiver/Source/SiftGPU/SiftPyramid.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 { From df2788e5ad51f7dcd2eac1498d0ef8bd11cf67c9 Mon Sep 17 00:00:00 2001 From: Patrick Stotko Date: Tue, 16 Oct 2018 09:09:08 +0200 Subject: [PATCH 2/2] Replace hard-coded max number of features for SiftGPU with the global one and adjust it in the config file to preserve current behavior --- FriedLiver/Source/Bundler.cpp | 2 +- FriedLiver/zParametersBundlingDefault.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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;