mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 01:20:25 +08:00
Memory efficiency: changed std::vector<unsigned char> bytes arrays to cv::Mat to avoid multiple copies when Signature objects are copied.
git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@1937 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
@@ -279,6 +279,14 @@ void DatabaseViewer::closeEvent(QCloseEvent* event)
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseViewer::showEvent(QShowEvent* anEvent)
|
||||
{
|
||||
ui_->graphicsView_A->fitInView(ui_->graphicsView_A->sceneRect(), Qt::KeepAspectRatio);
|
||||
ui_->graphicsView_B->fitInView(ui_->graphicsView_B->sceneRect(), Qt::KeepAspectRatio);
|
||||
ui_->graphicsView_A->resetZoom();
|
||||
ui_->graphicsView_B->resetZoom();
|
||||
}
|
||||
|
||||
void DatabaseViewer::resizeEvent(QResizeEvent* anEvent)
|
||||
{
|
||||
ui_->graphicsView_A->fitInView(ui_->graphicsView_A->sceneRect(), Qt::KeepAspectRatio);
|
||||
@@ -350,8 +358,8 @@ void DatabaseViewer::extractImages()
|
||||
for(int i=0; i<ids_.size(); i+=1)
|
||||
{
|
||||
int id = ids_.at(i);
|
||||
std::vector<unsigned char> compressedRgb = memory_->getImage(id);
|
||||
if(compressedRgb.size())
|
||||
cv::Mat compressedRgb = memory_->getImageCompressed(id);
|
||||
if(!compressedRgb.empty())
|
||||
{
|
||||
cv::Mat imageMat = rtabmap::util3d::uncompressImage(compressedRgb);
|
||||
cv::imwrite(QString("%1/%2.png").arg(path).arg(id).toStdString(), imageMat);
|
||||
@@ -1300,31 +1308,16 @@ void DatabaseViewer::updateConstraintView(const rtabmap::Link & link,
|
||||
bool updateB = false;
|
||||
ui_->horizontalSlider_A->blockSignals(true);
|
||||
ui_->horizontalSlider_B->blockSignals(true);
|
||||
if(ui_->horizontalSlider_A->value() == idToIndex_.value(link.from()))
|
||||
{
|
||||
ui_->horizontalSlider_B->setValue(idToIndex_.value(link.to()));
|
||||
updateB=true;
|
||||
}
|
||||
else if(ui_->horizontalSlider_A->value() == idToIndex_.value(link.to()))
|
||||
{
|
||||
ui_->horizontalSlider_B->setValue(idToIndex_.value(link.from()));
|
||||
updateB=true;
|
||||
}
|
||||
else if(ui_->horizontalSlider_B->value() == idToIndex_.value(link.from()))
|
||||
{
|
||||
ui_->horizontalSlider_A->setValue(idToIndex_.value(link.to()));
|
||||
updateA = true;
|
||||
}
|
||||
else if(ui_->horizontalSlider_B->value() == idToIndex_.value(link.to()))
|
||||
// set from on left and to on right
|
||||
if(ui_->horizontalSlider_A->value() != idToIndex_.value(link.from()))
|
||||
{
|
||||
ui_->horizontalSlider_A->setValue(idToIndex_.value(link.from()));
|
||||
updateA=true;
|
||||
}
|
||||
else
|
||||
if(ui_->horizontalSlider_B->value() != idToIndex_.value(link.to()))
|
||||
{
|
||||
ui_->horizontalSlider_A->setValue(idToIndex_.value(link.from()));
|
||||
ui_->horizontalSlider_B->setValue(idToIndex_.value(link.to()));
|
||||
updateA=updateB=true;
|
||||
updateB=true;
|
||||
}
|
||||
ui_->horizontalSlider_A->blockSignals(false);
|
||||
ui_->horizontalSlider_B->blockSignals(false);
|
||||
@@ -1505,10 +1498,10 @@ void DatabaseViewer::sliderIterationsValueChanged(int value)
|
||||
for(int i=0; i<ids_.size(); ++i)
|
||||
{
|
||||
Signature data = memory_->getSignatureData(ids_.at(i), false);
|
||||
if(data.getDepth2D().size())
|
||||
if(!data.getDepth2DCompressed().empty())
|
||||
{
|
||||
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud;
|
||||
cv::Mat depth2d = rtabmap::util3d::uncompressData(data.getDepth2D());
|
||||
cv::Mat depth2d = rtabmap::util3d::uncompressData(data.getDepth2DCompressed());
|
||||
cloud = rtabmap::util3d::depth2DToPointCloud(depth2d);
|
||||
scans_.insert(std::make_pair(ids_.at(i), cloud));
|
||||
}
|
||||
@@ -1681,8 +1674,8 @@ void DatabaseViewer::refineConstraint(int from, int to)
|
||||
if(ui_->checkBox_icp_2d->isChecked())
|
||||
{
|
||||
//2D
|
||||
cv::Mat oldDepth2D = util3d::uncompressData(dataFrom.getDepth2D());
|
||||
cv::Mat newDepth2D = util3d::uncompressData(dataTo.getDepth2D());
|
||||
cv::Mat oldDepth2D = util3d::uncompressData(dataFrom.getDepth2DCompressed());
|
||||
cv::Mat newDepth2D = util3d::uncompressData(dataTo.getDepth2DCompressed());
|
||||
|
||||
if(!oldDepth2D.empty() && !newDepth2D.empty())
|
||||
{
|
||||
@@ -1711,8 +1704,8 @@ void DatabaseViewer::refineConstraint(int from, int to)
|
||||
else
|
||||
{
|
||||
//3D
|
||||
cv::Mat depthA = rtabmap::util3d::uncompressImage(dataFrom.getDepth());
|
||||
cv::Mat depthB = rtabmap::util3d::uncompressImage(dataTo.getDepth());
|
||||
cv::Mat depthA = rtabmap::util3d::uncompressImage(dataFrom.getDepthCompressed());
|
||||
cv::Mat depthB = rtabmap::util3d::uncompressImage(dataTo.getDepthCompressed());
|
||||
|
||||
if(depthA.type() == CV_8UC1 || depthB.type() == CV_8UC1)
|
||||
{
|
||||
|
||||
@@ -928,7 +928,7 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
|
||||
// update clouds
|
||||
if(stat.poses().size())
|
||||
{
|
||||
// update pose only if a odometry is not received
|
||||
// update pose only if odometry is not received
|
||||
updateMapCloud(stat.poses(),
|
||||
_odometryReceived||stat.poses().size()==0?Transform():stat.poses().rbegin()->second,
|
||||
stat.constraints());
|
||||
@@ -986,11 +986,12 @@ void MainWindow::updateMapCloud(
|
||||
if(posesIn.size())
|
||||
{
|
||||
_currentPosesMap = posesIn;
|
||||
_currentLinksMap = constraints;
|
||||
if(_currentPosesMap.size())
|
||||
{
|
||||
if(!_ui->actionSave_point_cloud->isEnabled() &&
|
||||
_cachedSignatures.size() &&
|
||||
(--_cachedSignatures.end())->getDepth().size())
|
||||
!(--_cachedSignatures.end())->getDepthCompressed().empty())
|
||||
{
|
||||
//enable save cloud action
|
||||
_ui->actionSave_point_cloud->setEnabled(true);
|
||||
@@ -999,7 +1000,7 @@ void MainWindow::updateMapCloud(
|
||||
|
||||
if(!_ui->actionView_scans->isEnabled() &&
|
||||
_cachedSignatures.size() &&
|
||||
(--_cachedSignatures.end())->getDepth2D().size())
|
||||
!(--_cachedSignatures.end())->getDepth2DCompressed().empty())
|
||||
{
|
||||
_ui->actionExport_2D_scans_ply_pcd->setEnabled(true);
|
||||
_ui->actionExport_2D_Grid_map_bmp_png->setEnabled(true);
|
||||
@@ -1065,7 +1066,7 @@ void MainWindow::updateMapCloud(
|
||||
else if(_cachedSignatures.contains(iter->first))
|
||||
{
|
||||
QMap<int, Signature>::iterator jter = _cachedSignatures.find(iter->first);
|
||||
if(jter->getImage().size() && jter->getDepth().size())
|
||||
if(!jter->getImageCompressed().empty() && !jter->getDepthCompressed().empty())
|
||||
{
|
||||
this->createAndAddCloudToMap(iter->first, iter->second);
|
||||
}
|
||||
@@ -1100,7 +1101,7 @@ void MainWindow::updateMapCloud(
|
||||
else if(_cachedSignatures.contains(iter->first))
|
||||
{
|
||||
QMap<int, Signature>::iterator jter = _cachedSignatures.find(iter->first);
|
||||
if(jter->getDepth2D().size())
|
||||
if(!jter->getDepth2DCompressed().empty())
|
||||
{
|
||||
this->createAndAddScanToMap(iter->first, iter->second);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ void PdfPlotItem::showDescription(bool shown)
|
||||
{
|
||||
QImage img;
|
||||
QMap<int, Signature>::const_iterator iter = _signaturesRef->find(int(this->data().x()));
|
||||
if(iter != _signaturesRef->constEnd() && !iter.value().getImage().empty())
|
||||
if(iter != _signaturesRef->constEnd() && !iter.value().getImageCompressed().empty())
|
||||
{
|
||||
cv::Mat image;
|
||||
iter.value().uncompressData(&image, 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user