Skip to content

Commit

Permalink
add mask settings
Browse files Browse the repository at this point in the history
  • Loading branch information
borongyuan committed Oct 20, 2023
1 parent 81e7425 commit 5c14809
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 2 deletions.
2 changes: 2 additions & 0 deletions corelib/include/rtabmap/core/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@ class RTABMAP_CORE_EXPORT Parameters
RTABMAP_PARAM(OdomOpenVINS, FeatRepSLAM, int, 4, "What representation our features are in (slam features)");
RTABMAP_PARAM(OdomOpenVINS, DtSLAMDelay, double, 0.0, "Delay, in seconds, that we should wait from init before we start estimating SLAM features");
RTABMAP_PARAM(OdomOpenVINS, GravityMag, double, 9.81, "Gravity magnitude in the global frame (i.e. should be 9.81 typically)");
RTABMAP_PARAM_STR(OdomOpenVINS, LeftMaskPath, "", "Mask for left image");
RTABMAP_PARAM_STR(OdomOpenVINS, RightMaskPath, "", "Mask for right image");

RTABMAP_PARAM(OdomOpenVINS, InitWindowTime, double, 2.0, "Amount of time we will initialize over (seconds)");
RTABMAP_PARAM(OdomOpenVINS, InitIMUThresh, double, 1.0, "Variance threshold on our acceleration to be classified as moving");
Expand Down
28 changes: 26 additions & 2 deletions corelib/src/odometry/OdometryOpenVINS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "rtabmap/core/odometry/OdometryOpenVINS.h"
#include "rtabmap/core/OdometryInfo.h"
#include "rtabmap/core/util3d_transforms.h"
#include "rtabmap/utilite/UFile.h"
#include "rtabmap/utilite/ULogger.h"
#include "rtabmap/utilite/UTimer.h"
#include <opencv2/imgproc/types_c.h>
Expand All @@ -51,6 +52,7 @@ OdometryOpenVINS::OdometryOpenVINS(const ParametersMap & parameters) :
#ifdef RTABMAP_OPENVINS
ov_core::Printer::setPrintLevel(ov_core::Printer::PrintLevel(ULogger::level()+1));
int enum_index;
std::string left_mask_path, right_mask_path;
params_ = std::make_unique<ov_msckf::VioManagerOptions>();
Parameters::parse(parameters, Parameters::kOdomOpenVINSUseStereo(), params_->use_stereo);
Parameters::parse(parameters, Parameters::kOdomOpenVINSUseKLT(), params_->use_klt);
Expand Down Expand Up @@ -85,6 +87,22 @@ OdometryOpenVINS::OdometryOpenVINS(const ParametersMap & parameters) :
params_->state_options.feat_rep_slam = ov_type::LandmarkRepresentation::Representation(enum_index);
Parameters::parse(parameters, Parameters::kOdomOpenVINSDtSLAMDelay(), params_->dt_slam_delay);
Parameters::parse(parameters, Parameters::kOdomOpenVINSGravityMag(), params_->gravity_mag);
Parameters::parse(parameters, Parameters::kOdomOpenVINSLeftMaskPath(), left_mask_path);
if(!left_mask_path.empty())
{
if(!UFile::exists(left_mask_path))
UWARN("OpenVINS: invalid left mask path: %s", left_mask_path.c_str());
else
params_->masks.emplace(0, cv::imread(left_mask_path, cv::IMREAD_GRAYSCALE));
}
Parameters::parse(parameters, Parameters::kOdomOpenVINSLeftMaskPath(), right_mask_path);
if(!right_mask_path.empty())
{
if(!UFile::exists(right_mask_path))
UWARN("OpenVINS: invalid right mask path: %s", right_mask_path.c_str());
else
params_->masks.emplace(1, cv::imread(right_mask_path, cv::IMREAD_GRAYSCALE));
}
Parameters::parse(parameters, Parameters::kOdomOpenVINSInitWindowTime(), params_->init_options.init_window_time);
Parameters::parse(parameters, Parameters::kOdomOpenVINSInitIMUThresh(), params_->init_options.init_imu_thresh);
Parameters::parse(parameters, Parameters::kOdomOpenVINSInitMaxDisparity(), params_->init_options.init_max_disparity);
Expand Down Expand Up @@ -315,7 +333,10 @@ Transform OdometryOpenVINS::computeTransform(
message.timestamp = data.stamp();
message.sensor_ids.emplace_back(0);
message.images.emplace_back(image);
message.masks.emplace_back(cv::Mat::zeros(image.size(), CV_8UC1));
if(params_->masks.find(0) != params_->masks.end())
message.masks.emplace_back(params_->masks[0]);
else
message.masks.emplace_back(cv::Mat::zeros(image.size(), CV_8UC1));
if(!data.rightRaw().empty())
{
if(data.rightRaw().type() == CV_8UC3)
Expand All @@ -326,7 +347,10 @@ Transform OdometryOpenVINS::computeTransform(
UFATAL("Not supported color type!");
message.sensor_ids.emplace_back(1);
message.images.emplace_back(image);
message.masks.emplace_back(cv::Mat::zeros(image.size(), CV_8UC1));
if(params_->masks.find(1) != params_->masks.end())
message.masks.emplace_back(params_->masks[1]);
else
message.masks.emplace_back(cv::Mat::zeros(image.size(), CV_8UC1));
}
vioManager_->feed_measurement_camera(message);

Expand Down
2 changes: 2 additions & 0 deletions guilib/include/rtabmap/gui/PreferencesDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,8 @@ private Q_SLOTS:
void changeOdometryORBSLAMVocabulary();
void changeOdometryOKVISConfigPath();
void changeOdometryVINSConfigPath();
void changeOdometryOpenVINSLeftMask();
void changeOdometryOpenVINSRightMask();
void changeIcpPMConfigPath();
void changeSuperPointModelPath();
void changePyMatcherPath();
Expand Down
38 changes: 38 additions & 0 deletions guilib/src/PreferencesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,10 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
_ui->comboBox_OdomOpenVINSFeatRepSLAM->setObjectName(Parameters::kOdomOpenVINSFeatRepSLAM().c_str());
_ui->doubleSpinBox_OdomOpenVINSDtSLAMDelay->setObjectName(Parameters::kOdomOpenVINSDtSLAMDelay().c_str());
_ui->doubleSpinBox_OdomOpenVINSGravityMag->setObjectName(Parameters::kOdomOpenVINSGravityMag().c_str());
_ui->lineEdit_OdomOpenVINSLeftMaskPath->setObjectName(Parameters::kOdomOpenVINSLeftMaskPath().c_str());
connect(_ui->toolButton_OdomOpenVINSLeftMaskPath, SIGNAL(clicked()), this, SLOT(changeOdometryOpenVINSLeftMask()));
_ui->lineEdit_OdomOpenVINSRightMaskPath->setObjectName(Parameters::kOdomOpenVINSRightMaskPath().c_str());
connect(_ui->toolButton_OdomOpenVINSRightMaskPath, SIGNAL(clicked()), this, SLOT(changeOdometryOpenVINSRightMask()));

_ui->doubleSpinBox_OdomOpenVINSInitWindowTime->setObjectName(Parameters::kOdomOpenVINSInitWindowTime().c_str());
_ui->doubleSpinBox_OdomOpenVINSInitIMUThresh->setObjectName(Parameters::kOdomOpenVINSInitIMUThresh().c_str());
Expand Down Expand Up @@ -5212,6 +5216,40 @@ void PreferencesDialog::changeOdometryVINSConfigPath()
}
}

