DbViewer: added colormap menu option to EditDepthArea, update3dView() updates only last select id to avoid switching to second image after editing the depth of the first one.

This commit is contained in:
matlabbe
2019-03-05 10:07:20 -05:00
parent 45fa968076
commit 884d1d7684
4 changed files with 75 additions and 3 deletions

View File

@@ -200,6 +200,7 @@ private:
QMap<int, int> idToIndex_;
QList<rtabmap::Link> neighborLinks_;
QList<rtabmap::Link> loopLinks_;
int lastImageBrowsed_ = 0;
rtabmap::DBDriver * dbDriver_;
QString pathDatabase_;
std::string databaseFileName_;

View File

@@ -83,6 +83,10 @@ private:
QAction * removeCluster_;
QAction * resetChanges_;
QAction * setPenWidth_;
QAction * colorMapWhiteToBlack_;
QAction * colorMapBlackToWhite_;
QAction * colorMapRedToBlue_;
QAction * colorMapBlueToRed_;
};
}

View File

@@ -1507,6 +1507,7 @@ void DatabaseViewer::updateIds()
groundTruthPoses_.clear();
gpsPoses_.clear();
gpsValues_.clear();
lastImageBrowsed_ = 0;
ui_->checkBox_wmState->setVisible(false);
ui_->checkBox_alignPosesWithGroundTruth->setVisible(false);
ui_->checkBox_alignScansCloudsWithGroundTruth->setVisible(false);
@@ -3557,6 +3558,8 @@ void DatabaseViewer::update(int value,
QLabel * labelSensors,
bool updateConstraintView)
{
lastImageBrowsed_ = value;
UTimer timer;
labelIndex->setText(QString::number(value));
labelParents->clear();
@@ -4608,8 +4611,14 @@ void DatabaseViewer::update3dView()
{
if(ui_->dockWidget_view3d->isVisible())
{
sliderAValueChanged(ui_->horizontalSlider_A->value());
sliderBValueChanged(ui_->horizontalSlider_B->value());
if(lastImageBrowsed_ == ui_->horizontalSlider_B->value())
{
sliderBValueChanged(ui_->horizontalSlider_B->value());
}
else
{
sliderAValueChanged(ui_->horizontalSlider_A->value());
}
}
}

View File

@@ -52,6 +52,24 @@ EditDepthArea::EditDepthArea(QWidget *parent)
showRGB_->setChecked(true);
removeCluster_ = menu_->addAction(tr("Remove Cluster"));
setPenWidth_ = menu_->addAction(tr("Set Pen Width..."));
QMenu * colorMap = menu_->addMenu("Depth color map");
colorMapWhiteToBlack_ = colorMap->addAction(tr("White to black"));
colorMapWhiteToBlack_->setCheckable(true);
colorMapWhiteToBlack_->setChecked(true);
colorMapBlackToWhite_ = colorMap->addAction(tr("Black to white"));
colorMapBlackToWhite_->setCheckable(true);
colorMapBlackToWhite_->setChecked(false);
colorMapRedToBlue_ = colorMap->addAction(tr("Red to blue"));
colorMapRedToBlue_->setCheckable(true);
colorMapRedToBlue_->setChecked(false);
colorMapBlueToRed_ = colorMap->addAction(tr("Blue to red"));
colorMapBlueToRed_->setCheckable(true);
colorMapBlueToRed_->setChecked(false);
QActionGroup * group = new QActionGroup(this);
group->addAction(colorMapWhiteToBlack_);
group->addAction(colorMapBlackToWhite_);
group->addAction(colorMapRedToBlue_);
group->addAction(colorMapBlueToRed_);
resetChanges_ = menu_->addAction(tr("Reset Changes"));
}
@@ -61,7 +79,22 @@ void EditDepthArea::setImage(const cv::Mat &depth, const cv::Mat & rgb)
UASSERT(depth.type() == CV_32FC1 ||
depth.type() == CV_16UC1);
originalImage_ = depth;
image_ = uCvMat2QImage(depth).convertToFormat(QImage::Format_RGB32);
uCvQtDepthColorMap colorMap = uCvQtDepthWhiteToBlack;
if(colorMapBlackToWhite_->isChecked())
{
colorMap = uCvQtDepthBlackToWhite;
}
else if(colorMapRedToBlue_->isChecked())
{
colorMap = uCvQtDepthRedToBlue;
}
else if(colorMapBlueToRed_->isChecked())
{
colorMap = uCvQtDepthBlueToRed;
}
image_ = uCvMat2QImage(depth, true, colorMap).convertToFormat(QImage::Format_RGB32);
imageRGB_ = QImage();
if(!rgb.empty())
@@ -294,6 +327,31 @@ void EditDepthArea::contextMenuEvent(QContextMenuEvent * e)
myPenWidth_ = width;
}
}
else if(action == colorMapBlackToWhite_ ||
action == colorMapWhiteToBlack_ ||
action == colorMapRedToBlue_ ||
action == colorMapBlueToRed_)
{
if(!originalImage_.empty())
{
uCvQtDepthColorMap colorMap = uCvQtDepthWhiteToBlack;
if(colorMapBlackToWhite_->isChecked())
{
colorMap = uCvQtDepthBlackToWhite;
}
else if(colorMapRedToBlue_->isChecked())
{
colorMap = uCvQtDepthRedToBlue;
}
else if(colorMapBlueToRed_->isChecked())
{
colorMap = uCvQtDepthBlueToRed;
}
image_ = uCvMat2QImage(originalImage_, true, colorMap).convertToFormat(QImage::Format_RGB32);
update();
}
}
else if(action == resetChanges_)
{
this->resetChanges();