DBReader: added fine-grained camera selection (#1457)

This commit is contained in:
matlabbe
2025-02-26 16:06:13 -08:00
committed by GitHub
parent 35c3ca20ad
commit 258095e0f3
5 changed files with 171 additions and 51 deletions

View File

@@ -742,7 +742,7 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
connect(_ui->source_spinBox_databaseStartId, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->source_spinBox_databaseStopId, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->source_checkBox_useDbStamps, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->source_spinBox_database_cameraIndex, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->source_lineEdit_databaseCameraIndex, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->source_checkBox_stereoToDepthDB, SIGNAL(toggled(bool)), _ui->checkbox_stereo_depthGenerated, SLOT(setChecked(bool)));
connect(_ui->checkbox_stereo_depthGenerated, SIGNAL(toggled(bool)), _ui->source_checkBox_stereoToDepthDB, SLOT(setChecked(bool)));
@@ -2136,7 +2136,7 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
_ui->source_checkBox_ignorePriors->setChecked(false);
_ui->source_spinBox_databaseStartId->setValue(0);
_ui->source_spinBox_databaseStopId->setValue(0);
_ui->source_spinBox_database_cameraIndex->setValue(-1);
_ui->source_lineEdit_databaseCameraIndex->setText("");
_ui->source_checkBox_useDbStamps->setChecked(true);
#ifdef _WIN32
@@ -2867,7 +2867,7 @@ void PreferencesDialog::readCameraSettings(const QString & filePath)
_ui->source_checkBox_ignorePriors->setChecked(settings.value("ignorePriors", _ui->source_checkBox_ignorePriors->isChecked()).toBool());
_ui->source_spinBox_databaseStartId->setValue(settings.value("startId", _ui->source_spinBox_databaseStartId->value()).toInt());
_ui->source_spinBox_databaseStopId->setValue(settings.value("stopId", _ui->source_spinBox_databaseStopId->value()).toInt());
_ui->source_spinBox_database_cameraIndex->setValue(settings.value("cameraIndex", _ui->source_spinBox_database_cameraIndex->value()).toInt());
_ui->source_lineEdit_databaseCameraIndex->setText(settings.value("cameraIndices", _ui->source_lineEdit_databaseCameraIndex->text()).toString());
_ui->source_checkBox_useDbStamps->setChecked(settings.value("useDatabaseStamps", _ui->source_checkBox_useDbStamps->isChecked()).toBool());
settings.endGroup(); // Database
@@ -3467,7 +3467,7 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath) const
settings.setValue("ignorePriors", _ui->source_checkBox_ignorePriors->isChecked());
settings.setValue("startId", _ui->source_spinBox_databaseStartId->value());
settings.setValue("stopId", _ui->source_spinBox_databaseStopId->value());
settings.setValue("cameraIndex", _ui->source_spinBox_database_cameraIndex->value());
settings.setValue("cameraIndices", _ui->source_lineEdit_databaseCameraIndex->text());
settings.setValue("useDatabaseStamps", _ui->source_checkBox_useDbStamps->isChecked());
settings.endGroup(); // Database
@@ -4389,7 +4389,7 @@ void PreferencesDialog::selectSourceDatabase()
_ui->source_database_lineEdit_path->setText(paths.size()==1?paths.front():paths.join(";"));
_ui->source_spinBox_databaseStartId->setValue(0);
_ui->source_spinBox_databaseStopId->setValue(0);
_ui->source_spinBox_database_cameraIndex->setValue(-1);
_ui->source_lineEdit_databaseCameraIndex->setText("");
}
}
@@ -6953,13 +6953,50 @@ Camera * PreferencesDialog::createCamera(
}
else if(driver == kSrcDatabase)
{
std::vector<unsigned int> cameraIndices;
if(!_ui->source_lineEdit_databaseCameraIndex->text().isEmpty())
{
// read the first node to know how many cameras we have in the database
std::shared_ptr<DBReader> reader(
new DBReader(
_ui->source_database_lineEdit_path->text().toStdString(),
0,
false,
false,
false,
_ui->source_spinBox_databaseStartId->value()));
if(reader->init())
{
SensorData data = reader->takeImage();
unsigned int numCamerasInDb = data.cameraModels().size()>0?data.cameraModels().size():data.stereoCameraModels().size();
if(numCamerasInDb>1)
{
QStringList indicesStr = _ui->source_lineEdit_databaseCameraIndex->text().split(' ');
for(QStringList::iterator iter=indicesStr.begin(); iter!=indicesStr.end(); ++iter)
{
cameraIndices.push_back(iter->toInt());
if(cameraIndices.back() > numCamerasInDb)
{
QMessageBox::warning(this,
tr("Creating Database Reader"),
tr("Camera index %1 is not valid, it should be between 0 and %2. Remove or update camera indices under Source->Database panel (currently set to \"%3\").")
.arg(cameraIndices.back()).arg(numCamerasInDb).arg(_ui->source_lineEdit_databaseCameraIndex->text()),
QMessageBox::Ok);
cameraIndices.clear();
return 0;
}
}
}
}
}
camera = new DBReader(_ui->source_database_lineEdit_path->text().toStdString(),
_ui->source_checkBox_useDbStamps->isChecked()?-1:this->getGeneralInputRate(),
_ui->source_checkBox_ignoreOdometry->isChecked(),
_ui->source_checkBox_ignoreGoalDelay->isChecked(),
_ui->source_checkBox_ignoreGoals->isChecked(),
_ui->source_spinBox_databaseStartId->value(),
_ui->source_spinBox_database_cameraIndex->value(),
cameraIndices,
_ui->source_spinBox_databaseStopId->value(),
!_ui->general_checkBox_createIntermediateNodes->isChecked(),
_ui->source_checkBox_ignoreLandmarks->isChecked(),

View File

@@ -63,7 +63,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-520</y>
<y>-594</y>
<width>713</width>
<height>4653</height>
</rect>
@@ -95,7 +95,7 @@
<enum>QFrame::Raised</enum>
</property>
<property name="currentIndex">
<number>15</number>
<number>5</number>
</property>
<widget class="QWidget" name="page_22">
<layout class="QVBoxLayout" name="verticalLayout_29" stretch="0,0">
@@ -3424,7 +3424,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
<item>
<widget class="QStackedWidget" name="stackedWidget_src">
<property name="currentIndex">
<number>2</number>
<number>3</number>
</property>
<widget class="QWidget" name="page_41">
<layout class="QVBoxLayout" name="verticalLayout_64">
@@ -6777,7 +6777,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_9" columnstretch="0,0,0">
<layout class="QGridLayout" name="gridLayout_9" columnstretch="0,1,0">
<item row="8" column="0">
<widget class="QSpinBox" name="source_spinBox_databaseStartId">
<property name="minimum">
@@ -6930,7 +6930,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
<item row="10" column="1">
<widget class="QLabel" name="label_315">
<property name="text">
<string>Camera index. If the database contains multi-camera data, you can choose which camera to use. -1 means that all cameras are streamed.</string>
<string>Camera index. If the database contains multi-camera data, you can choose which camera to use. Leave empty to use all cameras. Can also be multiple indices split by spaces in a string like &quot;0 2&quot; to stream cameras 0 and 2 only.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@@ -6981,16 +6981,6 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QSpinBox" name="source_spinBox_database_cameraIndex">
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="label_58">
<property name="text">
@@ -7041,6 +7031,9 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLineEdit" name="source_lineEdit_databaseCameraIndex"/>
</item>
</layout>
</widget>
</item>