mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-04 00:57:46 +08:00
Aligned BundleAdjustment parameters with Optimizer/Strategy to avoid confusion in the code
This commit is contained in:
@@ -517,9 +517,9 @@ class RTABMAP_CORE_EXPORT Parameters
|
|||||||
RTABMAP_PARAM(OdomF2M, ScanRange, float, 0, "[Geometry] Distance Range used to filter points of local map (when > 0). 0 means local map is updated using time and not range.");
|
RTABMAP_PARAM(OdomF2M, ScanRange, float, 0, "[Geometry] Distance Range used to filter points of local map (when > 0). 0 means local map is updated using time and not range.");
|
||||||
RTABMAP_PARAM(OdomF2M, ValidDepthRatio, float, 0.75, "If a new frame has points without valid depth, they are added to local feature map only if points with valid depth on total points is over this ratio. Setting to 1 means no points without valid depth are added to local feature map.");
|
RTABMAP_PARAM(OdomF2M, ValidDepthRatio, float, 0.75, "If a new frame has points without valid depth, they are added to local feature map only if points with valid depth on total points is over this ratio. Setting to 1 means no points without valid depth are added to local feature map.");
|
||||||
#if defined(RTABMAP_G2O) || defined(RTABMAP_ORB_SLAM)
|
#if defined(RTABMAP_G2O) || defined(RTABMAP_ORB_SLAM)
|
||||||
RTABMAP_PARAM(OdomF2M, BundleAdjustment, int, 1, "Local bundle adjustment: 0=disabled, 1=g2o, 2=cvsba, 3=Ceres.");
|
RTABMAP_PARAM(OdomF2M, BundleAdjustment, int, 1, uFormat("Local bundle adjustment. Value matches the %s parameter: 0=disabled (TORO is not BA-capable), 1=g2o, 2=GTSAM, 3=Ceres, 4=cvsba.", kOptimizerStrategy().c_str()));
|
||||||
#else
|
#else
|
||||||
RTABMAP_PARAM(OdomF2M, BundleAdjustment, int, 0, "Local bundle adjustment: 0=disabled, 1=g2o, 2=cvsba, 3=Ceres.");
|
RTABMAP_PARAM(OdomF2M, BundleAdjustment, int, 0, uFormat("Local bundle adjustment. Value matches the %s parameter: 0=disabled (TORO is not BA-capable), 1=g2o, 2=GTSAM, 3=Ceres, 4=cvsba.", kOptimizerStrategy().c_str()));
|
||||||
#endif
|
#endif
|
||||||
RTABMAP_PARAM(OdomF2M, BundleAdjustmentMaxFrames, int, 10, "Maximum frames used for bundle adjustment (0=inf or all current frames in the local map).");
|
RTABMAP_PARAM(OdomF2M, BundleAdjustmentMaxFrames, int, 10, "Maximum frames used for bundle adjustment (0=inf or all current frames in the local map).");
|
||||||
RTABMAP_PARAM(OdomF2M, BundleAdjustmentMinMotion, float, 0.0, "To create a new keyframe with bundle adjustment, a minimum motion (in pixels) can be required. The motion is computed by the average distance between inliers of the previous keyframe and new frame.");
|
RTABMAP_PARAM(OdomF2M, BundleAdjustmentMinMotion, float, 0.0, "To create a new keyframe with bundle adjustment, a minimum motion (in pixels) can be required. The motion is computed by the average distance between inliers of the previous keyframe and new frame.");
|
||||||
@@ -780,9 +780,9 @@ class RTABMAP_CORE_EXPORT Parameters
|
|||||||
RTABMAP_PARAM(Vis, CorFlowErrorThreshold, float, 20, uFormat("[%s=false] Filter out features with error greater than this threshold.", kVisCorFlowUseMinEigenVals().c_str()));
|
RTABMAP_PARAM(Vis, CorFlowErrorThreshold, float, 20, uFormat("[%s=false] Filter out features with error greater than this threshold.", kVisCorFlowUseMinEigenVals().c_str()));
|
||||||
RTABMAP_PARAM(Vis, CorFlowGpu, bool, false, uFormat("[%s=1] Enable GPU version of the optical flow approach (only available if OpenCV is built with CUDA). Note that %s is not used in the GPU implementation.", kVisCorType().c_str(), kVisCorFlowUseMinEigenVals().c_str()));
|
RTABMAP_PARAM(Vis, CorFlowGpu, bool, false, uFormat("[%s=1] Enable GPU version of the optical flow approach (only available if OpenCV is built with CUDA). Note that %s is not used in the GPU implementation.", kVisCorType().c_str(), kVisCorFlowUseMinEigenVals().c_str()));
|
||||||
#if defined(RTABMAP_G2O) || defined(RTABMAP_ORB_SLAM)
|
#if defined(RTABMAP_G2O) || defined(RTABMAP_ORB_SLAM)
|
||||||
RTABMAP_PARAM(Vis, BundleAdjustment, int, 1, "Optimization with bundle adjustment: 0=disabled, 1=g2o, 2=cvsba, 3=Ceres.");
|
RTABMAP_PARAM(Vis, BundleAdjustment, int, 1, uFormat("Optimization with bundle adjustment. Value matches the %s parameter: 0=disabled (TORO is not BA-capable), 1=g2o, 2=GTSAM, 3=Ceres, 4=cvsba.", kOptimizerStrategy().c_str()));
|
||||||
#else
|
#else
|
||||||
RTABMAP_PARAM(Vis, BundleAdjustment, int, 0, "Optimization with bundle adjustment: 0=disabled, 1=g2o, 2=cvsba, 3=Ceres.");
|
RTABMAP_PARAM(Vis, BundleAdjustment, int, 0, uFormat("Optimization with bundle adjustment. Value matches the %s parameter: 0=disabled (TORO is not BA-capable), 1=g2o, 2=GTSAM, 3=Ceres, 4=cvsba.", kOptimizerStrategy().c_str()));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Features matching approaches
|
// Features matching approaches
|
||||||
|
|||||||
@@ -1880,7 +1880,10 @@ Transform RegistrationVis::computeTransformationImpl(
|
|||||||
(toSignature.sensorData().stereoCameraModels().size() >= 1 || toSignature.sensorData().cameraModels().size() >= 1))
|
(toSignature.sensorData().stereoCameraModels().size() >= 1 || toSignature.sensorData().cameraModels().size() >= 1))
|
||||||
{
|
{
|
||||||
UDEBUG("Refine with bundle adjustment");
|
UDEBUG("Refine with bundle adjustment");
|
||||||
Optimizer * sba = Optimizer::create(_bundleAdjustment==3?Optimizer::kTypeCeres:_bundleAdjustment==2?Optimizer::kTypeCVSBA:Optimizer::kTypeG2O, _bundleParameters);
|
// _bundleAdjustment matches the Optimizer/Strategy parameter 1:1
|
||||||
|
// (1=g2o, 2=GTSAM, 3=Ceres, 4=cvsba); 0 was filtered out above.
|
||||||
|
Optimizer * sba = Optimizer::create(
|
||||||
|
static_cast<Optimizer::Type>(_bundleAdjustment), _bundleParameters);
|
||||||
|
|
||||||
std::map<int, Transform> poses;
|
std::map<int, Transform> poses;
|
||||||
std::multimap<int, Link> links;
|
std::multimap<int, Link> links;
|
||||||
|
|||||||
@@ -110,13 +110,15 @@ OdometryF2M::OdometryF2M(const ParametersMap & parameters) :
|
|||||||
ParametersMap bundleParameters = parameters;
|
ParametersMap bundleParameters = parameters;
|
||||||
if(bundleAdjustment_ > 0)
|
if(bundleAdjustment_ > 0)
|
||||||
{
|
{
|
||||||
if((bundleAdjustment_==1 && Optimizer::isAvailable(Optimizer::kTypeG2O)) ||
|
// The BundleAdjustment int matches the Optimizer/Strategy parameter
|
||||||
(bundleAdjustment_==2 && Optimizer::isAvailable(Optimizer::kTypeCVSBA)) ||
|
// 1:1 (g2o=1, GTSAM=2, Ceres=3, CVSBA=4). 0 = "disabled" -- it's
|
||||||
(bundleAdjustment_==3 && Optimizer::isAvailable(Optimizer::kTypeCeres)))
|
// the TORO slot, which isn't BA-capable.
|
||||||
|
const Optimizer::Type sbaType = static_cast<Optimizer::Type>(bundleAdjustment_);
|
||||||
|
if(Optimizer::isAvailable(sbaType))
|
||||||
{
|
{
|
||||||
// disable bundle in RegistrationVis as we do it already here
|
// disable bundle in RegistrationVis as we do it already here
|
||||||
uInsert(bundleParameters, ParametersPair(Parameters::kVisBundleAdjustment(), "0"));
|
uInsert(bundleParameters, ParametersPair(Parameters::kVisBundleAdjustment(), "0"));
|
||||||
sba_ = Optimizer::create(bundleAdjustment_==3?Optimizer::kTypeCeres:bundleAdjustment_==2?Optimizer::kTypeCVSBA:Optimizer::kTypeG2O, bundleParameters);
|
sba_ = Optimizer::create(sbaType, bundleParameters);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,30 +40,28 @@ PostProcessingDialog::PostProcessingDialog(QWidget * parent) :
|
|||||||
_ui = new Ui_PostProcessingDialog();
|
_ui = new Ui_PostProcessingDialog();
|
||||||
_ui->setupUi(this);
|
_ui->setupUi(this);
|
||||||
|
|
||||||
if(!Optimizer::isAvailable(Optimizer::kTypeCVSBA) &&
|
int firstAvailable = -1;
|
||||||
!Optimizer::isAvailable(Optimizer::kTypeG2O) &&
|
for(int i = 0; i < _ui->comboBox_sbaType->count(); ++i)
|
||||||
!Optimizer::isAvailable(Optimizer::kTypeCeres))
|
{
|
||||||
|
const Optimizer::Type type = static_cast<Optimizer::Type>(i);
|
||||||
|
const bool usable = type != Optimizer::kTypeTORO && Optimizer::isAvailable(type);
|
||||||
|
if(usable)
|
||||||
|
{
|
||||||
|
if(firstAvailable < 0) firstAvailable = i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_ui->comboBox_sbaType->setItemData(i, 0, Qt::UserRole - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(firstAvailable < 0)
|
||||||
{
|
{
|
||||||
_ui->sba->setEnabled(false);
|
_ui->sba->setEnabled(false);
|
||||||
_ui->sba->setChecked(false);
|
_ui->sba->setChecked(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!Optimizer::isAvailable(Optimizer::kTypeCVSBA))
|
_ui->comboBox_sbaType->setCurrentIndex(firstAvailable);
|
||||||
{
|
|
||||||
_ui->comboBox_sbaType->setItemData(1, 0, Qt::UserRole - 1);
|
|
||||||
_ui->comboBox_sbaType->setCurrentIndex(0);
|
|
||||||
}
|
|
||||||
if(!Optimizer::isAvailable(Optimizer::kTypeG2O))
|
|
||||||
{
|
|
||||||
_ui->comboBox_sbaType->setItemData(0, 0, Qt::UserRole - 1);
|
|
||||||
_ui->comboBox_sbaType->setCurrentIndex(1);
|
|
||||||
}
|
|
||||||
if(!Optimizer::isAvailable(Optimizer::kTypeCeres))
|
|
||||||
{
|
|
||||||
_ui->comboBox_sbaType->setItemData(2, 0, Qt::UserRole - 1);
|
|
||||||
_ui->comboBox_sbaType->setCurrentIndex(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
restoreDefaults();
|
restoreDefaults();
|
||||||
@@ -135,8 +133,13 @@ bool PostProcessingDialog::validateForm()
|
|||||||
|
|
||||||
void PostProcessingDialog::updateVisibility()
|
void PostProcessingDialog::updateVisibility()
|
||||||
{
|
{
|
||||||
_ui->sba_variance->setVisible(_ui->comboBox_sbaType->currentIndex() == 0);
|
// Pixel variance applies to every BA backend except CVSBA (its
|
||||||
_ui->label_variance->setVisible(_ui->comboBox_sbaType->currentIndex() == 0);
|
// underlying Sba::run() API takes 2D points only -- no info-matrix
|
||||||
|
// knob).
|
||||||
|
const Optimizer::Type type = static_cast<Optimizer::Type>(_ui->comboBox_sbaType->currentIndex());
|
||||||
|
const bool usesPixelVariance = type != Optimizer::kTypeCVSBA;
|
||||||
|
_ui->sba_variance->setVisible(usesPixelVariance);
|
||||||
|
_ui->label_variance->setVisible(usesPixelVariance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostProcessingDialog::saveSettings(QSettings & settings, const QString & group) const
|
void PostProcessingDialog::saveSettings(QSettings & settings, const QString & group) const
|
||||||
@@ -288,7 +291,7 @@ double PostProcessingDialog::sbaVariance() const
|
|||||||
}
|
}
|
||||||
Optimizer::Type PostProcessingDialog::sbaType() const
|
Optimizer::Type PostProcessingDialog::sbaType() const
|
||||||
{
|
{
|
||||||
return _ui->comboBox_sbaType->currentIndex()==2?Optimizer::kTypeCeres:_ui->comboBox_sbaType->currentIndex()==1?Optimizer::kTypeCVSBA:Optimizer::kTypeG2O;
|
return static_cast<Optimizer::Type>(_ui->comboBox_sbaType->currentIndex());
|
||||||
}
|
}
|
||||||
bool PostProcessingDialog::sbaRematchFeatures() const
|
bool PostProcessingDialog::sbaRematchFeatures() const
|
||||||
{
|
{
|
||||||
@@ -349,18 +352,11 @@ void PostProcessingDialog::setSBAVariance(double variance)
|
|||||||
}
|
}
|
||||||
void PostProcessingDialog::setSBAType(Optimizer::Type type)
|
void PostProcessingDialog::setSBAType(Optimizer::Type type)
|
||||||
{
|
{
|
||||||
if(type == Optimizer::kTypeCeres)
|
if(type < 0 || type >= _ui->comboBox_sbaType->count())
|
||||||
{
|
{
|
||||||
_ui->comboBox_sbaType->setCurrentIndex(2);
|
type = Optimizer::kTypeG2O;
|
||||||
}
|
|
||||||
else if(type == Optimizer::kTypeCVSBA)
|
|
||||||
{
|
|
||||||
_ui->comboBox_sbaType->setCurrentIndex(1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_ui->comboBox_sbaType->setCurrentIndex(0);
|
|
||||||
}
|
}
|
||||||
|
_ui->comboBox_sbaType->setCurrentIndex(static_cast<int>(type));
|
||||||
}
|
}
|
||||||
void PostProcessingDialog::setSBARematchFeatures(bool value)
|
void PostProcessingDialog::setSBARematchFeatures(bool value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -267,7 +267,7 @@
|
|||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLabel" name="label_variance">
|
<widget class="QLabel" name="label_variance">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Pixel variance used by g2o.</string>
|
<string>Pixel variance used by g2o / GTSAM / Ceres BA.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@@ -308,6 +308,11 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QComboBox" name="comboBox_sbaType">
|
<widget class="QComboBox" name="comboBox_sbaType">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>TORO</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>g2o</string>
|
<string>g2o</string>
|
||||||
@@ -315,7 +320,7 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>cvsba</string>
|
<string>GTSAM</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@@ -323,6 +328,11 @@
|
|||||||
<string>Ceres</string>
|
<string>Ceres</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>cvsba</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
|
|||||||
Reference in New Issue
Block a user