DbViewer: added decimation parameter for cloud visualization. ImageView: adding scaling to height menu option.

This commit is contained in:
matlabbe
2018-08-17 14:01:11 -04:00
parent c18f3cd539
commit 67aa4cd28e
4 changed files with 145 additions and 46 deletions

View File

@@ -64,6 +64,7 @@ public:
int getFeaturesSize() const {return _featuresSize;} int getFeaturesSize() const {return _featuresSize;}
bool isGraphicsViewMode() const; bool isGraphicsViewMode() const;
bool isGraphicsViewScaled() const; bool isGraphicsViewScaled() const;
bool isGraphicsViewScaledToHeight() const;
const QColor & getDefaultBackgroundColor() const; const QColor & getDefaultBackgroundColor() const;
const QColor & getBackgroundColor() const; const QColor & getBackgroundColor() const;
@@ -75,6 +76,7 @@ public:
void setLinesShown(bool shown); void setLinesShown(bool shown);
void setGraphicsViewMode(bool on); void setGraphicsViewMode(bool on);
void setGraphicsViewScaled(bool scaled); void setGraphicsViewScaled(bool scaled);
void setGraphicsViewScaledToHeight(bool scaled);
void setDefaultBackgroundColor(const QColor & color); void setDefaultBackgroundColor(const QColor & color);
void setBackgroundColor(const QColor & color); void setBackgroundColor(const QColor & color);
@@ -129,6 +131,9 @@ private:
QAction * _setFeaturesSize; QAction * _setFeaturesSize;
QAction * _graphicsViewMode; QAction * _graphicsViewMode;
QAction * _graphicsViewScaled; QAction * _graphicsViewScaled;
QAction * _graphicsViewScaledToHeight;
QAction * _graphicsViewNoScaling;
QMenu * _scaleMenu;
QGraphicsView * _graphicsView; QGraphicsView * _graphicsView;
QMultiMap<int, rtabmap::KeypointItem *> _features; QMultiMap<int, rtabmap::KeypointItem *> _features;

View File

