mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 09:30:25 +08:00
DbViewer: EditDepth colormap now matches the one in main window
This commit is contained in:
@@ -200,7 +200,7 @@ private:
|
||||
QMap<int, int> idToIndex_;
|
||||
QList<rtabmap::Link> neighborLinks_;
|
||||
QList<rtabmap::Link> loopLinks_;
|
||||
int lastImageBrowsed_ = 0;
|
||||
int lastSliderIndexBrowsed_;
|
||||
rtabmap::DBDriver * dbDriver_;
|
||||
QString pathDatabase_;
|
||||
std::string databaseFileName_;
|
||||
|
||||
@@ -35,6 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <QPoint>
|
||||
#include <QWidget>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include "rtabmap/utilite/UCv2Qt.h"
|
||||
|
||||
class QMenu;
|
||||
class QAction;
|
||||
@@ -54,6 +55,7 @@ public:
|
||||
|
||||
void setPenWidth(int newWidth);
|
||||
int penWidth() const { return myPenWidth_; }
|
||||
void setColorMap(uCvQtDepthColorMap type);
|
||||
|
||||
public Q_SLOTS:
|
||||
void resetChanges();
|
||||
|
||||
@@ -36,6 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <QtCore/QSettings>
|
||||
#include <opencv2/features2d/features2d.hpp>
|
||||
#include <map>
|
||||
#include "rtabmap/utilite/UCv2Qt.h"
|
||||
|
||||
class QAction;
|
||||
class QMenu;
|
||||
@@ -67,6 +68,7 @@ public:
|
||||
bool isGraphicsViewScaledToHeight() const;
|
||||
const QColor & getDefaultBackgroundColor() const;
|
||||
const QColor & getBackgroundColor() const;
|
||||
uCvQtDepthColorMap getDepthColorMap() const;
|
||||
|
||||
float viewScale() const;
|
||||
|
||||
|
||||
@@ -1507,7 +1507,7 @@ void DatabaseViewer::updateIds()
|
||||
groundTruthPoses_.clear();
|
||||
gpsPoses_.clear();
|
||||
gpsValues_.clear();
|
||||
lastImageBrowsed_ = 0;
|
||||
lastSliderIndexBrowsed_ = 0;
|
||||
ui_->checkBox_wmState->setVisible(false);
|
||||
ui_->checkBox_alignPosesWithGroundTruth->setVisible(false);
|
||||
ui_->checkBox_alignScansCloudsWithGroundTruth->setVisible(false);
|
||||
@@ -1984,12 +1984,17 @@ void DatabaseViewer::editDepthImage()
|
||||
{
|
||||
if(dbDriver_ && ids_.size())
|
||||
{
|
||||
int id = ids_.at(ui_->horizontalSlider_A->value());
|
||||
if(lastSliderIndexBrowsed_>= ids_.size())
|
||||
{
|
||||
lastSliderIndexBrowsed_ = ui_->horizontalSlider_A->value();
|
||||
}
|
||||
int id = ids_.at(lastSliderIndexBrowsed_);
|
||||
SensorData data;
|
||||
dbDriver_->getNodeData(id, data, true, false, false, false);
|
||||
data.uncompressData();
|
||||
if(!data.depthRaw().empty())
|
||||
{
|
||||
editDepthArea_->setColorMap(lastSliderIndexBrowsed_ == ui_->horizontalSlider_B->value()?ui_->graphicsView_B->getDepthColorMap():ui_->graphicsView_A->getDepthColorMap());
|
||||
editDepthArea_->setImage(data.depthRaw(), data.imageRaw());
|
||||
if(editDepthDialog_->exec() == QDialog::Accepted && editDepthArea_->isModified())
|
||||
{
|
||||
@@ -3558,7 +3563,7 @@ void DatabaseViewer::update(int value,
|
||||
QLabel * labelSensors,
|
||||
bool updateConstraintView)
|
||||
{
|
||||
lastImageBrowsed_ = value;
|
||||
lastSliderIndexBrowsed_ = value;
|
||||
|
||||
UTimer timer;
|
||||
labelIndex->setText(QString::number(value));
|
||||
@@ -4611,7 +4616,7 @@ void DatabaseViewer::update3dView()
|
||||
{
|
||||
if(ui_->dockWidget_view3d->isVisible())
|
||||
{
|
||||
if(lastImageBrowsed_ == ui_->horizontalSlider_B->value())
|
||||
if(lastSliderIndexBrowsed_ == ui_->horizontalSlider_B->value())
|
||||
{
|
||||
sliderBValueChanged(ui_->horizontalSlider_B->value());
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "rtabmap/gui/EditDepthArea.h"
|
||||
#include <rtabmap/utilite/ULogger.h>
|
||||
#include <rtabmap/utilite/UCv2Qt.h>
|
||||
|
||||
namespace rtabmap {
|
||||
|
||||
@@ -55,13 +54,13 @@ EditDepthArea::EditDepthArea(QWidget *parent)
|
||||
QMenu * colorMap = menu_->addMenu("Depth color map");
|
||||
colorMapWhiteToBlack_ = colorMap->addAction(tr("White to black"));
|
||||
colorMapWhiteToBlack_->setCheckable(true);
|
||||
colorMapWhiteToBlack_->setChecked(true);
|
||||
colorMapWhiteToBlack_->setChecked(false);
|
||||
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);
|
||||
colorMapRedToBlue_->setChecked(true);
|
||||
colorMapBlueToRed_ = colorMap->addAction(tr("Blue to red"));
|
||||
colorMapBlueToRed_->setCheckable(true);
|
||||
colorMapBlueToRed_->setChecked(false);
|
||||
@@ -156,6 +155,32 @@ void EditDepthArea::resetChanges()
|
||||
update();
|
||||
}
|
||||
|
||||
void EditDepthArea::setColorMap(uCvQtDepthColorMap type)
|
||||
{
|
||||
if(type == uCvQtDepthBlackToWhite)
|
||||
{
|
||||
colorMapBlackToWhite_->setChecked(true);
|
||||
}
|
||||
else if(type == uCvQtDepthRedToBlue)
|
||||
{
|
||||
colorMapRedToBlue_->setChecked(true);
|
||||
}
|
||||
else if(type == uCvQtDepthBlueToRed)
|
||||
{
|
||||
colorMapBlueToRed_->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
colorMapWhiteToBlack_->setChecked(true);
|
||||
}
|
||||
|
||||
if(!originalImage_.empty())
|
||||
{
|
||||
image_ = uCvMat2QImage(originalImage_, true, type).convertToFormat(QImage::Format_RGB32);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void EditDepthArea::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
@@ -332,25 +357,20 @@ void EditDepthArea::contextMenuEvent(QContextMenuEvent * e)
|
||||
action == colorMapRedToBlue_ ||
|
||||
action == colorMapBlueToRed_)
|
||||
{
|
||||
if(!originalImage_.empty())
|
||||
uCvQtDepthColorMap colorMap = uCvQtDepthWhiteToBlack;
|
||||
if(colorMapBlackToWhite_->isChecked())
|
||||
{
|
||||
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();
|
||||
colorMap = uCvQtDepthBlackToWhite;
|
||||
}
|
||||
else if(colorMapRedToBlue_->isChecked())
|
||||
{
|
||||
colorMap = uCvQtDepthRedToBlue;
|
||||
}
|
||||
else if(colorMapBlueToRed_->isChecked())
|
||||
{
|
||||
colorMap = uCvQtDepthBlueToRed;
|
||||
}
|
||||
this->setColorMap(colorMap);
|
||||
}
|
||||
else if(action == resetChanges_)
|
||||
{
|
||||
|
||||
@@ -38,7 +38,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <QVBoxLayout>
|
||||
#include <QGraphicsRectItem>
|
||||
#include "rtabmap/utilite/ULogger.h"
|
||||
#include "rtabmap/utilite/UCv2Qt.h"
|
||||
#include "rtabmap/gui/KeypointItem.h"
|
||||
#include "rtabmap/core/util2d.h"
|
||||
|
||||
@@ -202,13 +201,13 @@ ImageView::ImageView(QWidget * parent) :
|
||||
QMenu * colorMap = _menu->addMenu("Depth color map");
|
||||
_colorMapWhiteToBlack = colorMap->addAction(tr("White to black"));
|
||||
_colorMapWhiteToBlack->setCheckable(true);
|
||||
_colorMapWhiteToBlack->setChecked(true);
|
||||
_colorMapWhiteToBlack->setChecked(false);
|
||||
_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);
|
||||
_colorMapRedToBlue->setChecked(true);
|
||||
_colorMapBlueToRed = colorMap->addAction(tr("Blue to red"));
|
||||
_colorMapBlueToRed->setCheckable(true);
|
||||
_colorMapBlueToRed->setChecked(false);
|
||||
@@ -323,6 +322,24 @@ const QColor & ImageView::getBackgroundColor() const
|
||||
return _graphicsView->backgroundBrush().color();
|
||||
}
|
||||
|
||||
uCvQtDepthColorMap ImageView::getDepthColorMap() const
|
||||
{
|
||||
uCvQtDepthColorMap colorMap = uCvQtDepthWhiteToBlack;
|
||||
if(_colorMapBlackToWhite->isChecked())
|
||||
{
|
||||
colorMap = uCvQtDepthBlackToWhite;
|
||||
}
|
||||
else if(_colorMapRedToBlue->isChecked())
|
||||
{
|
||||
colorMap = uCvQtDepthRedToBlue;
|
||||
}
|
||||
else if(_colorMapBlueToRed->isChecked())
|
||||
{
|
||||
colorMap = uCvQtDepthBlueToRed;
|
||||
}
|
||||
return colorMap;
|
||||
}
|
||||
|
||||
|
||||
void ImageView::setFeaturesShown(bool shown)
|
||||
{
|
||||
@@ -904,20 +921,7 @@ void ImageView::setImage(const QImage & image)
|
||||
void ImageView::setImageDepth(const cv::Mat & imageDepth)
|
||||
{
|
||||
_imageDepthCv = imageDepth;
|
||||
uCvQtDepthColorMap colorMap = uCvQtDepthWhiteToBlack;
|
||||
if(_colorMapBlackToWhite->isChecked())
|
||||
{
|
||||
colorMap = uCvQtDepthBlackToWhite;
|
||||
}
|
||||
else if(_colorMapRedToBlue->isChecked())
|
||||
{
|
||||
colorMap = uCvQtDepthRedToBlue;
|
||||
}
|
||||
else if(_colorMapBlueToRed->isChecked())
|
||||
{
|
||||
colorMap = uCvQtDepthBlueToRed;
|
||||
}
|
||||
setImageDepth(uCvMat2QImage(_imageDepthCv, true, colorMap));
|
||||
setImageDepth(uCvMat2QImage(_imageDepthCv, true, getDepthColorMap()));
|
||||
}
|
||||
|
||||
void ImageView::setImageDepth(const QImage & imageDepth)
|
||||
|
||||
Reference in New Issue
Block a user