CloudViewer: added backface culling option on right-click menu. MainWindow: removed error msg on wrong decimation (util3d already handle this case)

This commit is contained in:
matlabbe
2016-11-27 20:10:05 -05:00
parent 1910cef3d1
commit 3363772ce5
5 changed files with 37 additions and 66 deletions

View File

@@ -866,6 +866,10 @@ Transform RegistrationVis::computeTransformationImpl(
UWARN("saved projected.bmp");*/ UWARN("saved projected.bmp");*/
} }
else
{
UWARN("All projected points are outside the camera. Guess (%s) is wrong or images are not overlapping.", guess.prettyPrint().c_str());
}
UDEBUG(""); UDEBUG("");
} }
else else
@@ -1318,8 +1322,8 @@ Transform RegistrationVis::computeTransformationImpl(
} }
else if(toSignature.sensorData().isValid()) else if(toSignature.sensorData().isValid())
{ {
UWARN("Missing correspondences for registration. toWords = %d toImageEmpty=%d", UWARN("Missing correspondences for registration (%d->%d). toWords = %d toImageEmpty=%d",
(int)toSignature.getWords().size(), toSignature.sensorData().imageRaw().empty()?1:0); fromSignature.id(), toSignature.id(), (int)toSignature.getWords().size(), toSignature.sensorData().imageRaw().empty()?1:0);
} }
info.inliers = inliersCount; info.inliers = inliersCount;

View File

