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

@@ -348,6 +348,8 @@ DatabaseViewer::DatabaseViewer(const QString & ini, QWidget * parent) :
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(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_->doubleSpinBox_posefilteringRadius, 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
connect(ui_->doubleSpinBox_gainCompensationRadius, 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_->doubleSpinBox_posefilteringRadius, 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");
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_->spinBox_decimation->setValue(settings.value("decimation", ui_->spinBox_decimation->value()).toInt());
settings.endGroup();
settings.beginGroup("grid");
@@ -577,6 +580,7 @@ void DatabaseViewer::writeSettings()
settings.beginGroup("optimization");
settings.setValue("gainCompensationRadius", ui_->doubleSpinBox_gainCompensationRadius->value());
settings.setValue("voxelSize", ui_->doubleSpinBox_voxelSize->value());
settings.setValue("decimation", ui_->spinBox_decimation->value());
settings.endGroup();
// save Grid settings
@@ -660,6 +664,7 @@ void DatabaseViewer::restoreDefaultSettings()
ui_->doubleSpinBox_optimizationScale->setValue(1.0);
ui_->doubleSpinBox_gainCompensationRadius->setValue(0.0);
ui_->doubleSpinBox_voxelSize->setValue(0.0);
ui_->spinBox_decimation->setValue(1);
ui_->groupBox_posefiltering->setChecked(false);
ui_->doubleSpinBox_posefilteringRadius->setValue(0.1);
@@ -3588,7 +3593,7 @@ void DatabaseViewer::update(int value,
data.imageRaw(),
depth,
data.cameraModels()[0],
1,0,0,indices.get());
ui_->spinBox_decimation->value(),0,0,indices.get());
if(indices->size())
{
cloud = util3d::transformPointCloud(cloud, data.cameraModels()[0].localTransform());
@@ -3597,7 +3602,7 @@ void DatabaseViewer::update(int value,
}
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())
{
@@ -3665,7 +3670,7 @@ void DatabaseViewer::update(int value,
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud;
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(ui_->doubleSpinBox_voxelSize->value() > 0.0)
@@ -4572,11 +4577,11 @@ void DatabaseViewer::updateConstraintView(
pcl::IndicesPtr indicesTo(new std::vector<int>);
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())
{
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())

View File

@@ -183,10 +183,21 @@ ImageView::ImageView(QWidget * parent) :
_graphicsViewMode = _menu->addAction(tr("Graphics view"));
_graphicsViewMode->setCheckable(true);
_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->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..."));
_saveImage = _menu->addAction(tr("Save picture..."));
_saveImage->setEnabled(false);
@@ -270,6 +281,11 @@ bool ImageView::isGraphicsViewScaled() const
return _graphicsViewScaled->isChecked();
}
bool ImageView::isGraphicsViewScaledToHeight() const
{
return _graphicsViewScaledToHeight->isChecked();
}
const QColor & ImageView::getDefaultBackgroundColor() const
{
return _defaultBgColor;
@@ -362,7 +378,7 @@ void ImageView::setGraphicsViewMode(bool on)
{
_graphicsViewMode->setChecked(on);
_graphicsView->setVisible(on);
_graphicsViewScaled->setEnabled(on);
_scaleMenu->setEnabled(on);
if(on)
{
@@ -402,6 +418,12 @@ void ImageView::setGraphicsViewMode(bool on)
{
_graphicsView->fitInView(_graphicsView->sceneRect(), Qt::KeepAspectRatio);
}
else if(_graphicsViewScaledToHeight->isChecked())
{
QRectF rect = _graphicsView->sceneRect();
rect.setWidth(1);
_graphicsView->fitInView(rect, Qt::KeepAspectRatio);
}
else
{
_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)
{
_defaultBgColor = color;
@@ -566,9 +609,18 @@ void ImageView::paintEvent(QPaintEvent *event)
void ImageView::resizeEvent(QResizeEvent* 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());
Q_EMIT configChanged();
}
else if(action == _graphicsViewScaledToHeight || action == _graphicsViewNoScaling)
{
this->setGraphicsViewScaledToHeight(_graphicsViewScaledToHeight->isChecked());
Q_EMIT configChanged();
}
else if(action == _setAlpha)
{
bool ok = false;
@@ -933,6 +990,12 @@ void ImageView::setSceneRect(const QRectF & rect)
{
_graphicsView->fitInView(_graphicsView->sceneRect(), Qt::KeepAspectRatio);
}
else if(_graphicsViewScaledToHeight->isChecked())
{
QRectF rect = _graphicsView->sceneRect();
rect.setWidth(1);
_graphicsView->fitInView(rect, Qt::KeepAspectRatio);
}
else
{
_graphicsView->resetTransform();

View File

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