@@ -348,6 +348,8 @@ DatabaseViewer::DatabaseViewer(const QString & ini, QWidget * parent) :
connect(ui_->doubleSpinBox_gainCompensationRadius, SIGNAL(valueChanged(double)), this, SLOT(updateConstraintView())); connect(ui_->doubleSpinBox_gainCompensationRadius, SIGNAL(valueChanged(double)), this, SLOT(updateConstraintView()));
connect(ui_->doubleSpinBox_voxelSize, SIGNAL(valueChanged(double)), this, SLOT(updateConstraintView())); connect(ui_->doubleSpinBox_voxelSize, SIGNAL(valueChanged(double)), this, SLOT(updateConstraintView()));
connect(ui_->doubleSpinBox_voxelSize, SIGNAL(valueChanged(double)), this, SLOT(update3dView())); connect(ui_->doubleSpinBox_voxelSize, SIGNAL(valueChanged(double)), this, SLOT(update3dView()));
connect(ui_->spinBox_decimation, SIGNAL(valueChanged(int)), this, SLOT(updateConstraintView()));
connect(ui_->spinBox_decimation, SIGNAL(valueChanged(int)), this, SLOT(update3dView()));
connect(ui_->groupBox_posefiltering, SIGNAL(clicked(bool)), this, SLOT(updateGraphView())); connect(ui_->groupBox_posefiltering, SIGNAL(clicked(bool)), this, SLOT(updateGraphView()));
connect(ui_->doubleSpinBox_posefilteringRadius, SIGNAL(editingFinished()), this, SLOT(updateGraphView())); connect(ui_->doubleSpinBox_posefilteringRadius, SIGNAL(editingFinished()), this, SLOT(updateGraphView()));
connect(ui_->doubleSpinBox_posefilteringAngle, SIGNAL(editingFinished()), this, SLOT(updateGraphView())); connect(ui_->doubleSpinBox_posefilteringAngle, SIGNAL(editingFinished()), this, SLOT(updateGraphView()));
@@ -373,6 +375,7 @@ DatabaseViewer::DatabaseViewer(const QString & ini, QWidget * parent) :
// Graph view // Graph view
connect(ui_->doubleSpinBox_gainCompensationRadius, SIGNAL(valueChanged(double)), this, SLOT(configModified())); connect(ui_->doubleSpinBox_gainCompensationRadius, SIGNAL(valueChanged(double)), this, SLOT(configModified()));
connect(ui_->doubleSpinBox_voxelSize, SIGNAL(valueChanged(double)), this, SLOT(configModified())); connect(ui_->doubleSpinBox_voxelSize, SIGNAL(valueChanged(double)), this, SLOT(configModified()));
connect(ui_->spinBox_decimation, SIGNAL(valueChanged(int)), this, SLOT(configModified()));
connect(ui_->groupBox_posefiltering, SIGNAL(clicked(bool)), this, SLOT(configModified())); connect(ui_->groupBox_posefiltering, SIGNAL(clicked(bool)), this, SLOT(configModified()));
connect(ui_->doubleSpinBox_posefilteringRadius, SIGNAL(valueChanged(double)), this, SLOT(configModified())); connect(ui_->doubleSpinBox_posefilteringRadius, SIGNAL(valueChanged(double)), this, SLOT(configModified()));
connect(ui_->doubleSpinBox_posefilteringAngle, SIGNAL(valueChanged(double)), this, SLOT(configModified())); connect(ui_->doubleSpinBox_posefilteringAngle, SIGNAL(valueChanged(double)), this, SLOT(configModified()));
@@ -496,7 +499,7 @@ void DatabaseViewer::readSettings()
settings.beginGroup("optimization"); settings.beginGroup("optimization");
ui_->doubleSpinBox_gainCompensationRadius->setValue(settings.value("gainCompensationRadius", ui_->doubleSpinBox_gainCompensationRadius->value()).toDouble()); ui_->doubleSpinBox_gainCompensationRadius->setValue(settings.value("gainCompensationRadius", ui_->doubleSpinBox_gainCompensationRadius->value()).toDouble());
ui_->doubleSpinBox_voxelSize->setValue(settings.value("voxelSize", ui_->doubleSpinBox_voxelSize->value()).toDouble()); ui_->doubleSpinBox_voxelSize->setValue(settings.value("voxelSize", ui_->doubleSpinBox_voxelSize->value()).toDouble());
ui_->spinBox_decimation->setValue(settings.value("decimation", ui_->spinBox_decimation->value()).toInt());
settings.endGroup(); settings.endGroup();
settings.beginGroup("grid"); settings.beginGroup("grid");
@@ -577,6 +580,7 @@ void DatabaseViewer::writeSettings()
settings.beginGroup("optimization"); settings.beginGroup("optimization");
settings.setValue("gainCompensationRadius", ui_->doubleSpinBox_gainCompensationRadius->value()); settings.setValue("gainCompensationRadius", ui_->doubleSpinBox_gainCompensationRadius->value());
settings.setValue("voxelSize", ui_->doubleSpinBox_voxelSize->value()); settings.setValue("voxelSize", ui_->doubleSpinBox_voxelSize->value());
settings.setValue("decimation", ui_->spinBox_decimation->value());
settings.endGroup(); settings.endGroup();
// save Grid settings // save Grid settings
@@ -660,6 +664,7 @@ void DatabaseViewer::restoreDefaultSettings()
ui_->doubleSpinBox_optimizationScale->setValue(1.0); ui_->doubleSpinBox_optimizationScale->setValue(1.0);
ui_->doubleSpinBox_gainCompensationRadius->setValue(0.0); ui_->doubleSpinBox_gainCompensationRadius->setValue(0.0);
ui_->doubleSpinBox_voxelSize->setValue(0.0); ui_->doubleSpinBox_voxelSize->setValue(0.0);
ui_->spinBox_decimation->setValue(1);
ui_->groupBox_posefiltering->setChecked(false); ui_->groupBox_posefiltering->setChecked(false);
ui_->doubleSpinBox_posefilteringRadius->setValue(0.1); ui_->doubleSpinBox_posefilteringRadius->setValue(0.1);
@@ -3588,7 +3593,7 @@ void DatabaseViewer::update(int value,
data.imageRaw(), data.imageRaw(),
depth, depth,
data.cameraModels()[0], data.cameraModels()[0],
1,0,0,indices.get()); ui_->spinBox_decimation->value(),0,0,indices.get());
if(indices->size()) if(indices->size())
{ {
cloud = util3d::transformPointCloud(cloud, data.cameraModels()[0].localTransform()); cloud = util3d::transformPointCloud(cloud, data.cameraModels()[0].localTransform());
@@ -3597,7 +3602,7 @@ void DatabaseViewer::update(int value,
} }
else else
{ {
cloud = util3d::cloudRGBFromSensorData(data, 1, 0, 0, indices.get(), ui_->parameters_toolbox->getParameters()); cloud = util3d::cloudRGBFromSensorData(data, ui_->spinBox_decimation->value(), 0, 0, indices.get(), ui_->parameters_toolbox->getParameters());
} }
if(indices->size()) if(indices->size())
{ {
@@ -3665,7 +3670,7 @@ void DatabaseViewer::update(int value,
{ {
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud; pcl::PointCloud<pcl::PointXYZ>::Ptr cloud;
pcl::IndicesPtr indices(new std::vector<int>); pcl::IndicesPtr indices(new std::vector<int>);
cloud = util3d::cloudFromSensorData(data, 1, 0, 0, indices.get(), ui_->parameters_toolbox->getParameters()); cloud = util3d::cloudFromSensorData(data, ui_->spinBox_decimation->value(), 0, 0, indices.get(), ui_->parameters_toolbox->getParameters());
if(indices->size()) if(indices->size())
{ {
if(ui_->doubleSpinBox_voxelSize->value() > 0.0) if(ui_->doubleSpinBox_voxelSize->value() > 0.0)
@@ -4572,11 +4577,11 @@ void DatabaseViewer::updateConstraintView(
pcl::IndicesPtr indicesTo(new std::vector<int>); pcl::IndicesPtr indicesTo(new std::vector<int>);
if(!dataFrom.imageRaw().empty() && !dataFrom.depthOrRightRaw().empty()) if(!dataFrom.imageRaw().empty() && !dataFrom.depthOrRightRaw().empty())
{ {
cloudFrom=util3d::cloudRGBFromSensorData(dataFrom, 1, 0, 0, indicesFrom.get(), ui_->parameters_toolbox->getParameters()); cloudFrom=util3d::cloudRGBFromSensorData(dataFrom, ui_->spinBox_decimation->value(), 0, 0, indicesFrom.get(), ui_->parameters_toolbox->getParameters());
} }
if(!dataTo.imageRaw().empty() && !dataTo.depthOrRightRaw().empty()) if(!dataTo.imageRaw().empty() && !dataTo.depthOrRightRaw().empty())
{ {
cloudTo=util3d::cloudRGBFromSensorData(dataTo, 1, 0, 0, indicesTo.get(), ui_->parameters_toolbox->getParameters()); cloudTo=util3d::cloudRGBFromSensorData(dataTo, ui_->spinBox_decimation->value(), 0, 0, indicesTo.get(), ui_->parameters_toolbox->getParameters());
} }
if(cloudTo.get() && indicesTo->size()) if(cloudTo.get() && indicesTo->size())

View File

@@ -183,10 +183,21 @@ ImageView::ImageView(QWidget * parent) :
_graphicsViewMode = _menu->addAction(tr("Graphics view")); _graphicsViewMode = _menu->addAction(tr("Graphics view"));
_graphicsViewMode->setCheckable(true); _graphicsViewMode->setCheckable(true);
_graphicsViewMode->setChecked(false); _graphicsViewMode->setChecked(false);
_graphicsViewScaled = _menu->addAction(tr("Scale image")); _scaleMenu = _menu->addMenu("Scale image");
_scaleMenu->setEnabled(false);
_graphicsViewScaled = _scaleMenu->addAction(tr("Fit in view"));
_graphicsViewScaled->setCheckable(true); _graphicsViewScaled->setCheckable(true);
_graphicsViewScaled->setChecked(true); _graphicsViewScaled->setChecked(true);
_graphicsViewScaled->setEnabled(false); _graphicsViewScaledToHeight = _scaleMenu->addAction(tr("Fit height"));
_graphicsViewScaledToHeight->setCheckable(true);
_graphicsViewScaledToHeight->setChecked(false);
_graphicsViewNoScaling = _scaleMenu->addAction(tr("No scale"));
_graphicsViewNoScaling->setCheckable(true);
_graphicsViewNoScaling->setChecked(false);
QActionGroup * group = new QActionGroup(this);
group->addAction(_graphicsViewScaled);
group->addAction(_graphicsViewScaledToHeight);
group->addAction(_graphicsViewNoScaling);
_setAlpha = _menu->addAction(tr("Set transparency...")); _setAlpha = _menu->addAction(tr("Set transparency..."));
_saveImage = _menu->addAction(tr("Save picture...")); _saveImage = _menu->addAction(tr("Save picture..."));
_saveImage->setEnabled(false); _saveImage->setEnabled(false);
@@ -270,6 +281,11 @@ bool ImageView::isGraphicsViewScaled() const
return _graphicsViewScaled->isChecked(); return _graphicsViewScaled->isChecked();
} }
bool ImageView::isGraphicsViewScaledToHeight() const
{
return _graphicsViewScaledToHeight->isChecked();
}
const QColor & ImageView::getDefaultBackgroundColor() const const QColor & ImageView::getDefaultBackgroundColor() const
{ {
return _defaultBgColor; return _defaultBgColor;
@@ -362,7 +378,7 @@ void ImageView::setGraphicsViewMode(bool on)
{ {
_graphicsViewMode->setChecked(on); _graphicsViewMode->setChecked(on);
_graphicsView->setVisible(on); _graphicsView->setVisible(on);
_graphicsViewScaled->setEnabled(on); _scaleMenu->setEnabled(on);
if(on) if(on)
{ {
@@ -402,6 +418,12 @@ void ImageView::setGraphicsViewMode(bool on)
{ {
_graphicsView->fitInView(_graphicsView->sceneRect(), Qt::KeepAspectRatio); _graphicsView->fitInView(_graphicsView->sceneRect(), Qt::KeepAspectRatio);
} }
else if(_graphicsViewScaledToHeight->isChecked())
{
QRectF rect = _graphicsView->sceneRect();
rect.setWidth(1);
_graphicsView->fitInView(rect, Qt::KeepAspectRatio);
}
else else
{ {
_graphicsView->resetTransform(); _graphicsView->resetTransform();
@@ -432,6 +454,27 @@ void ImageView::setGraphicsViewScaled(bool scaled)
} }
} }
void ImageView::setGraphicsViewScaledToHeight(bool scaled)
{
_graphicsViewScaledToHeight->setChecked(scaled);
if(scaled)
{
QRectF rect = _graphicsView->sceneRect();
rect.setWidth(1);
_graphicsView->fitInView(rect, Qt::KeepAspectRatio);
}
else
{
_graphicsView->resetTransform();
}
if(!_graphicsView->isVisible())
{
this->update();
}
}
void ImageView::setDefaultBackgroundColor(const QColor & color) void ImageView::setDefaultBackgroundColor(const QColor & color)
{ {
_defaultBgColor = color; _defaultBgColor = color;
@@ -566,9 +609,18 @@ void ImageView::paintEvent(QPaintEvent *event)
void ImageView::resizeEvent(QResizeEvent* event) void ImageView::resizeEvent(QResizeEvent* event)
{ {
QWidget::resizeEvent(event); QWidget::resizeEvent(event);
if(_graphicsView->isVisible() && _graphicsViewScaled->isChecked()) if(_graphicsView->isVisible())
{ {
_graphicsView->fitInView(_graphicsView->sceneRect(), Qt::KeepAspectRatio); if(_graphicsViewScaled->isChecked())
{
_graphicsView->fitInView(_graphicsView->sceneRect(), Qt::KeepAspectRatio);
}
else if(_graphicsViewScaledToHeight->isChecked())
{
QRectF rect = _graphicsView->sceneRect();
rect.setWidth(1);
_graphicsView->fitInView(rect, Qt::KeepAspectRatio);
}
} }
} }
@@ -632,6 +684,11 @@ void ImageView::contextMenuEvent(QContextMenuEvent * e)
this->setGraphicsViewScaled(_graphicsViewScaled->isChecked()); this->setGraphicsViewScaled(_graphicsViewScaled->isChecked());
Q_EMIT configChanged(); Q_EMIT configChanged();
} }
else if(action == _graphicsViewScaledToHeight || action == _graphicsViewNoScaling)
{
this->setGraphicsViewScaledToHeight(_graphicsViewScaledToHeight->isChecked());
Q_EMIT configChanged();
}
else if(action == _setAlpha) else if(action == _setAlpha)
{ {
bool ok = false; bool ok = false;
@@ -933,6 +990,12 @@ void ImageView::setSceneRect(const QRectF & rect)
{ {
_graphicsView->fitInView(_graphicsView->sceneRect(), Qt::KeepAspectRatio); _graphicsView->fitInView(_graphicsView->sceneRect(), Qt::KeepAspectRatio);
} }
else if(_graphicsViewScaledToHeight->isChecked())
{
QRectF rect = _graphicsView->sceneRect();
rect.setWidth(1);
_graphicsView->fitInView(rect, Qt::KeepAspectRatio);
}
else else
{ {
_graphicsView->resetTransform(); _graphicsView->resetTransform();

View File

@@ -61,8 +61,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>398</width> <width>327</width>
<height>242</height> <height>222</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1"> <layout class="QGridLayout" name="gridLayout" columnstretch="0,1">
@@ -253,8 +253,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>397</width> <width>327</width>
<height>242</height> <height>222</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,1"> <layout class="QGridLayout" name="gridLayout_2" columnstretch="0,1">
@@ -1221,15 +1221,15 @@
<item> <item>
<widget class="QToolBox" name="toolBox"> <widget class="QToolBox" name="toolBox">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="page_3"> <widget class="QWidget" name="page_3">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>318</width> <width>312</width>
<height>219</height> <height>200</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
@@ -1389,9 +1389,9 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>-167</y>
<width>282</width> <width>441</width>
<height>845</height> <height>764</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
@@ -1439,7 +1439,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="11" column="1"> <item row="12" column="1">
<widget class="QLabel" name="label_54"> <widget class="QLabel" name="label_54">
<property name="text"> <property name="text">
<string>Voxel size (for clouds and scans)</string> <string>Voxel size (for clouds and scans)</string>
@@ -1466,7 +1466,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="11" column="0"> <item row="12" column="0">
<widget class="QDoubleSpinBox" name="doubleSpinBox_voxelSize"> <widget class="QDoubleSpinBox" name="doubleSpinBox_voxelSize">
<property name="suffix"> <property name="suffix">
<string> m</string> <string> m</string>
@@ -1524,6 +1524,25 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0">
<widget class="QComboBox" name="comboBox_octomap_rendering_type">
<item>
<property name="text">
<string>Point Cloud</string>
</property>
</item>
<item>
<property name="text">
<string>Cube</string>
</property>
</item>
<item>
<property name="text">
<string>Volume</string>
</property>
</item>
</widget>
</item>
<item row="8" column="1"> <item row="8" column="1">
<widget class="QLabel" name="label_octomap_depth"> <widget class="QLabel" name="label_octomap_depth">
<property name="text"> <property name="text">
@@ -1544,25 +1563,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0">
<widget class="QComboBox" name="comboBox_octomap_rendering_type">
<item>
<property name="text">
<string>Point Cloud</string>
</property>
</item>
<item>
<property name="text">
<string>Cube</string>
</property>
</item>
<item>
<property name="text">
<string>Volume</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="label_octomap_empty"> <widget class="QLabel" name="label_octomap_empty">
<property name="text"> <property name="text">
@@ -1657,6 +1657,32 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="11" column="1">
<widget class="QLabel" name="label_56">
<property name="text">
<string>Decimation (for images)</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QSpinBox" name="spinBox_decimation">
<property name="prefix">
<string/>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>16</number>
</property>
<property name="value">
<number>16</number>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@@ -1898,8 +1924,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>205</width> <width>200</width>
<height>117</height> <height>111</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">
@@ -1998,8 +2024,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>185</width> <width>179</width>
<height>487</height> <height>452</height>
</rect> </rect>
</property> </property>
<attribute name="label"> <attribute name="label">