PostProcessingDialog.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
29 #include "ui_postProcessingDialog.h"
30 
31 #include <QPushButton>
32 #include <QMessageBox>
33 #include <rtabmap/core/Optimizer.h>
34 
35 namespace rtabmap {
36 
38  QDialog(parent)
39 {
40  _ui = new Ui_PostProcessingDialog();
41  _ui->setupUi(this);
42 
46  {
47  _ui->sba->setEnabled(false);
48  _ui->sba->setChecked(false);
49  }
50  else
51  {
53  {
54  _ui->comboBox_sbaType->setItemData(1, 0, Qt::UserRole - 1);
55  _ui->comboBox_sbaType->setCurrentIndex(0);
56  }
58  {
59  _ui->comboBox_sbaType->setItemData(0, 0, Qt::UserRole - 1);
60  _ui->comboBox_sbaType->setCurrentIndex(1);
61  }
63  {
64  _ui->comboBox_sbaType->setItemData(2, 0, Qt::UserRole - 1);
65  _ui->comboBox_sbaType->setCurrentIndex(1);
66  }
67  }
68 
70 
71  connect(_ui->buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(closeDialog(QAbstractButton *)));
72 
73  connect(_ui->detectMoreLoopClosures, SIGNAL(clicked(bool)), this, SLOT(updateButtonBox()));
74  connect(_ui->refineNeighborLinks, SIGNAL(stateChanged(int)), this, SLOT(updateButtonBox()));
75  connect(_ui->refineLoopClosureLinks, SIGNAL(stateChanged(int)), this, SLOT(updateButtonBox()));
76  connect(_ui->sba, SIGNAL(clicked(bool)), this, SLOT(updateButtonBox()));
77  connect(_ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked()), this, SLOT(restoreDefaults()));
78 
79  connect(_ui->detectMoreLoopClosures, SIGNAL(clicked(bool)), this, SIGNAL(configChanged()));
80  connect(_ui->clusterRadius, SIGNAL(valueChanged(double)), this, SIGNAL(configChanged()));
81  connect(_ui->clusterAngle, SIGNAL(valueChanged(double)), this, SIGNAL(configChanged()));
82  connect(_ui->iterations, SIGNAL(valueChanged(int)), this, SIGNAL(configChanged()));
83  connect(_ui->intraSession, SIGNAL(stateChanged(int)), this, SIGNAL(configChanged()));
84  connect(_ui->interSession, SIGNAL(stateChanged(int)), this, SIGNAL(configChanged()));
85  connect(_ui->refineNeighborLinks, SIGNAL(stateChanged(int)), this, SIGNAL(configChanged()));
86  connect(_ui->refineLoopClosureLinks, SIGNAL(stateChanged(int)), this, SIGNAL(configChanged()));
87 
88  connect(_ui->sba, SIGNAL(clicked(bool)), this, SIGNAL(configChanged()));
89  connect(_ui->sba_iterations, SIGNAL(valueChanged(int)), this, SIGNAL(configChanged()));
90  connect(_ui->comboBox_sbaType, SIGNAL(currentIndexChanged(int)), this, SIGNAL(configChanged()));
91  connect(_ui->comboBox_sbaType, SIGNAL(currentIndexChanged(int)), this, SLOT(updateVisibility()));
92  connect(_ui->sba_rematchFeatures, SIGNAL(stateChanged(int)), this, SIGNAL(configChanged()));
93 
95 }
96 
98 {
99  delete _ui;
100 }
101 
102 void PostProcessingDialog::closeDialog ( QAbstractButton * button )
103 {
104  UDEBUG("");
105 
106  QDialogButtonBox::ButtonRole role = _ui->buttonBox->buttonRole(button);
107  switch(role)
108  {
109  case QDialogButtonBox::RejectRole:
110  this->reject();
111  break;
112 
113  case QDialogButtonBox::AcceptRole:
114  if(validateForm())
115  {
116  this->accept();
117  }
118  break;
119 
120  default:
121  break;
122  }
123 }
124 
126 {
127  if(_ui->detectMoreLoopClosures->isChecked() && !this->intraSession() && !this->interSession())
128  {
129  QMessageBox::warning(this, tr("Configuration error"), tr("Intra-session and inter-session parameters cannot be both disabled at the same time. Please select one (or both)."));
130  return false;
131  }
132  return true;
133 }
134 
136 {
137  _ui->sba_variance->setVisible(_ui->comboBox_sbaType->currentIndex() == 0);
138  _ui->label_variance->setVisible(_ui->comboBox_sbaType->currentIndex() == 0);
139 }
140 
141 void PostProcessingDialog::saveSettings(QSettings & settings, const QString & group) const
142 {
143  if(!group.isEmpty())
144  {
145  settings.beginGroup(group);
146  }
147  settings.setValue("detect_more_lc", this->isDetectMoreLoopClosures());
148  settings.setValue("cluster_radius", this->clusterRadius());
149  settings.setValue("cluster_angle", this->clusterAngle());
150  settings.setValue("iterations", this->iterations());
151  settings.setValue("intra_session", this->intraSession());
152  settings.setValue("inter_session", this->interSession());
153  settings.setValue("refine_neigbors", this->isRefineNeighborLinks());
154  settings.setValue("refine_lc", this->isRefineLoopClosureLinks());
155  settings.setValue("sba", this->isSBA());
156  settings.setValue("sba_iterations", this->sbaIterations());
157  settings.setValue("sba_type", this->sbaType());
158  settings.setValue("sba_variance", this->sbaVariance());
159  settings.setValue("sba_rematch_features", this->sbaRematchFeatures());
160  if(!group.isEmpty())
161  {
162  settings.endGroup();
163  }
164 }
165 
166 void PostProcessingDialog::loadSettings(QSettings & settings, const QString & group)
167 {
168  if(!group.isEmpty())
169  {
170  settings.beginGroup(group);
171  }
172  this->setDetectMoreLoopClosures(settings.value("detect_more_lc", this->isDetectMoreLoopClosures()).toBool());
173  this->setClusterRadius(settings.value("cluster_radius", this->clusterRadius()).toDouble());
174  this->setClusterAngle(settings.value("cluster_angle", this->clusterAngle()).toDouble());
175  this->setIterations(settings.value("iterations", this->iterations()).toInt());
176  this->setIntraSession(settings.value("intra_session", this->intraSession()).toBool());
177  this->setInterSession(settings.value("inter_session", this->interSession()).toBool());
178  this->setRefineNeighborLinks(settings.value("refine_neigbors", this->isRefineNeighborLinks()).toBool());
179  this->setRefineLoopClosureLinks(settings.value("refine_lc", this->isRefineLoopClosureLinks()).toBool());
180  this->setSBA(settings.value("sba", this->isSBA()).toBool());
181  this->setSBAIterations(settings.value("sba_iterations", this->sbaIterations()).toInt());
182  this->setSBAType((Optimizer::Type)settings.value("sba_type", this->sbaType()).toInt());
183  this->setSBAVariance(settings.value("sba_variance", this->sbaVariance()).toDouble());
184  this->setSBARematchFeatures(settings.value("sba_rematch_features", this->sbaRematchFeatures()).toBool());
185 
186  if(!group.isEmpty())
187  {
188  settings.endGroup();
189  }
190 }
191 
193 {
195  setClusterRadius(1);
196  setClusterAngle(30);
197  setIterations(5);
198  setIntraSession(true);
199  setInterSession(true);
200  setRefineNeighborLinks(false);
202  setSBA(false);
203  setSBAIterations(20);
206  {
208  {
210  }
212  {
214  }
215  }
217  setSBAVariance(1.0);
218  setSBARematchFeatures(true);
219 }
220 
222 {
223  _ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
225 }
226 
228 {
229  return _ui->detectMoreLoopClosures->isChecked();
230 }
231 
233 {
234  return _ui->clusterRadius->value();
235 }
236 
238 {
239  return _ui->clusterAngle->value();
240 }
241 
243 {
244  return _ui->iterations->value();
245 }
246 
248 {
249  return _ui->intraSession->isChecked();
250 }
251 
253 {
254  return _ui->interSession->isChecked();
255 }
256 
258 {
259  return _ui->refineNeighborLinks->isChecked();
260 }
261 
263 {
264  return _ui->refineLoopClosureLinks->isChecked();
265 }
266 
268 {
269  return _ui->sba->isEnabled() && _ui->sba->isChecked();
270 }
271 
273 {
274  return _ui->sba_iterations->value();
275 }
277 {
278  return _ui->sba_variance->value();
279 }
281 {
282  return _ui->comboBox_sbaType->currentIndex()==2?Optimizer::kTypeCeres:_ui->comboBox_sbaType->currentIndex()==1?Optimizer::kTypeCVSBA:Optimizer::kTypeG2O;
283 }
285 {
286  return _ui->sba_rematchFeatures->isChecked();
287 }
288 
289 //setters
291 {
292  _ui->detectMoreLoopClosures->setChecked(on);
293 }
295 {
296  _ui->clusterRadius->setValue(radius);
297 }
299 {
300  _ui->clusterAngle->setValue(angle);
301 }
303 {
304  _ui->iterations->setValue(iterations);
305 }
307 {
308  _ui->intraSession->setChecked(enabled);
309 }
311 {
312  _ui->interSession->setChecked(enabled);
313 }
315 {
316  _ui->refineNeighborLinks->setChecked(on);
317 }
319 {
320  _ui->refineLoopClosureLinks->setChecked(on);
321 }
323 {
324  _ui->sba->setChecked((
328 }
330 {
331  _ui->sba_iterations->setValue(iterations);
332 }
334 {
335  _ui->sba_variance->setValue(variance);
336 }
338 {
340  {
341  _ui->comboBox_sbaType->setCurrentIndex(2);
342  }
343  else if(type == Optimizer::kTypeCVSBA)
344  {
345  _ui->comboBox_sbaType->setCurrentIndex(1);
346  }
347  else
348  {
349  _ui->comboBox_sbaType->setCurrentIndex(0);
350  }
351 }
353 {
354  _ui->sba_rematchFeatures->setChecked(value);
355 }
356 
357 
358 }
rtabmap::Optimizer::isAvailable
static bool isAvailable(Optimizer::Type type)
Definition: Optimizer.cpp:47
rtabmap::PostProcessingDialog::sbaIterations
int sbaIterations() const
Definition: PostProcessingDialog.cpp:272
rtabmap::PostProcessingDialog::clusterRadius
double clusterRadius() const
Definition: PostProcessingDialog.cpp:232
rtabmap::PostProcessingDialog::isSBA
bool isSBA() const
Definition: PostProcessingDialog.cpp:267
rtabmap::PostProcessingDialog::intraSession
bool intraSession() const
Definition: PostProcessingDialog.cpp:247
rtabmap::PostProcessingDialog::setIntraSession
void setIntraSession(bool enabled)
Definition: PostProcessingDialog.cpp:306
rtabmap::PostProcessingDialog::setSBAType
void setSBAType(Optimizer::Type type)
Definition: PostProcessingDialog.cpp:337
this
this
PostProcessingDialog.h
type
rtabmap::PostProcessingDialog::sbaType
Optimizer::Type sbaType() const
Definition: PostProcessingDialog.cpp:280
rtabmap::Optimizer::kTypeCVSBA
@ kTypeCVSBA
Definition: Optimizer.h:70
rtabmap::PostProcessingDialog::setInterSession
void setInterSession(bool enabled)
Definition: PostProcessingDialog.cpp:310
rtabmap::PostProcessingDialog::updateVisibility
void updateVisibility()
Definition: PostProcessingDialog.cpp:135
rtabmap::PostProcessingDialog::sbaVariance
double sbaVariance() const
Definition: PostProcessingDialog.cpp:276
rtabmap::PostProcessingDialog::setIterations
void setIterations(int iterations)
Definition: PostProcessingDialog.cpp:302
rtabmap::PostProcessingDialog::PostProcessingDialog
PostProcessingDialog(QWidget *parent=0)
Definition: PostProcessingDialog.cpp:37
rtabmap::Optimizer::Type
Type
Definition: Optimizer.h:64
rtabmap::PostProcessingDialog::clusterAngle
double clusterAngle() const
Definition: PostProcessingDialog.cpp:237
rtabmap::PostProcessingDialog::setSBAIterations
void setSBAIterations(int iterations)
Definition: PostProcessingDialog.cpp:329
Optimizer.h
rtabmap::PostProcessingDialog::setSBAVariance
void setSBAVariance(double variance)
Definition: PostProcessingDialog.cpp:333
rtabmap::PostProcessingDialog::validateForm
bool validateForm()
Definition: PostProcessingDialog.cpp:125
rtabmap::PostProcessingDialog::iterations
int iterations() const
Definition: PostProcessingDialog.cpp:242
rtabmap::PostProcessingDialog::closeDialog
void closeDialog(QAbstractButton *button)
Definition: PostProcessingDialog.cpp:102
glm::angle
GLM_FUNC_DECL T angle(detail::tquat< T, P > const &x)
rtabmap::PostProcessingDialog::setClusterAngle
void setClusterAngle(double angle)
Definition: PostProcessingDialog.cpp:298
rtabmap::PostProcessingDialog::isDetectMoreLoopClosures
bool isDetectMoreLoopClosures() const
Definition: PostProcessingDialog.cpp:227
rtabmap::PostProcessingDialog::setDetectMoreLoopClosures
void setDetectMoreLoopClosures(bool on)
Definition: PostProcessingDialog.cpp:290
rtabmap::PostProcessingDialog::loadSettings
void loadSettings(QSettings &settings, const QString &group="")
Definition: PostProcessingDialog.cpp:166
rtabmap::PostProcessingDialog::isRefineLoopClosureLinks
bool isRefineLoopClosureLinks() const
Definition: PostProcessingDialog.cpp:262
rtabmap::PostProcessingDialog::interSession
bool interSession() const
Definition: PostProcessingDialog.cpp:252
rtabmap::PostProcessingDialog::saveSettings
void saveSettings(QSettings &settings, const QString &group="") const
Definition: PostProcessingDialog.cpp:141
UDEBUG
#define UDEBUG(...)
rtabmap::PostProcessingDialog::~PostProcessingDialog
virtual ~PostProcessingDialog()
Definition: PostProcessingDialog.cpp:97
rtabmap::PostProcessingDialog::setRefineNeighborLinks
void setRefineNeighborLinks(bool on)
Definition: PostProcessingDialog.cpp:314
rtabmap::PostProcessingDialog::setRefineLoopClosureLinks
void setRefineLoopClosureLinks(bool on)
Definition: PostProcessingDialog.cpp:318
rtabmap::Optimizer::kTypeG2O
@ kTypeG2O
Definition: Optimizer.h:67
rtabmap::PostProcessingDialog::_ui
Ui_PostProcessingDialog * _ui
Definition: PostProcessingDialog.h:100
rtabmap::PostProcessingDialog::configChanged
void configChanged()
rtabmap::PostProcessingDialog::isRefineNeighborLinks
bool isRefineNeighborLinks() const
Definition: PostProcessingDialog.cpp:257
rtabmap::Optimizer::kTypeCeres
@ kTypeCeres
Definition: Optimizer.h:69
rtabmap
Definition: CameraARCore.cpp:35
rtabmap::PostProcessingDialog::sbaRematchFeatures
bool sbaRematchFeatures() const
Definition: PostProcessingDialog.cpp:284
value
value
rtabmap::PostProcessingDialog::setSBARematchFeatures
void setSBARematchFeatures(bool value)
Definition: PostProcessingDialog.cpp:352
rtabmap::PostProcessingDialog::restoreDefaults
void restoreDefaults()
Definition: PostProcessingDialog.cpp:192
rtabmap::PostProcessingDialog::setClusterRadius
void setClusterRadius(double radius)
Definition: PostProcessingDialog.cpp:294
rtabmap::PostProcessingDialog::setSBA
void setSBA(bool on)
Definition: PostProcessingDialog.cpp:322
rtabmap::PostProcessingDialog::updateButtonBox
void updateButtonBox()
Definition: PostProcessingDialog.cpp:221


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:14