mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 09:30:25 +08:00
Export Images: fixed images still saved when cancelling the dialog
This commit is contained in:
@@ -1003,7 +1003,7 @@ void DatabaseViewer::extractImages()
|
||||
}
|
||||
|
||||
QString path = QFileDialog::getExistingDirectory(this, tr("Select directory where to save images..."), QDir::homePath());
|
||||
if(!path.isNull())
|
||||
if(!path.isEmpty())
|
||||
{
|
||||
if(ids_.size())
|
||||
{
|
||||
|
||||
@@ -5733,7 +5733,7 @@ void MainWindow::exportImages()
|
||||
}
|
||||
|
||||
QString path = QFileDialog::getExistingDirectory(this, tr("Select directory where to save images..."), this->getWorkingDirectory());
|
||||
if(!path.isNull())
|
||||
if(!path.isEmpty())
|
||||
{
|
||||
SensorData data;
|
||||
if(_cachedSignatures.contains(poses.rbegin()->first))
|
||||
@@ -5815,63 +5815,63 @@ void MainWindow::exportImages()
|
||||
tr("Export images..."),
|
||||
tr("Data in the cache don't seem to have images (tested node %1). Calibration file will not be saved. Try refreshing the cache (with clouds).").arg(poses.rbegin()->first));
|
||||
}
|
||||
}
|
||||
|
||||
_initProgressDialog->resetProgress();
|
||||
_initProgressDialog->show();
|
||||
_initProgressDialog->setMaximumSteps(_cachedSignatures.size());
|
||||
_initProgressDialog->resetProgress();
|
||||
_initProgressDialog->show();
|
||||
_initProgressDialog->setMaximumSteps(_cachedSignatures.size());
|
||||
|
||||
unsigned int saved = 0;
|
||||
for(std::map<int, Transform>::iterator iter=poses.begin(); iter!=poses.end(); ++iter)
|
||||
{
|
||||
int id = iter->first;
|
||||
SensorData data;
|
||||
if(_cachedSignatures.contains(iter->first))
|
||||
unsigned int saved = 0;
|
||||
for(std::map<int, Transform>::iterator iter=poses.begin(); iter!=poses.end(); ++iter)
|
||||
{
|
||||
data = _cachedSignatures.value(iter->first).sensorData();
|
||||
data.uncompressData();
|
||||
int id = iter->first;
|
||||
SensorData data;
|
||||
if(_cachedSignatures.contains(iter->first))
|
||||
{
|
||||
data = _cachedSignatures.value(iter->first).sensorData();
|
||||
data.uncompressData();
|
||||
}
|
||||
QString info;
|
||||
bool warn = false;
|
||||
if(!data.imageRaw().empty() && !data.rightRaw().empty())
|
||||
{
|
||||
cv::imwrite(QString("%1/left/%2.%3").arg(path).arg(id).arg(ext).toStdString(), data.imageRaw());
|
||||
cv::imwrite(QString("%1/right/%2.%3").arg(path).arg(id).arg(ext).toStdString(), data.rightRaw());
|
||||
info = tr("Saved left/%1.%2 and right/%1.%2.").arg(id).arg(ext);
|
||||
}
|
||||
else if(!data.imageRaw().empty() && !data.depthRaw().empty())
|
||||
{
|
||||
cv::imwrite(QString("%1/rgb/%2.%3").arg(path).arg(id).arg(ext).toStdString(), data.imageRaw());
|
||||
cv::imwrite(QString("%1/depth/%2.png").arg(path).arg(id).toStdString(), data.depthRaw());
|
||||
info = tr("Saved rgb/%1.%2 and depth/%1.png.").arg(id).arg(ext);
|
||||
}
|
||||
else if(!data.imageRaw().empty())
|
||||
{
|
||||
cv::imwrite(QString("%1/%2.%3").arg(path).arg(id).arg(ext).toStdString(), data.imageRaw());
|
||||
info = tr("Saved %1.%2.").arg(id).arg(ext);
|
||||
}
|
||||
else
|
||||
{
|
||||
info = tr("No images saved for node %1!").arg(id);
|
||||
warn = true;
|
||||
}
|
||||
saved += warn?0:1;
|
||||
_initProgressDialog->appendText(info, !warn?Qt::black:Qt::darkYellow);
|
||||
_initProgressDialog->incrementStep();
|
||||
QApplication::processEvents();
|
||||
|
||||
}
|
||||
QString info;
|
||||
bool warn = false;
|
||||
if(!data.imageRaw().empty() && !data.rightRaw().empty())
|
||||
if(saved!=poses.size())
|
||||
{
|
||||
cv::imwrite(QString("%1/left/%2.%3").arg(path).arg(id).arg(ext).toStdString(), data.imageRaw());
|
||||
cv::imwrite(QString("%1/right/%2.%3").arg(path).arg(id).arg(ext).toStdString(), data.rightRaw());
|
||||
info = tr("Saved left/%1.%2 and right/%1.%2.").arg(id).arg(ext);
|
||||
}
|
||||
else if(!data.imageRaw().empty() && !data.depthRaw().empty())
|
||||
{
|
||||
cv::imwrite(QString("%1/rgb/%2.%3").arg(path).arg(id).arg(ext).toStdString(), data.imageRaw());
|
||||
cv::imwrite(QString("%1/depth/%2.png").arg(path).arg(id).toStdString(), data.depthRaw());
|
||||
info = tr("Saved rgb/%1.%2 and depth/%1.png.").arg(id).arg(ext);
|
||||
}
|
||||
else if(!data.imageRaw().empty())
|
||||
{
|
||||
cv::imwrite(QString("%1/%2.%3").arg(path).arg(id).arg(ext).toStdString(), data.imageRaw());
|
||||
info = tr("Saved %1.%2.").arg(id).arg(ext);
|
||||
_initProgressDialog->setAutoClose(false);
|
||||
_initProgressDialog->appendText(tr("%1 images of %2 saved to \"%3\".").arg(saved).arg(poses.size()).arg(path));
|
||||
}
|
||||
else
|
||||
{
|
||||
info = tr("No images saved for node %1!").arg(id);
|
||||
warn = true;
|
||||
_initProgressDialog->appendText(tr("%1 images saved to \"%2\".").arg(saved).arg(path));
|
||||
}
|
||||
saved += warn?0:1;
|
||||
_initProgressDialog->appendText(info, !warn?Qt::black:Qt::darkYellow);
|
||||
_initProgressDialog->incrementStep();
|
||||
QApplication::processEvents();
|
||||
|
||||
_initProgressDialog->setValue(_initProgressDialog->maximumSteps());
|
||||
}
|
||||
if(saved!=poses.size())
|
||||
{
|
||||
_initProgressDialog->setAutoClose(false);
|
||||
_initProgressDialog->appendText(tr("%1 images of %2 saved to \"%3\".").arg(saved).arg(poses.size()).arg(path));
|
||||
}
|
||||
else
|
||||
{
|
||||
_initProgressDialog->appendText(tr("%1 images saved to \"%2\".").arg(saved).arg(path));
|
||||
}
|
||||
|
||||
_initProgressDialog->setValue(_initProgressDialog->maximumSteps());
|
||||
}
|
||||
|
||||
void MainWindow::exportBundlerFormat()
|
||||
|
||||
@@ -2503,7 +2503,7 @@ void PreferencesDialog::readSettingsEnd()
|
||||
|
||||
void PreferencesDialog::saveWindowGeometry(const QWidget * window)
|
||||
{
|
||||
if(!window->objectName().isNull() && !window->isMaximized())
|
||||
if(!window->objectName().isEmpty() && !window->isMaximized())
|
||||
{
|
||||
QSettings settings(getIniFilePath(), QSettings::IniFormat);
|
||||
settings.beginGroup("Gui");
|
||||
@@ -2516,7 +2516,7 @@ void PreferencesDialog::saveWindowGeometry(const QWidget * window)
|
||||
|
||||
void PreferencesDialog::loadWindowGeometry(QWidget * window)
|
||||
{
|
||||
if(!window->objectName().isNull())
|
||||
if(!window->objectName().isEmpty())
|
||||
{
|
||||
QByteArray bytes;
|
||||
QSettings settings(getIniFilePath(), QSettings::IniFormat);
|
||||
@@ -2534,7 +2534,7 @@ void PreferencesDialog::loadWindowGeometry(QWidget * window)
|
||||
|
||||
void PreferencesDialog::saveMainWindowState(const QMainWindow * mainWindow)
|
||||
{
|
||||
if(!mainWindow->objectName().isNull())
|
||||
if(!mainWindow->objectName().isEmpty())
|
||||
{
|
||||
saveWindowGeometry(mainWindow);
|
||||
|
||||
@@ -2551,7 +2551,7 @@ void PreferencesDialog::saveMainWindowState(const QMainWindow * mainWindow)
|
||||
|
||||
void PreferencesDialog::loadMainWindowState(QMainWindow * mainWindow, bool & maximized, bool & statusBarShown)
|
||||
{
|
||||
if(!mainWindow->objectName().isNull())
|
||||
if(!mainWindow->objectName().isEmpty())
|
||||
{
|
||||
loadWindowGeometry(mainWindow);
|
||||
|
||||
@@ -2574,7 +2574,7 @@ void PreferencesDialog::loadMainWindowState(QMainWindow * mainWindow, bool & ma
|
||||
|
||||
void PreferencesDialog::saveWidgetState(const QWidget * widget)
|
||||
{
|
||||
if(!widget->objectName().isNull())
|
||||
if(!widget->objectName().isEmpty())
|
||||
{
|
||||
QSettings settings(getIniFilePath(), QSettings::IniFormat);
|
||||
settings.beginGroup("Gui");
|
||||
@@ -2633,7 +2633,7 @@ void PreferencesDialog::saveWidgetState(const QWidget * widget)
|
||||
|
||||
void PreferencesDialog::loadWidgetState(QWidget * widget)
|
||||
{
|
||||
if(!widget->objectName().isNull())
|
||||
if(!widget->objectName().isEmpty())
|
||||
{
|
||||
QByteArray bytes;
|
||||
QSettings settings(getIniFilePath(), QSettings::IniFormat);
|
||||
|
||||
Reference in New Issue
Block a user