void PreferencesDialog::changeOdometryOpenVINSLeftMask()
{
QString path;
if(_ui->lineEdit_OdomOpenVINSLeftMaskPath->text().isEmpty())
{
path = QFileDialog::getOpenFileName(this, tr("Select Left Mask"), this->getWorkingDirectory(), tr("Image mask (*.jpg *.png)"));
}
else
{
path = QFileDialog::getOpenFileName(this, tr("Select Left Mask"), _ui->lineEdit_OdomOpenVINSLeftMaskPath->text(), tr("Image mask (*.jpg *.png)"));
}
if(!path.isEmpty())
{
_ui->lineEdit_OdomOpenVINSLeftMaskPath->setText(path);
}
}

void PreferencesDialog::changeOdometryOpenVINSRightMask()
{
QString path;
if(_ui->lineEdit_OdomOpenVINSRightMaskPath->text().isEmpty())
{
path = QFileDialog::getOpenFileName(this, tr("Select Right Mask"), this->getWorkingDirectory(), tr("Image mask (*.jpg *.png)"));
}
else
{
path = QFileDialog::getOpenFileName(this, tr("Select Right Mask"), _ui->lineEdit_OdomOpenVINSRightMaskPath->text(), tr("Image mask (*.jpg *.png)"));
}
if(!path.isEmpty())
{
_ui->lineEdit_OdomOpenVINSRightMaskPath->setText(path);
}
}

void PreferencesDialog::changeIcpPMConfigPath()
{
QString path;
Expand Down
54 changes: 54 additions & 0 deletions guilib/src/ui/preferencesDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -18590,6 +18590,60 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag
</property>
</widget>
</item>
<item row="15" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_16" stretch="0,1">
<item>
<widget class="QToolButton" name="toolButton_OdomOpenVINSLeftMaskPath">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_OdomOpenVINSLeftMaskPath"/>
</item>
</layout>
</item>
<item row="15" column="1">
<widget class="QLabel" name="label_736">
<property name="text">
<string>Mask for left image</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="16" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_17" stretch="0,1">
<item>
<widget class="QToolButton" name="toolButton_OdomOpenVINSRightMaskPath">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_OdomOpenVINSRightMaskPath"/>
</item>
</layout>
</item>
<item row="16" column="1">
<widget class="QLabel" name="label_737">
<property name="text">
<string>Mask for right image</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit 5c14809

Please sign in to comment.