@@ -993,16 +993,6 @@ pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_EXP cloudRGBFromSensorData(
int subRGBWidth = sensorData.imageRaw().cols/sensorData.cameraModels().size(); int subRGBWidth = sensorData.imageRaw().cols/sensorData.cameraModels().size();
int subDepthWidth = sensorData.depthRaw().cols/sensorData.cameraModels().size(); int subDepthWidth = sensorData.depthRaw().cols/sensorData.cameraModels().size();
if(subRGBWidth % decimation != 0 || subDepthWidth % decimation != 0)
{
UWARN("Image size (rgb=%d,%d depth=%d,%d) modulus decimation (%d) is not null "
"for the cloud creation! Setting decimation to 1...",
subRGBWidth, sensorData.imageRaw().rows,
subDepthWidth, sensorData.depthRaw().rows,
decimation);
decimation = 1;
}
for(unsigned int i=0; i<sensorData.cameraModels().size(); ++i) for(unsigned int i=0; i<sensorData.cameraModels().size(); ++i)
{ {
if(sensorData.cameraModels()[i].isValidForProjection()) if(sensorData.cameraModels()[i].isValidForProjection())

View File

@@ -316,6 +316,7 @@ private:
QAction * _aSetRenderingRate; QAction * _aSetRenderingRate;
QAction * _aSetLighting; QAction * _aSetLighting;
QAction * _aSetEdgeVisibility; QAction * _aSetEdgeVisibility;
QAction * _aBackfaceCulling;
QMenu * _menu; QMenu * _menu;
std::set<std::string> _graphes; std::set<std::string> _graphes;
std::set<std::string> _coordinates; std::set<std::string> _coordinates;
@@ -337,7 +338,6 @@ private:
QString _workingDirectory; QString _workingDirectory;
QColor _defaultBgColor; QColor _defaultBgColor;
QColor _currentBgColor; QColor _currentBgColor;
bool _backfaceCulling;
bool _frontfaceCulling; bool _frontfaceCulling;
double _renderingRate; double _renderingRate;
vtkProp * _octomapActor; vtkProp * _octomapActor;

View File

@@ -128,6 +128,7 @@ CloudViewer::CloudViewer(QWidget *parent) :
_aSetRenderingRate(0), _aSetRenderingRate(0),
_aSetLighting(0), _aSetLighting(0),
_aSetEdgeVisibility(0), _aSetEdgeVisibility(0),
_aBackfaceCulling(0),
_menu(0), _menu(0),
_trajectory(new pcl::PointCloud<pcl::PointXYZ>), _trajectory(new pcl::PointCloud<pcl::PointXYZ>),
_maxTrajectorySize(100), _maxTrajectorySize(100),
@@ -140,7 +141,6 @@ CloudViewer::CloudViewer(QWidget *parent) :
_workingDirectory("."), _workingDirectory("."),
_defaultBgColor(Qt::black), _defaultBgColor(Qt::black),
_currentBgColor(Qt::black), _currentBgColor(Qt::black),
_backfaceCulling(false),
_frontfaceCulling(false), _frontfaceCulling(false),
_renderingRate(5.0), _renderingRate(5.0),
_octomapActor(0) _octomapActor(0)
@@ -241,6 +241,9 @@ void CloudViewer::createMenu()
_aSetEdgeVisibility = new QAction("Show edges", this); _aSetEdgeVisibility = new QAction("Show edges", this);
_aSetEdgeVisibility->setCheckable(true); _aSetEdgeVisibility->setCheckable(true);
_aSetEdgeVisibility->setChecked(false); _aSetEdgeVisibility->setChecked(false);
_aBackfaceCulling = new QAction("Backface culling", this);
_aBackfaceCulling->setCheckable(true);
_aBackfaceCulling->setChecked(true);
QMenu * cameraMenu = new QMenu("Camera", this); QMenu * cameraMenu = new QMenu("Camera", this);
cameraMenu->addAction(_aLockCamera); cameraMenu->addAction(_aLockCamera);
@@ -279,6 +282,7 @@ void CloudViewer::createMenu()
_menu->addAction(_aSetRenderingRate); _menu->addAction(_aSetRenderingRate);
_menu->addAction(_aSetLighting); _menu->addAction(_aSetLighting);
_menu->addAction(_aSetEdgeVisibility); _menu->addAction(_aSetEdgeVisibility);
_menu->addAction(_aBackfaceCulling);
} }
void CloudViewer::saveSettings(QSettings & settings, const QString & group) const void CloudViewer::saveSettings(QSettings & settings, const QString & group) const
@@ -542,14 +546,8 @@ bool CloudViewer::addCloudMesh(
{ {
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked()); _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked()); _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
if(_backfaceCulling) _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
{ _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->BackfaceCullingOn();
}
if(_frontfaceCulling)
{
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->FrontfaceCullingOn();
}
_visualizer->updatePointCloudPose(id, pose.toEigen3f()); _visualizer->updatePointCloudPose(id, pose.toEigen3f());
_addedClouds.insert(id, pose); _addedClouds.insert(id, pose);
return true; return true;
@@ -573,14 +571,8 @@ bool CloudViewer::addCloudMesh(
{ {
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked()); _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked()); _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
if(_backfaceCulling) _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
{ _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->BackfaceCullingOn();
}
if(_frontfaceCulling)
{
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->FrontfaceCullingOn();
}
_visualizer->updatePointCloudPose(id, pose.toEigen3f()); _visualizer->updatePointCloudPose(id, pose.toEigen3f());
_addedClouds.insert(id, pose); _addedClouds.insert(id, pose);
return true; return true;
@@ -604,14 +596,8 @@ bool CloudViewer::addCloudMesh(
{ {
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked()); _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked()); _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
if(_backfaceCulling) _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
{ _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->BackfaceCullingOn();
}
if(_frontfaceCulling)
{
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->FrontfaceCullingOn();
}
_visualizer->updatePointCloudPose(id, pose.toEigen3f()); _visualizer->updatePointCloudPose(id, pose.toEigen3f());
_addedClouds.insert(id, pose); _addedClouds.insert(id, pose);
return true; return true;
@@ -634,14 +620,8 @@ bool CloudViewer::addCloudMesh(
{ {
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked()); _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked()); _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
if(_backfaceCulling) _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
{ _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->BackfaceCullingOn();
}
if(_frontfaceCulling)
{
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->FrontfaceCullingOn();
}
_visualizer->updatePointCloudPose(id, pose.toEigen3f()); _visualizer->updatePointCloudPose(id, pose.toEigen3f());
_addedClouds.insert(id, pose); _addedClouds.insert(id, pose);
return true; return true;
@@ -665,14 +645,8 @@ bool CloudViewer::addCloudTextureMesh(
{ {
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked()); _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked()); _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
if(_backfaceCulling) _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
{ _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->BackfaceCullingOn();
}
if(_frontfaceCulling)
{
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->FrontfaceCullingOn();
}
if(!textureMesh->cloud.is_dense) if(!textureMesh->cloud.is_dense)
{ {
_visualizer->getCloudActorMap()->find(id)->second.actor->GetTexture()->SetInterpolate(1); _visualizer->getCloudActorMap()->find(id)->second.actor->GetTexture()->SetInterpolate(1);
@@ -1152,6 +1126,8 @@ bool CloudViewer::addTextureMesh (
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked()); _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetLighting(_aSetLighting->isChecked());
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked()); _visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetEdgeVisibility(_aSetEdgeVisibility->isChecked());
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
_visualizer->getCloudActorMap()->find(id)->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
return true; return true;
} }
@@ -1733,8 +1709,16 @@ Transform CloudViewer::getTargetPose() const
void CloudViewer::setBackfaceCulling(bool enabled, bool frontfaceCulling) void CloudViewer::setBackfaceCulling(bool enabled, bool frontfaceCulling)
{ {
_backfaceCulling = enabled; _aBackfaceCulling->setChecked(enabled);
_frontfaceCulling = frontfaceCulling; _frontfaceCulling = frontfaceCulling;
pcl::visualization::CloudActorMapPtr cloudActorMap = _visualizer->getCloudActorMap();
for(pcl::visualization::CloudActorMap::iterator iter=cloudActorMap->begin(); iter!=cloudActorMap->end(); ++iter)
{
iter->second.actor->GetProperty()->SetBackfaceCulling(_aBackfaceCulling->isChecked());
iter->second.actor->GetProperty()->SetFrontfaceCulling(_frontfaceCulling);
}
this->update();
} }
void CloudViewer::setRenderingRate(double rate) void CloudViewer::setRenderingRate(double rate)
@@ -2507,6 +2491,10 @@ void CloudViewer::handleAction(QAction * a)
{ {
this->setEdgeVisibility(_aSetEdgeVisibility->isChecked()); this->setEdgeVisibility(_aSetEdgeVisibility->isChecked());
} }
else if(a == _aBackfaceCulling)
{
this->setBackfaceCulling(_aBackfaceCulling->isChecked(), _frontfaceCulling);
}
} }
} /* namespace rtabmap */ } /* namespace rtabmap */

View File

@@ -2518,17 +2518,6 @@ std::pair<pcl::PointCloud<pcl::PointXYZRGB>::Ptr, pcl::IndicesPtr> MainWindow::c
pcl::IndicesPtr indices(new std::vector<int>); pcl::IndicesPtr indices(new std::vector<int>);
UASSERT(nodeId == data.id()); UASSERT(nodeId == data.id());
if(image.cols % _preferencesDialog->getCloudDecimation(0) != 0 ||
image.rows % _preferencesDialog->getCloudDecimation(0) != 0)
{
UERROR("Decimation (%d) is not modulo of the image resolution (%dx%d)! The cloud cannot be "
"created. Go to Preferences->3D Rendering under \"Map\" column to modify this parameter.",
_preferencesDialog->getCloudDecimation(0),
image.cols,
image.rows);
return outputPair;
}
// Create organized cloud // Create organized cloud
cloud = util3d::cloudRGBFromSensorData(data, cloud = util3d::cloudRGBFromSensorData(data,
_preferencesDialog->getCloudDecimation(0), _preferencesDialog->getCloudDecimation(0),