From bce863ec277a74783acec0630735b1ff0a0c5977 Mon Sep 17 00:00:00 2001 From: Check Deng Date: Sat, 4 May 2019 19:24:35 +0800 Subject: [PATCH] Add max iteration times --- src/Vocabulary.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Vocabulary.cpp b/src/Vocabulary.cpp index 9f0eff3..971a913 100644 --- a/src/Vocabulary.cpp +++ b/src/Vocabulary.cpp @@ -3,10 +3,12 @@ #include "quicklz.h" #include #include "timers.h" + +const int MAX_ITERATION = 100; + namespace DBoW3{ // -------------------------------------------------------------------------- - Vocabulary::Vocabulary (int k, int L, WeightingType weighting, ScoringType scoring) : m_k(k), m_L(L), m_weighting(weighting), m_scoring(scoring), @@ -263,9 +265,11 @@ void Vocabulary::HKmeansStep(NodeId parent_id, // to check if clusters move after iterations std::vector last_association, current_association; - - while(goon) + + int count = 0; + while(goon && count < MAX_ITERATION) { + count++; // 1. Calculate clusters if(first_time)