Removed AutoUpdate parameter, not needed

This commit is contained in:
matlabbe
2026-07-17 15:43:02 -07:00
parent b27442a584
commit bc90058612
5 changed files with 30 additions and 32 deletions
@@ -264,7 +264,6 @@ class RTABMAP_CORE_EXPORT Parameters
RTABMAP_PARAM(Kp, NewWordsComparedTogether, bool, true, "When adding new words to dictionary, they are compared also with each other (to detect same words in the same signature).");
RTABMAP_PARAM(Kp, FlannIndexSaved, bool, false, uFormat("Save FLANN index during localization session (when %s=false). The FLANN index will be saved to database after the first time localization mode is used, then on next sessions, the index is reloaded from the database instead of being rebuilt again. This can save significant loading time when the visual word dictionary is big (>1M words). Note that if the dictionary is modified (parameters or data), the index will be rebuilt and saved again on the next session. Ignored on initialization if %s is enabled.", kMemIncrementalMemory().c_str(), kMemInitWMWithAllNodes().c_str()).c_str());
RTABMAP_PARAM(Kp, SerializeWithChecksum, bool, true, "On serialization of the FLANN index, compute checksum of the data used by the FLANN index. This adds a slight overhead on serialization/deserialization to make sure that the dictionary data correspond to same data used when the index was built.");
RTABMAP_PARAM(Kp, AutoUpdate, bool, true, "Automatically update on any parameter changes affecting the structure of the dictionary. Otherwise, it is updated only when triggered externally (i.e., deferring initialization time).");
RTABMAP_PARAM(Kp, SubPixWinSize, int, 3, "See cv::cornerSubPix().");
RTABMAP_PARAM(Kp, SubPixIterations, int, 0, "See cv::cornerSubPix(). 0 disables sub pixel refining.");
RTABMAP_PARAM(Kp, SubPixEps, double, 0.02, "See cv::cornerSubPix().");
+26 -9
View File
@@ -435,10 +435,14 @@ void Memory::loadDataFromDb(bool postInitClosingEvents)
_dbDriver->getLastWordId(id);
_vwd->setLastWordId(id);
}
else {
_dummyDictionary = false;
}
}
else
{
_dbDriver->load(*_vwd, false);
_dummyDictionary = false;
}
}
else
@@ -446,6 +450,7 @@ void Memory::loadDataFromDb(bool postInitClosingEvents)
if(_dummyDictionary)
{
UWARN("A dummy dictionary is requested but %s is false, loading the dictionary as usual.", Parameters::kMemInitWMWithAllNodes().c_str());
_dummyDictionary = false;
}
UDEBUG("load words");
// load the last dictionary
@@ -453,11 +458,11 @@ void Memory::loadDataFromDb(bool postInitClosingEvents)
}
UDEBUG("%d words loaded!", _vwd->getUnusedWordsSize());
UDEBUG("Dictionary memory usage: %ld Bytes", _vwd->getMemoryUsed());
if(_vwd->isAutoUpdateEnabled()) {
if(!_dummyDictionary) {
_vwd->update();
}
else {
UDEBUG("Dictionary update skipped (%s=true)", Parameters::kKpAutoUpdate().c_str());
UDEBUG("Dictionary update skipped (dummy dictionary is enabled)");
}
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(uFormat("Loading dictionary, done! (%d words)", (int)_vwd->getUnusedWordsSize())));
@@ -519,6 +524,24 @@ void Memory::loadDataFromDb(bool postInitClosingEvents)
UWARN("%s", msg.c_str());
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(msg));
if(_dummyDictionary)
{
UWARN("Dummy dictionary cannot be used when repairing the dictionary, disabling dummy dictionary.");
for(std::map<int, Signature *>::const_iterator i=signatures.begin(); i!=signatures.end(); ++i)
{
Signature * s = this->_getSignature(i->first);
UASSERT(s != 0);
if(!s->isEnabled())
{
break;
}
this->disableWordsRef(s->id());
}
_vwd->deleteUnusedWords();
_vwd->clear();
_dummyDictionary = false;
}
//remove all words ref
const std::map<int, VisualWord *> & addedWords = _vwd->getVisualWords();
@@ -584,12 +607,7 @@ void Memory::loadDataFromDb(bool postInitClosingEvents)
UWARN("%s", msg.c_str());
if(postInitClosingEvents) UEventsManager::post(new RtabmapEventInit(msg));
_memoryChanged = true; // This will force rtabmap to save back the dictionary even if we don't process any new data
if(_vwd->isAutoUpdateEnabled()) {
_vwd->update();
}
else {
UDEBUG("Dictionary update skipped (%s=true)", Parameters::kKpAutoUpdate().c_str());
}
_vwd->update();
}
}
@@ -636,7 +654,6 @@ void Memory::setDummyDictionary(bool enabled)
UINFO("Dummy dictionary disabled.");
}
_dummyDictionary = enabled;
_vwd->setAutoUpdate(!_dummyDictionary);
}
void Memory::saveFlannIndex(bool postInitClosingEvents)
+4 -20
View File
@@ -73,8 +73,7 @@ VWDictionary::VWDictionary(const ParametersMap & parameters) :
useDistanceL1_(false),
_flannIndex(new FlannIndex()),
_modified(true),
_strategy(kNNBruteForce),
_autoUpdate(true)
_strategy(kNNBruteForce)
{
this->setNNStrategy((NNStrategy)Parameters::defaultKpNNStrategy());
this->parseParameters(parameters);
@@ -122,12 +121,7 @@ void VWDictionary::parseParameters(const ParametersMap & parameters)
_dataTree = cv::Mat();
_notIndexedWords = uKeysSet(_visualWords);
_removedIndexedWords.clear();
if(_autoUpdate) {
this->update();
}
else {
UDEBUG("Dictionary update skipped (%s=true)", Parameters::kKpAutoUpdate().c_str());
}
this->update();
}
if(incrementalDictionary)
@@ -272,12 +266,7 @@ void VWDictionary::setFixedDictionary(const std::string & dictionaryPath)
_dictionaryPath = dictionaryPath;
_newDictionaryPath = dictionaryPath;
_incrementalDictionary = false;
if(_autoUpdate) {
this->update();
}
else {
UDEBUG("Dictionary update skipped (%s=true)", Parameters::kKpAutoUpdate().c_str());
}
this->update();
UWARN("Loaded %d words!", (int)_visualWords.size());
}
}
@@ -356,12 +345,7 @@ bool VWDictionary::setNNStrategy(NNStrategy strategy)
_dataTree = cv::Mat();
_notIndexedWords = uKeysSet(_visualWords);
_removedIndexedWords.clear();
if(_autoUpdate) {
this->update();
}
else {
UDEBUG("Dictionary update skipped (%s=true)", Parameters::kKpAutoUpdate().c_str());
}
this->update();
return true;
}
return false;
-1
View File
@@ -198,7 +198,6 @@ int main(int argc, char * argv[])
// Add some optimizations (soft set, can be overriden by arguments)
inputParams.insert(ParametersPair(Parameters::kMemLoadVisualLocalFeaturesOnInit(), "false")); // don't need features already loaded in RAM
inputParams.insert(ParametersPair(Parameters::kMemIncrementalMemory(), "true")); // should be incremental to update links
inputParams.insert(ParametersPair(Parameters::kKpAutoUpdate(), "false")); // don't build the dictionary (don't need it)
std::string dbPath = argv[argc-1];
if(!UFile::exists(dbPath))
-1
View File
@@ -154,7 +154,6 @@ int main(int argc, char * argv[])
ParametersMap inputParams;
inputParams.insert(ParametersPair(Parameters::kMemInitWMWithAllNodes(), "true")); // load the whole map in RAM
inputParams.insert(ParametersPair(Parameters::kMemLoadVisualLocalFeaturesOnInit(), "false")); // don't need features already loaded in RAM
inputParams.insert(ParametersPair(Parameters::kKpAutoUpdate(), "false")); // don't build the dictionary (don't need it)
std::string dbPath = argv[argc-1];
if(!UFile::exists(dbPath))