Image Decimation can now be negative, meaning that decimation is done from RGB size instead of depth. If Depth size is smaller than RGB, it may be upsampled depending on the decimation value. Export Dialog: Fixed MLS not done even when checked.

This commit is contained in:
matlabbe
2016-10-30 16:03:23 -04:00
parent 20a5d80647
commit 768c864766
12 changed files with 230 additions and 183 deletions

View File

@@ -1706,7 +1706,11 @@ void DatabaseViewer::view3DMap()
items.append("4");
items.append("8");
items.append("16");
QString item = QInputDialog::getItem(this, tr("Decimation?"), tr("Image decimation"), items, 2, false, &ok);
items.append("-2");
items.append("-4");
items.append("-8");
items.append("-16");
QString item = QInputDialog::getItem(this, tr("Decimation?"), tr("Image decimation. Negative decimation is done from RGB size instead of depth size (if depth is smaller than RGB, it may be interpolated depending of the decimation value)."), items, 2, false, &ok);
if(ok)
{
int decimation = item.toInt();
@@ -1928,7 +1932,11 @@ void DatabaseViewer::generate3DMap()
items.append("4");
items.append("8");
items.append("16");
QString item = QInputDialog::getItem(this, tr("Decimation?"), tr("Image decimation"), items, 2, false, &ok);
items.append("-2");
items.append("-4");
items.append("-8");
items.append("-16");
QString item = QInputDialog::getItem(this, tr("Decimation?"), tr("Image decimation. Negative decimation is done from RGB size instead of depth size (if depth is smaller than RGB, it may be interpolated depending of the decimation value)."), items, 2, false, &ok);
if(ok)
{
int decimation = item.toInt();
@@ -4129,14 +4137,14 @@ void DatabaseViewer::refineConstraint(int from, int to, bool silent, bool update
dataTo.uncompressData(&tmpC, &tmpD, 0);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloudFrom = util3d::cloudFromSensorData(
dataFrom,
ui_->spinBox_icp_decimation->value(),
ui_->spinBox_icp_decimation->value()==0?1:ui_->spinBox_icp_decimation->value(),
ui_->doubleSpinBox_icp_maxDepth->value(),
ui_->doubleSpinBox_icp_minDepth->value(),
0,
ui_->parameters_toolbox->getParameters());
pcl::PointCloud<pcl::PointXYZ>::Ptr cloudTo = util3d::cloudFromSensorData(
dataTo,
ui_->spinBox_icp_decimation->value(),
ui_->spinBox_icp_decimation->value()==0?1:ui_->spinBox_icp_decimation->value(),
ui_->doubleSpinBox_icp_maxDepth->value(),
ui_->doubleSpinBox_icp_minDepth->value(),
0,

View File

@@ -358,6 +358,7 @@ void ExportCloudsDialog::restoreDefaults()
void ExportCloudsDialog::updateReconstructionFlavor()
{
_ui->groupBox_mls->setVisible(_ui->comboBox_pipeline->currentIndex() == 1);
_ui->groupBox_mls->setEnabled(_ui->comboBox_pipeline->currentIndex() == 1);
_ui->groupBox_gp3->setVisible(_ui->comboBox_pipeline->currentIndex() == 1);
_ui->groupBox_organized->setVisible(_ui->comboBox_pipeline->currentIndex() == 0);
}
@@ -818,7 +819,7 @@ bool ExportCloudsDialog::getExportedClouds(
}
std::map<int, Transform> viewPoints = poses;
if(_ui->groupBox_mls->isVisible() && _ui->groupBox_mls->isChecked())
if(_ui->groupBox_mls->isEnabled() && _ui->groupBox_mls->isChecked())
{
_progressDialog->appendText(tr("Smoothing the surface using Moving Least Squares (MLS) algorithm... "
"[search radius=%1m voxel=%2m]").arg(_ui->doubleSpinBox_mlsRadius->value()).arg(_ui->doubleSpinBox_voxelSize_assembled->value()));
@@ -850,10 +851,10 @@ bool ExportCloudsDialog::getExportedClouds(
{
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloudWithNormals = iter->second.first;
if(_ui->groupBox_mls->isVisible() && _ui->groupBox_mls->isChecked())
if(_ui->groupBox_mls->isEnabled() && _ui->groupBox_mls->isChecked())
{
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudWithoutNormals(new pcl::PointCloud<pcl::PointXYZRGB>);
if(iter->second.first->isOrganized())
if(iter->second.second->size())
{
pcl::copyPointCloud(*cloudWithNormals, *iter->second.second, *cloudWithoutNormals);
}
@@ -1244,65 +1245,70 @@ bool ExportCloudsDialog::getExportedClouds(
int w = ster->second.width;
int h = ster->second.height;
UASSERT(w > 1 && h > 1);
UASSERT(textureMesh->tex_polygons.size() && textureMesh->tex_polygons[0].size());
textureMesh->tex_coordinates.resize(1);
if(!_ui->checkBox_mesh_quad->isEnabled()) // disabled -> we are exporting to file
if(textureMesh->tex_polygons.size() && textureMesh->tex_polygons[0].size())
{
// When saving to file, tex_coordinates should be linked to polygon vertices, not points
int polygonSize = textureMesh->tex_polygons[0][0].vertices.size();
textureMesh->tex_coordinates[0].resize(polygonSize*textureMesh->tex_polygons[0].size());
for(unsigned int i=0; i<textureMesh->tex_polygons[0].size(); ++i)
textureMesh->tex_coordinates.resize(1);
if(!_ui->checkBox_mesh_quad->isEnabled()) // disabled -> we are exporting to file
{
const pcl::Vertices & vertices = textureMesh->tex_polygons[0][i];
UASSERT(polygonSize == (int)vertices.vertices.size());
for(int k=0; k<polygonSize; ++k)
// When saving to file, tex_coordinates should be linked to polygon vertices, not points
int polygonSize = textureMesh->tex_polygons[0][0].vertices.size();
textureMesh->tex_coordinates[0].resize(polygonSize*textureMesh->tex_polygons[0].size());
for(unsigned int i=0; i<textureMesh->tex_polygons[0].size(); ++i)
{
const pcl::Vertices & vertices = textureMesh->tex_polygons[0][i];
UASSERT(polygonSize == (int)vertices.vertices.size());
for(int k=0; k<polygonSize; ++k)
{
//uv
UASSERT(vertices.vertices[k] < oter->second.size());
int originalVertex = oter->second[vertices.vertices[k]];
textureMesh->tex_coordinates[0][i*polygonSize+k] = Eigen::Vector2f(
float(originalVertex % w) / float(w), // u
float(h - originalVertex / w) / float(h)); // v
}
}
}
else
{
int nPoints = textureMesh->cloud.data.size()/textureMesh->cloud.point_step;
textureMesh->tex_coordinates[0].resize(nPoints);
for(int i=0; i<nPoints; ++i)
{
//uv
UASSERT(vertices.vertices[k] < oter->second.size());
int originalVertex = oter->second[vertices.vertices[k]];
textureMesh->tex_coordinates[0][i*polygonSize+k] = Eigen::Vector2f(
UASSERT(i < (int)oter->second.size());
int originalVertex = oter->second[i];
textureMesh->tex_coordinates[0][i] = Eigen::Vector2f(
float(originalVertex % w) / float(w), // u
float(h - originalVertex / w) / float(h)); // v
}
}
}
else
{
int nPoints = textureMesh->cloud.data.size()/textureMesh->cloud.point_step;
textureMesh->tex_coordinates[0].resize(nPoints);
for(int i=0; i<nPoints; ++i)
pcl::TexMaterial mesh_material;
mesh_material.tex_d = 1.0f;
mesh_material.tex_Ns = 75.0f;
mesh_material.tex_illum = 1;
std::stringstream tex_name;
tex_name << "material_" << iter->first;
tex_name >> mesh_material.tex_name;
std::string tmpDirectory = dir.filePath("tmp_textures").toStdString();
mesh_material.tex_file = uFormat("%s/%s%d.png", tmpDirectory.c_str(), "texture_", iter->first);
if(!cv::imwrite(mesh_material.tex_file, images.at(iter->first)))
{
//uv
UASSERT(i < (int)oter->second.size());
int originalVertex = oter->second[i];
textureMesh->tex_coordinates[0][i] = Eigen::Vector2f(
float(originalVertex % w) / float(w), // u
float(h - originalVertex / w) / float(h)); // v
UERROR("Cannot save texture of image %d", iter->first);
}
else
{
UINFO("Saved temporary texture: \"%s\"", mesh_material.tex_file.c_str());
}
}
pcl::TexMaterial mesh_material;
mesh_material.tex_d = 1.0f;
mesh_material.tex_Ns = 75.0f;
mesh_material.tex_illum = 1;
std::stringstream tex_name;
tex_name << "material_" << iter->first;
tex_name >> mesh_material.tex_name;
std::string tmpDirectory = dir.filePath("tmp_textures").toStdString();
mesh_material.tex_file = uFormat("%s/%s%d.png", tmpDirectory.c_str(), "texture_", iter->first);
if(!cv::imwrite(mesh_material.tex_file, images.at(iter->first)))
{
UERROR("Cannot save texture of image %d", iter->first);
textureMesh->tex_materials.push_back(mesh_material);
}
else
{
UINFO("Saved temporary texture: \"%s\"", mesh_material.tex_file.c_str());
UWARN("No polygons for mesh %d!?", iter->first);
}
textureMesh->tex_materials.push_back(mesh_material);
}
else
{
@@ -1422,7 +1428,7 @@ std::map<int, std::pair<pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr, pcl::Indic
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloudWithoutNormals;
cloudWithoutNormals = util3d::cloudRGBFromSensorData(
d,
_ui->spinBox_decimation->value(),
_ui->spinBox_decimation->value() == 0?1:_ui->spinBox_decimation->value(),
_ui->doubleSpinBox_maxDepth->value(),
_ui->doubleSpinBox_minDepth->value(),
indices.get(),

View File

@@ -3888,7 +3888,7 @@ int PreferencesDialog::getCloudMeshingTriangleSize()
int PreferencesDialog::getCloudDecimation(int index) const
{
UASSERT(index >= 0 && index <= 1);
return _3dRenderingDecimation[index]->value();
return _3dRenderingDecimation[index]->value()==0?1:_3dRenderingDecimation[index]->value();
}
double PreferencesDialog::getCloudMaxDepth(int index) const
{

View File

@@ -983,7 +983,7 @@
<item>
<widget class="QToolBox" name="toolBox">
<property name="currentIndex">
<number>1</number>
<number>3</number>
</property>
<widget class="QWidget" name="page_3">
<property name="geometry">
@@ -991,7 +991,7 @@
<x>0</x>
<y>0</y>
<width>324</width>
<height>188</height>
<height>210</height>
</rect>
</property>
<attribute name="label">
@@ -1443,8 +1443,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>201</width>
<height>126</height>
<width>283</width>
<height>225</height>
</rect>
</property>
<attribute name="label">
@@ -1543,8 +1543,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>181</width>
<height>200</height>
<width>283</width>
<height>225</height>
</rect>
</property>
<attribute name="label">
@@ -1554,14 +1554,17 @@
<item row="1" column="0">
<widget class="QSpinBox" name="spinBox_icp_decimation">
<property name="minimum">
<number>1</number>
<number>-32</number>
</property>
<property name="maximum">
<number>32</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Decimation</string>
<string>Decimation. Negative decimation is done from RGB size instead of depth size (if depth is smaller than RGB, it may be interpolated depending of the decimation value).</string>
</property>
<property name="wordWrap">
<bool>true</bool>

View File

@@ -23,9 +23,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-823</y>
<y>0</y>
<width>773</width>
<height>1731</height>
<height>1755</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
@@ -173,7 +173,7 @@
<item row="0" column="2">
<widget class="QLabel" name="label_108">
<property name="text">
<string>3D cloud decimation (1-2-4-8-...).</string>
<string>3D cloud decimation (1-2-4-8-...). Negative decimation is done from RGB size instead of depth size (if depth is smaller than RGB, it may be interpolated depending of the decimation value).</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@@ -183,7 +183,7 @@
<item row="0" column="1">
<widget class="QSpinBox" name="spinBox_decimation">
<property name="minimum">
<number>1</number>
<number>-32</number>
</property>
<property name="maximum">
<number>32</number>

View File

@@ -63,25 +63,16 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-577</y>
<width>678</width>
<height>2417</height>
<y>0</y>
<width>673</width>
<height>2520</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@@ -95,7 +86,7 @@
<enum>QFrame::Raised</enum>
</property>
<property name="currentIndex">
<number>5</number>
<number>1</number>
</property>
<widget class="QWidget" name="page_22">
<layout class="QVBoxLayout" name="verticalLayout_29" stretch="0,1">
@@ -776,7 +767,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
<item row="2" column="2">
<widget class="QLabel" name="label_108">
<property name="text">
<string>3D cloud decimation (1-2-4-8-...).</string>
<string>3D cloud decimation (1-2-4-8-...). Negative decimation is done from RGB size instead of depth size (if depth is smaller than RGB, it may be interpolated depending of the decimation value).</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@@ -808,13 +799,13 @@ Show a yellow background when the number of odometry inliers goes under this thr
<item row="2" column="0">
<widget class="QSpinBox" name="spinBox_decimation">
<property name="minimum">
<number>1</number>
<number>-32</number>
</property>
<property name="maximum">
<number>32</number>
</property>
<property name="value">
<number>4</number>
<number>1</number>
</property>
</widget>
</item>
@@ -1099,13 +1090,13 @@ Show a yellow background when the number of odometry inliers goes under this thr
<item row="2" column="1">
<widget class="QSpinBox" name="spinBox_decimation_odom">
<property name="minimum">
<number>1</number>
<number>-32</number>
</property>
<property name="maximum">
<number>32</number>
</property>
<property name="value">
<number>2</number>
<number>1</number>
</property>
</widget>
</item>
@@ -4290,16 +4281,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
<string>Directory of images (optional settings)</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_93">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@@ -5713,7 +5695,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag
<item row="12" column="1">
<widget class="QLabel" name="label_retrieved_13">
<property name="text">
<string>Image pre decimation. This option can be used to reduce image size before features extraction.</string>
<string>Image pre decimation. This option can be used to reduce image size before features extraction. Negative decimation is done from RGB size instead of depth size (if depth is smaller than RGB, it may be interpolated depending of the decimation value).</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@@ -5785,7 +5767,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag
<item row="13" column="0">
<widget class="QSpinBox" name="spinBox_imagePostDecimation">
<property name="minimum">
<number>1</number>
<number>-16</number>
</property>
<property name="maximum">
<number>16</number>
@@ -5831,7 +5813,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag
<item row="13" column="1">
<widget class="QLabel" name="label_retrieved_6">
<property name="text">
<string>Image post decimation. This option can be used to save images in lower resolution (size/decimation). It is done on the original image.</string>
<string>Image post decimation. This option can be used to save images in lower resolution (size/decimation). It is done on the original image. Negative decimation is done from RGB size instead of depth size (if depth is smaller than RGB, it may be interpolated depending of the decimation value).</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@@ -5880,7 +5862,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag
<item row="12" column="0">
<widget class="QSpinBox" name="spinBox_imagePreDecimation">
<property name="minimum">
<number>1</number>
<number>-16</number>
</property>
<property name="maximum">
<number>16</number>
@@ -8516,7 +8498,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag
<item row="0" column="0">
<widget class="QSpinBox" name="spinBox_grid_decimation">
<property name="minimum">
<number>1</number>
<number>-32</number>
</property>
<property name="maximum">
<number>32</number>
@@ -8529,7 +8511,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag
<item row="0" column="1">
<widget class="QLabel" name="label_322">
<property name="text">
<string>Image Decimation (1-2-4-8-...).</string>
<string>Image Decimation (1-2-4-8-...). Negative decimation is done from RGB size instead of depth size (if depth is smaller than RGB, it may be interpolated depending of the decimation value).</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@@ -9352,7 +9334,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag
<item row="7" column="1">
<widget class="QLabel" name="label_248">
<property name="text">
<string>Decimation of images before features extraction.</string>
<string>Decimation of images before features extraction. Negative decimation is done from RGB size instead of depth size (if depth is smaller than RGB, it may be interpolated depending of the decimation value).</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@@ -9365,7 +9347,10 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag
<item row="7" column="0">
<widget class="QSpinBox" name="odom_imageDecimation">
<property name="minimum">
<number>1</number>
<number>-32</number>
</property>
<property name="maximum">
<number>32</number>
</property>
</widget>
</item>
@@ -10376,16 +10361,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag
</property>
<widget class="QWidget" name="page_54">
<layout class="QVBoxLayout" name="verticalLayout_85">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@@ -10525,16 +10501,7 @@ Lower the ratio -&gt; higher the precision. 0 means disabled, matching the neare
</widget>
<widget class="QWidget" name="page_55">
<layout class="QVBoxLayout" name="verticalLayout_86">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@@ -10692,16 +10659,7 @@ Lower the ratio -&gt; higher the precision. 0 means disabled, matching the neare
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@@ -10781,16 +10739,7 @@ Lower the ratio -&gt; higher the precision. 0 means disabled, matching the neare
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>
@@ -10902,16 +10851,7 @@ Lower the ratio -&gt; higher the precision. 0 means disabled, matching the neare
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<item>