mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-01 17:10:26 +08:00
Added cloud smoothing (MLS) to save clouds
Modified saving questions to yes for merging clouds before saving or meshing git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@1335 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
@@ -1125,9 +1125,19 @@ void MainWindow::updateMapCloud(const std::map<int, Transform> & posesIn, const
|
||||
|
||||
}
|
||||
}
|
||||
else if(!_ui->widget_cloudViewer->addOrUpdateCloud(cloudName, cloud, iter->second))
|
||||
else
|
||||
{
|
||||
UERROR("Adding cloud %d to viewer failed!", iter->first);
|
||||
if(_preferencesDialog->getMeshSmoothing(0))
|
||||
{
|
||||
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloudWithNormals;
|
||||
cloudWithNormals = util3d::computeNormalsSmoothed(cloud, (float)_preferencesDialog->getMeshSmoothingRadius(0));
|
||||
cloud->clear();
|
||||
pcl::copyPointCloud(*cloudWithNormals, *cloud);
|
||||
}
|
||||
if(!_ui->widget_cloudViewer->addOrUpdateCloud(cloudName, cloud, iter->second))
|
||||
{
|
||||
UERROR("Adding cloud %d to viewer failed!", iter->first);
|
||||
}
|
||||
}
|
||||
|
||||
_ui->widget_cloudViewer->setCloudOpacity(cloudName, _preferencesDialog->getCloudOpacity(0));
|
||||
@@ -2910,7 +2920,7 @@ void MainWindow::savePointClouds()
|
||||
{
|
||||
int button = QMessageBox::question(this,
|
||||
tr("One or multiple files?"),
|
||||
tr("Save clouds separately?"),
|
||||
tr("Merge all clouds together?"),
|
||||
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
|
||||
|
||||
if(button == QMessageBox::Yes || button == QMessageBox::No)
|
||||
@@ -2921,9 +2931,21 @@ void MainWindow::savePointClouds()
|
||||
_initProgressDialog->setMaximumSteps(_currentPosesMap.size()*2+1);
|
||||
|
||||
std::map<int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr> clouds;
|
||||
if(button == QMessageBox::No)
|
||||
if(button == QMessageBox::Yes)
|
||||
{
|
||||
clouds.insert(std::make_pair(0, this->createAssembledCloud()));
|
||||
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud = this->createAssembledCloud();
|
||||
if(_preferencesDialog->getMeshSmoothing(1))
|
||||
{
|
||||
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloudWithNormals;
|
||||
_initProgressDialog->appendText(tr("Smoothing the surface using Moving Least Squares algorithm..."));
|
||||
_initProgressDialog->incrementStep();
|
||||
QApplication::processEvents();
|
||||
|
||||
cloudWithNormals = util3d::computeNormalsSmoothed(cloud, (float)_preferencesDialog->getMeshSmoothingRadius(1));
|
||||
cloud->clear();
|
||||
pcl::copyPointCloud(*cloudWithNormals, *cloud);
|
||||
}
|
||||
clouds.insert(std::make_pair(0, cloud));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2938,7 +2960,9 @@ void MainWindow::saveMeshes()
|
||||
{
|
||||
int button = QMessageBox::question(this,
|
||||
tr("One or multiple files?"),
|
||||
tr("Save meshes separately?"),
|
||||
tr("Merge all clouds together before surface reconstruction?\n"
|
||||
" Yes: Output a single mesh for the merged clouds.\n"
|
||||
" No: Output a mesh for each cloud."),
|
||||
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
|
||||
|
||||
if(button == QMessageBox::Yes || button == QMessageBox::No)
|
||||
@@ -2949,18 +2973,35 @@ void MainWindow::saveMeshes()
|
||||
_initProgressDialog->setMaximumSteps(_currentPosesMap.size()*2+1);
|
||||
|
||||
std::map<int, pcl::PolygonMesh::Ptr> meshes;
|
||||
if(button == QMessageBox::No)
|
||||
if(button == QMessageBox::Yes)
|
||||
{
|
||||
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud = this->createAssembledCloud();
|
||||
_initProgressDialog->appendText(tr("Meshing the assembled cloud (%1 points)...").arg(cloud->size()));
|
||||
_initProgressDialog->incrementStep();
|
||||
QApplication::processEvents();
|
||||
|
||||
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloudWithNormals;
|
||||
if(_preferencesDialog->getMeshSmoothing(1))
|
||||
{
|
||||
_initProgressDialog->appendText(tr("Smoothing the surface using Moving Least Squares algorithm..."));
|
||||
_initProgressDialog->incrementStep();
|
||||
QApplication::processEvents();
|
||||
|
||||
cloudWithNormals = util3d::computeNormalsSmoothed(cloud, (float)_preferencesDialog->getMeshSmoothingRadius(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
_initProgressDialog->appendText(tr("Computing surface normals (without smoothing)..."));
|
||||
_initProgressDialog->incrementStep();
|
||||
QApplication::processEvents();
|
||||
|
||||
cloudWithNormals = util3d::computeNormals(cloud, _preferencesDialog->getMeshNormalKSearch(1));
|
||||
}
|
||||
|
||||
_initProgressDialog->appendText(tr("Greedy projection triangulation..."));
|
||||
_initProgressDialog->incrementStep();
|
||||
QApplication::processEvents();
|
||||
|
||||
pcl::PolygonMesh::Ptr mesh = util3d::createMesh(cloudWithNormals, _preferencesDialog->getMeshGP3Radius(1));
|
||||
meshes.insert(std::make_pair(0, mesh));
|
||||
}
|
||||
@@ -2979,7 +3020,7 @@ void MainWindow::viewPointClouds()
|
||||
{
|
||||
int button = QMessageBox::question(this,
|
||||
tr("One or multiple clouds?"),
|
||||
tr("View clouds separately?"),
|
||||
tr("Merge all clouds together?"),
|
||||
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
|
||||
|
||||
if(button == QMessageBox::Yes || button == QMessageBox::No)
|
||||
@@ -2990,9 +3031,23 @@ void MainWindow::viewPointClouds()
|
||||
_initProgressDialog->setMaximumSteps(_currentPosesMap.size()+1);
|
||||
|
||||
std::map<int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr> clouds;
|
||||
if(button == QMessageBox::No)
|
||||
if(button == QMessageBox::Yes)
|
||||
{
|
||||
clouds.insert(std::make_pair(0, this->createAssembledCloud()));
|
||||
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud = this->createAssembledCloud();
|
||||
|
||||
if(_preferencesDialog->getMeshSmoothing(1))
|
||||
{
|
||||
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloudWithNormals;
|
||||
_initProgressDialog->appendText(tr("Smoothing the surface using Moving Least Squares algorithm..."));
|
||||
_initProgressDialog->incrementStep();
|
||||
QApplication::processEvents();
|
||||
|
||||
cloudWithNormals = util3d::computeNormalsSmoothed(cloud, (float)_preferencesDialog->getMeshSmoothingRadius(1));
|
||||
cloud->clear();
|
||||
pcl::copyPointCloud(*cloudWithNormals, *cloud);
|
||||
}
|
||||
|
||||
clouds.insert(std::make_pair(0, cloud));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3039,7 +3094,9 @@ void MainWindow::viewMeshes()
|
||||
{
|
||||
int button = QMessageBox::question(this,
|
||||
tr("One or multiple meshes?"),
|
||||
tr("View meshes separately?"),
|
||||
tr("Merge all clouds together before surface reconstruction?\n"
|
||||
" Yes: Output a single mesh for the merged clouds.\n"
|
||||
" No: Output a mesh for each cloud."),
|
||||
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
|
||||
|
||||
if(button == QMessageBox::Yes || button == QMessageBox::No)
|
||||
@@ -3050,7 +3107,7 @@ void MainWindow::viewMeshes()
|
||||
_initProgressDialog->setMaximumSteps(_currentPosesMap.size()+1);
|
||||
|
||||
std::map<int, pcl::PolygonMesh::Ptr> meshes;
|
||||
if(button == QMessageBox::No)
|
||||
if(button == QMessageBox::Yes)
|
||||
{
|
||||
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud = this->createAssembledCloud();
|
||||
_initProgressDialog->appendText(tr("Meshing the assembled cloud (%1 points)...").arg(cloud->size()));
|
||||
@@ -3060,12 +3117,25 @@ void MainWindow::viewMeshes()
|
||||
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloudWithNormals;
|
||||
if(_preferencesDialog->getMeshSmoothing(1))
|
||||
{
|
||||
_initProgressDialog->appendText(tr("Smoothing the surface using Moving Least Squares algorithm..."));
|
||||
_initProgressDialog->incrementStep();
|
||||
QApplication::processEvents();
|
||||
|
||||
cloudWithNormals = util3d::computeNormalsSmoothed(cloud, (float)_preferencesDialog->getMeshSmoothingRadius(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
_initProgressDialog->appendText(tr("Computing surface normals (without smoothing)..."));
|
||||
_initProgressDialog->incrementStep();
|
||||
QApplication::processEvents();
|
||||
|
||||
cloudWithNormals = util3d::computeNormals(cloud, _preferencesDialog->getMeshNormalKSearch(1));
|
||||
}
|
||||
|
||||
_initProgressDialog->appendText(tr("Greedy projection triangulation..."));
|
||||
_initProgressDialog->incrementStep();
|
||||
QApplication::processEvents();
|
||||
|
||||
pcl::PolygonMesh::Ptr mesh = util3d::createMesh(cloudWithNormals, _preferencesDialog->getMeshGP3Radius(1));
|
||||
meshes.insert(std::make_pair(0, mesh));
|
||||
}
|
||||
@@ -3507,6 +3577,14 @@ std::map<int, pcl::PointCloud<pcl::PointXYZRGB>::Ptr > MainWindow::createPointCl
|
||||
|
||||
if(cloud->size())
|
||||
{
|
||||
if(_preferencesDialog->getMeshSmoothing(1))
|
||||
{
|
||||
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloudWithNormals;
|
||||
cloudWithNormals = util3d::computeNormalsSmoothed(cloud, (float)_preferencesDialog->getMeshSmoothingRadius(1));
|
||||
cloud->clear();
|
||||
pcl::copyPointCloud(*cloudWithNormals, *cloud);
|
||||
}
|
||||
|
||||
clouds.insert(std::make_pair(iter->first, cloud));
|
||||
inserted = true;
|
||||
}
|
||||
|
||||
@@ -713,7 +713,7 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
|
||||
for(int i=0; i<3; ++i)
|
||||
{
|
||||
_3dRenderingShowClouds[i]->setChecked(true);
|
||||
_3dRenderingVoxelSize[i]->setValue(i==2?0.01:0.00);
|
||||
_3dRenderingVoxelSize[i]->setValue(i==2?0.005:0.00);
|
||||
_3dRenderingDecimation[i]->setValue(i==0?4:i==1?2:1);
|
||||
_3dRenderingMaxDepth[i]->setValue(i==1?0.0:4.0);
|
||||
_3dRenderingShowScans[i]->setChecked(true);
|
||||
@@ -727,7 +727,7 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
|
||||
|
||||
_3dRenderingNormalKSearch[i]->setValue(20);
|
||||
_3dRenderingGP3Radius[i]->setValue(0.04);
|
||||
_3dRenderingSmoothing[i]->setChecked(true);
|
||||
_3dRenderingSmoothing[i]->setChecked(i==0?false:true);
|
||||
_3dRenderingSmoothingRadius[i]->setValue(0.04);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>729</width>
|
||||
<height>823</height>
|
||||
<height>836</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_16">
|
||||
@@ -86,7 +86,7 @@
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>15</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_22">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_29">
|
||||
@@ -490,7 +490,7 @@ High-res view</string>
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.010000000000000</double>
|
||||
<double>0.005000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -916,7 +916,7 @@ High-res view</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user