Detect more loop closures from/to specific map ID only option (#1653)

* Detect more loop closures from/to specific map ID only option

* default value -1

* Added elapsed time

* Avoid loading ALL signatures in RAM, only load them when necessary

* Avoid creating flann index when initializing with Kp/NNStrategy>=3

* Setting opt params by default
This commit is contained in:
matlabbe
2026-02-13 10:49:12 -08:00
committed by GitHub
parent d6cf470402
commit 0ef907757b
6 changed files with 234 additions and 109 deletions
+28 -2
View File
@@ -855,6 +855,7 @@ void DatabaseViewer::restoreDefaultSettings()
ui_->checkBox_detectMore_intraSession->setChecked(true);
ui_->checkBox_detectMore_interSession->setChecked(true);
ui_->checkBox_opt_graph_as_guess->setChecked(true);
ui_->spinBox_fromToMapId->setValue(-1);
}
void DatabaseViewer::openDatabase()
@@ -4297,6 +4298,7 @@ void DatabaseViewer::detectMoreLoopClosures()
bool intraSession = ui_->checkBox_detectMore_intraSession->isChecked();
bool interSession = ui_->checkBox_detectMore_interSession->isChecked();
bool useOptimizedGraphAsGuess = ui_->checkBox_opt_graph_as_guess->isChecked();
int fromToMapId = ui_->spinBox_fromToMapId->value();
if(!interSession && !intraSession)
{
QMessageBox::warning(this, tr("Cannot detect more loop closures"), tr("Intra and inter session parameters are disabled! Enable one or both."));
@@ -4313,14 +4315,38 @@ void DatabaseViewer::detectMoreLoopClosures()
ui_->doubleSpinBox_detectMore_radius->value(),
ui_->doubleSpinBox_detectMore_angle->value()*CV_PI/180.0);
progressDialog->setMaximumSteps(progressDialog->maximumSteps()+(int)clusters.size());
progressDialog->appendText(tr("Looking for more loop closures, %1 clusters found.").arg(clusters.size()));
QApplication::processEvents();
if(progressDialog->isCanceled())
{
break;
}
progressDialog->appendText(tr("Looking for more loop closures: %1 clusters found.").arg(clusters.size()));
if(fromToMapId >=0)
{
for(std::multimap<int, int>::iterator iter=clusters.begin(); iter!=clusters.end();)
{
int mapId = uValue(mapIds_, iter->first, 0);
if(mapId != fromToMapId)
{
iter = clusters.erase(iter);
}
else {
++iter;
}
}
progressDialog->appendText(tr("Looking for more loop closures: filtered %1 clusters for map session %2.").arg(clusters.size()).arg(fromToMapId));
if(clusters.empty())
{
progressDialog->appendText(tr("No clusters belong to mapId %1, aborting!").arg(fromToMapId));
QApplication::processEvents();
break;
}
}
progressDialog->setMaximumSteps(progressDialog->maximumSteps()+(int)clusters.size());
QApplication::processEvents();
std::set<int> addedLinks;
int i=0;
for(std::multimap<int, int>::iterator iter=clusters.begin(); iter!= clusters.end() && !progressDialog->isCanceled(); ++iter, ++i)
+99 -79
View File
@@ -61,7 +61,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>307</width>
<width>364</width>
<height>389</height>
</rect>
</property>
@@ -392,7 +392,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>306</width>
<width>364</width>
<height>389</height>
</rect>
</property>
@@ -1722,7 +1722,7 @@
<item>
<widget class="QToolBox" name="toolBox">
<property name="currentIndex">
<number>1</number>
<number>2</number>
</property>
<widget class="QWidget" name="page_3">
<property name="geometry">
@@ -1885,8 +1885,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>518</width>
<height>1071</height>
<width>276</width>
<height>1598</height>
</rect>
</property>
<attribute name="label">
@@ -2604,15 +2604,22 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>222</width>
<height>306</height>
<y>-152</y>
<width>403</width>
<height>287</height>
</rect>
</property>
<attribute name="label">
<string>Detect more loop closures</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_10" columnstretch="0,1">
<item row="5" column="0">
<widget class="QCheckBox" name="checkBox_detectMore_interSession">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QDoubleSpinBox" name="doubleSpinBox_detectMore_radiusMin">
<property name="suffix">
@@ -2632,13 +2639,6 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_36">
<property name="text">
<string>Radius Min</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_32">
<property name="text">
@@ -2646,23 +2646,43 @@
</property>
</widget>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_29">
<item row="3" column="1">
<widget class="QLabel" name="label_31">
<property name="text">
<string>Radius Max</string>
<string>Iterations</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QSpinBox" name="spinBox_detectMore_iterations">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="checkBox_opt_graph_as_guess">
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="label_37">
<property name="text">
<string>Use optimized graph as guess</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
@@ -2673,25 +2693,6 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QDoubleSpinBox" name="doubleSpinBox_detectMore_angle">
<property name="suffix">
<string> degrees</string>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="maximum">
<double>180.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>30.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QDoubleSpinBox" name="doubleSpinBox_detectMore_radius">
<property name="suffix">
@@ -2711,18 +2712,18 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QSpinBox" name="spinBox_detectMore_iterations">
<property name="minimum">
<number>1</number>
<item row="8" column="0">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="maximum">
<number>100</number>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</spacer>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="checkBox_detectMore_intraSession">
@@ -2731,10 +2732,17 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_31">
<item row="0" column="1">
<widget class="QLabel" name="label_29">
<property name="text">
<string>Iterations</string>
<string>Radius Max</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_36">
<property name="text">
<string>Radius Min</string>
</property>
</widget>
</item>
@@ -2745,30 +2753,42 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="checkBox_detectMore_interSession">
<property name="text">
<string/>
<item row="2" column="0">
<widget class="QDoubleSpinBox" name="doubleSpinBox_detectMore_angle">
<property name="suffix">
<string> degrees</string>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="maximum">
<double>180.000000000000000</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>30.000000000000000</double>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="checkBox_opt_graph_as_guess">
<property name="text">
<string/>
<item row="7" column="0">
<widget class="QSpinBox" name="spinBox_fromToMapId">
<property name="minimum">
<number>-1</number>
</property>
<property name="checked">
<bool>true</bool>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>-1</number>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="label_37">
<item row="7" column="1">
<widget class="QLabel" name="label_38">
<property name="text">
<string>Use optimized graph as guess</string>
</property>
<property name="wordWrap">
<bool>true</bool>
<string>From/to map ID only (-1 is all)</string>
</property>
</widget>
</item>