From cdb1e29d453cef3a575660550d69803b1d289b74 Mon Sep 17 00:00:00 2001 From: Mathieu Labbe Date: Mon, 12 Jan 2015 17:43:42 -0500 Subject: [PATCH] Fixed not working "Insert data in GUI cache" when disabled --- guilib/src/ExportCloudsDialog.cpp | 9 +++ guilib/src/ExportCloudsDialog.h | 1 + guilib/src/MainWindow.cpp | 119 +++++++++++++++++------------- 3 files changed, 78 insertions(+), 51 deletions(-) diff --git a/guilib/src/ExportCloudsDialog.cpp b/guilib/src/ExportCloudsDialog.cpp index 01c1dafe..840d7f2f 100644 --- a/guilib/src/ExportCloudsDialog.cpp +++ b/guilib/src/ExportCloudsDialog.cpp @@ -56,6 +56,15 @@ void ExportCloudsDialog::setOkButton() _ui->checkBox_binary->setVisible(false); } +void ExportCloudsDialog::enableRegeneration(bool enabled) +{ + if(!enabled) + { + _ui->groupBox_regenerate->setChecked(false); + } + _ui->groupBox_regenerate->setEnabled(enabled); +} + bool ExportCloudsDialog::getAssemble() const { return _ui->groupBox_assemble->isChecked(); diff --git a/guilib/src/ExportCloudsDialog.h b/guilib/src/ExportCloudsDialog.h index d22ab1b0..ac653e93 100644 --- a/guilib/src/ExportCloudsDialog.h +++ b/guilib/src/ExportCloudsDialog.h @@ -45,6 +45,7 @@ public: void setSaveButton(); void setOkButton(); + void enableRegeneration(bool enabled); bool getAssemble() const; double getAssembleVoxel() const; diff --git a/guilib/src/MainWindow.cpp b/guilib/src/MainWindow.cpp index bf9916ff..8f2147f3 100644 --- a/guilib/src/MainWindow.cpp +++ b/guilib/src/MainWindow.cpp @@ -1060,6 +1060,11 @@ void MainWindow::processStats(const rtabmap::Statistics & stat) this->captureScreen(); } _processingStatistics = false; + + if(!_preferencesDialog->isImagesKept()) + { + _cachedSignatures.clear(); + } } void MainWindow::updateMapCloud( @@ -1101,7 +1106,7 @@ void MainWindow::updateMapCloud( } } - _ui->actionPost_processing->setEnabled(_currentPosesMap.size() >= 2 && _currentLinksMap.size() >= 1); + _ui->actionPost_processing->setEnabled(_cachedSignatures.size() >= 2 && _currentPosesMap.size() >= 2 && _currentLinksMap.size() >= 1); } // filter duplicated poses @@ -1518,10 +1523,10 @@ void MainWindow::updateNodeVisibility(int nodeId, bool visible) if(_currentPosesMap.find(nodeId) != _currentPosesMap.end()) { QMap viewerClouds = _ui->widget_cloudViewer->getAddedClouds(); - if(_preferencesDialog->isCloudsShown(0) && _cachedSignatures.contains(nodeId)) + if(_preferencesDialog->isCloudsShown(0)) { std::string cloudName = uFormat("cloud%d", nodeId); - if(visible && !viewerClouds.contains(cloudName)) + if(visible && !viewerClouds.contains(cloudName) && _cachedSignatures.contains(nodeId)) { createAndAddCloudToMap(nodeId, _currentPosesMap.find(nodeId)->second, uValue(_currentMapIds, nodeId, -1)); } @@ -1536,10 +1541,10 @@ void MainWindow::updateNodeVisibility(int nodeId, bool visible) } } - if(_preferencesDialog->isScansShown(0) && _cachedSignatures.contains(nodeId)) + if(_preferencesDialog->isScansShown(0)) { std::string scanName = uFormat("scan%d", nodeId); - if(visible && !viewerClouds.contains(scanName)) + if(visible && !viewerClouds.contains(scanName) && _cachedSignatures.contains(nodeId)) { createAndAddScanToMap(nodeId, _currentPosesMap.find(nodeId)->second, uValue(_currentMapIds, nodeId, -1)); } @@ -1714,6 +1719,11 @@ void MainWindow::processRtabmapEvent3DMap(const rtabmap::RtabmapEvent3DMap & eve } _initProgressDialog->appendText(tr("%1 locations are updated to/inserted in the cache.").arg(event.getPoses().size())); + + if(!_preferencesDialog->isImagesKept()) + { + _cachedSignatures.clear(); + } } _initProgressDialog->setValue(_initProgressDialog->maximumSteps()); } @@ -2711,6 +2721,11 @@ void MainWindow::generateTOROMap() void MainWindow::postProcessing() { + if(_cachedSignatures.size() == 0) + { + UERROR("Signatures must be cached in the GUI to post processing."); + return; + } if(_postProcessingDialog->exec() != QDialog::Accepted) { return; @@ -3901,6 +3916,7 @@ bool MainWindow::getExportedClouds( { _exportDialog->setOkButton(); } + _exportDialog->enableRegeneration(_preferencesDialog->isImagesKept()); if(_exportDialog->exec() == QDialog::Accepted) { std::map poses = _ui->widget_mapVisibility->getVisiblePoses(); @@ -4453,14 +4469,15 @@ pcl::PointCloud::Ptr MainWindow::getAssembledCloud( bool inserted = false; if(!iter->second.isNull()) { - if(_cachedSignatures.contains(iter->first)) + pcl::PointCloud::Ptr cloud(new pcl::PointCloud); + if(regenerateClouds) { - const Signature & s = _cachedSignatures.find(iter->first).value(); - cv::Mat image, depth; - s.uncompressDataConst(&image, &depth, 0); - pcl::PointCloud::Ptr cloud; - if(regenerateClouds) + if(_cachedSignatures.contains(iter->first)) { + const Signature & s = _cachedSignatures.find(iter->first).value(); + cv::Mat image, depth; + s.uncompressDataConst(&image, &depth, 0); + cloud = createCloud(iter->first, image, depth, @@ -4474,22 +4491,22 @@ pcl::PointCloud::Ptr MainWindow::getAssembledCloud( regenerateDecimation, regenerateMaxDepth); } - else if(uContains(_createdClouds, iter->first)) + else { - cloud = util3d::transformPointCloud(_createdClouds.at(iter->first), iter->second); - } - - if(cloud->size()) - { - *assembledCloud += *cloud; - - inserted = true; - ++count; + UWARN("Cloud %d not found in cache!", iter->first); } } - else + else if(uContains(_createdClouds, iter->first)) { - UERROR("Cloud %d not found?!?", iter->first); + cloud = util3d::transformPointCloud(_createdClouds.at(iter->first), iter->second); + } + + if(cloud->size()) + { + *assembledCloud += *cloud; + + inserted = true; + ++count; } } else @@ -4539,41 +4556,41 @@ std::map::Ptr > MainWindow::getClouds( bool inserted = false; if(!iter->second.isNull()) { - if(_cachedSignatures.contains(iter->first)) + pcl::PointCloud::Ptr cloud(new pcl::PointCloud); + if(regenerateClouds) { - const Signature & s = _cachedSignatures.find(iter->first).value(); - cv::Mat image, depth; - s.uncompressDataConst(&image, &depth, 0); - pcl::PointCloud::Ptr cloud; - if(regenerateClouds) + if(_cachedSignatures.contains(iter->first)) { - cloud = createCloud(iter->first, - image, - depth, - s.getDepthFx(), - s.getDepthFy(), - s.getDepthCx(), - s.getDepthCy(), - s.getLocalTransform(), - Transform::getIdentity(), - regenerateVoxelSize, - regenerateDecimation, - regenerateMaxDepth); + const Signature & s = _cachedSignatures.find(iter->first).value(); + cv::Mat image, depth; + s.uncompressDataConst(&image, &depth, 0); + cloud = createCloud(iter->first, + image, + depth, + s.getDepthFx(), + s.getDepthFy(), + s.getDepthCx(), + s.getDepthCy(), + s.getLocalTransform(), + Transform::getIdentity(), + regenerateVoxelSize, + regenerateDecimation, + regenerateMaxDepth); } - else if(uContains(_createdClouds, iter->first)) + else { - cloud = _createdClouds.at(iter->first); - } - - if(cloud->size()) - { - clouds.insert(std::make_pair(iter->first, cloud)); - inserted = true; + UERROR("Cloud %d not found in cache!", iter->first); } } - else + else if(uContains(_createdClouds, iter->first)) { - UERROR("Cloud %d not found?!?", iter->first); + cloud = _createdClouds.at(iter->first); + } + + if(cloud->size()) + { + clouds.insert(std::make_pair(iter->first, cloud)); + inserted = true; } } else