mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-09 19:19:49 +08:00
DBReader: added camera selection
This commit is contained in:
@@ -51,12 +51,14 @@ public:
|
|||||||
float frameRate = 0.0f,
|
float frameRate = 0.0f,
|
||||||
bool odometryIgnored = false,
|
bool odometryIgnored = false,
|
||||||
bool ignoreGoalDelay = false,
|
bool ignoreGoalDelay = false,
|
||||||
bool goalsIgnored = false);
|
bool goalsIgnored = false,
|
||||||
|
int cameraIndex = -1);
|
||||||
DBReader(const std::list<std::string> & databasePaths,
|
DBReader(const std::list<std::string> & databasePaths,
|
||||||
float frameRate = 0.0f,
|
float frameRate = 0.0f,
|
||||||
bool odometryIgnored = false,
|
bool odometryIgnored = false,
|
||||||
bool ignoreGoalDelay = false,
|
bool ignoreGoalDelay = false,
|
||||||
bool goalsIgnored = false);
|
bool goalsIgnored = false,
|
||||||
|
int cameraIndex = -1);
|
||||||
virtual ~DBReader();
|
virtual ~DBReader();
|
||||||
|
|
||||||
bool init(int startIndex=0);
|
bool init(int startIndex=0);
|
||||||
@@ -73,6 +75,7 @@ private:
|
|||||||
bool _odometryIgnored;
|
bool _odometryIgnored;
|
||||||
bool _ignoreGoalDelay;
|
bool _ignoreGoalDelay;
|
||||||
bool _goalsIgnored;
|
bool _goalsIgnored;
|
||||||
|
int _cameraIndex;
|
||||||
|
|
||||||
DBDriver * _dbDriver;
|
DBDriver * _dbDriver;
|
||||||
UTimer _timer;
|
UTimer _timer;
|
||||||
|
|||||||
@@ -46,12 +46,14 @@ DBReader::DBReader(const std::string & databasePath,
|
|||||||
float frameRate,
|
float frameRate,
|
||||||
bool odometryIgnored,
|
bool odometryIgnored,
|
||||||
bool ignoreGoalDelay,
|
bool ignoreGoalDelay,
|
||||||
bool goalsIgnored) :
|
bool goalsIgnored,
|
||||||
|
int cameraIndex) :
|
||||||
_paths(uSplit(databasePath, ';')),
|
_paths(uSplit(databasePath, ';')),
|
||||||
_frameRate(frameRate),
|
_frameRate(frameRate),
|
||||||
_odometryIgnored(odometryIgnored),
|
_odometryIgnored(odometryIgnored),
|
||||||
_ignoreGoalDelay(ignoreGoalDelay),
|
_ignoreGoalDelay(ignoreGoalDelay),
|
||||||
_goalsIgnored(goalsIgnored),
|
_goalsIgnored(goalsIgnored),
|
||||||
|
_cameraIndex(cameraIndex),
|
||||||
_dbDriver(0),
|
_dbDriver(0),
|
||||||
_currentId(_ids.end()),
|
_currentId(_ids.end()),
|
||||||
_previousStamp(0),
|
_previousStamp(0),
|
||||||
@@ -63,12 +65,14 @@ DBReader::DBReader(const std::list<std::string> & databasePaths,
|
|||||||
float frameRate,
|
float frameRate,
|
||||||
bool odometryIgnored,
|
bool odometryIgnored,
|
||||||
bool ignoreGoalDelay,
|
bool ignoreGoalDelay,
|
||||||
bool goalsIgnored) :
|
bool goalsIgnored,
|
||||||
|
int cameraIndex) :
|
||||||
_paths(databasePaths),
|
_paths(databasePaths),
|
||||||
_frameRate(frameRate),
|
_frameRate(frameRate),
|
||||||
_odometryIgnored(odometryIgnored),
|
_odometryIgnored(odometryIgnored),
|
||||||
_ignoreGoalDelay(ignoreGoalDelay),
|
_ignoreGoalDelay(ignoreGoalDelay),
|
||||||
_goalsIgnored(goalsIgnored),
|
_goalsIgnored(goalsIgnored),
|
||||||
|
_cameraIndex(cameraIndex),
|
||||||
_dbDriver(0),
|
_dbDriver(0),
|
||||||
_currentId(_ids.end()),
|
_currentId(_ids.end()),
|
||||||
_previousStamp(0),
|
_previousStamp(0),
|
||||||
@@ -368,6 +372,37 @@ OdometryEvent DBReader::getNextData()
|
|||||||
if(!this->isKilled())
|
if(!this->isKilled())
|
||||||
{
|
{
|
||||||
data.uncompressData();
|
data.uncompressData();
|
||||||
|
if(data.cameraModels().size() > 1 &&
|
||||||
|
_cameraIndex >= 0)
|
||||||
|
{
|
||||||
|
if(_cameraIndex < (int)data.cameraModels().size())
|
||||||
|
{
|
||||||
|
// select one camera
|
||||||
|
int subImageWidth = data.imageRaw().cols/data.cameraModels().size();
|
||||||
|
UASSERT(!data.imageRaw().empty() &&
|
||||||
|
data.imageRaw().cols % data.cameraModels().size() == 0 &&
|
||||||
|
_cameraIndex*subImageWidth < data.imageRaw().cols);
|
||||||
|
data.setImageRaw(
|
||||||
|
cv::Mat(data.imageRaw(),
|
||||||
|
cv::Rect(_cameraIndex*subImageWidth, 0, subImageWidth, data.imageRaw().rows)).clone());
|
||||||
|
|
||||||
|
if(!data.depthOrRightRaw().empty())
|
||||||
|
{
|
||||||
|
UASSERT(data.depthOrRightRaw().cols % data.cameraModels().size() == 0 &&
|
||||||
|
subImageWidth == data.depthOrRightRaw().cols/(int)data.cameraModels().size() &&
|
||||||
|
_cameraIndex*subImageWidth < data.depthOrRightRaw().cols);
|
||||||
|
data.setDepthOrRightRaw(
|
||||||
|
cv::Mat(data.depthOrRightRaw(),
|
||||||
|
cv::Rect(_cameraIndex*subImageWidth, 0, subImageWidth, data.depthOrRightRaw().rows)).clone());
|
||||||
|
}
|
||||||
|
CameraModel model = data.cameraModels().at(_cameraIndex);
|
||||||
|
data.setCameraModel(model);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UWARN("DBReader: Camera index %d doesn't exist! Camera models = %d.", _cameraIndex, (int)data.cameraModels().size());
|
||||||
|
}
|
||||||
|
}
|
||||||
data.setId(seq);
|
data.setId(seq);
|
||||||
data.setStamp(stamp);
|
data.setStamp(stamp);
|
||||||
data.setGroundTruth(groundTruth);
|
data.setGroundTruth(groundTruth);
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ public:
|
|||||||
bool getSourceDatabaseGoalsIgnored() const; //Database group
|
bool getSourceDatabaseGoalsIgnored() const; //Database group
|
||||||
int getSourceDatabaseStartPos() const; //Database group
|
int getSourceDatabaseStartPos() const; //Database group
|
||||||
bool getSourceDatabaseStampsUsed() const;//Database group
|
bool getSourceDatabaseStampsUsed() const;//Database group
|
||||||
|
int getSourceDatabaseCameraIndex() const; //Database group
|
||||||
bool isSourceRGBDColorOnly() const;
|
bool isSourceRGBDColorOnly() const;
|
||||||
int getSourceImageDecimation() const;
|
int getSourceImageDecimation() const;
|
||||||
bool isSourceStereoDepthGenerated() const;
|
bool isSourceStereoDepthGenerated() const;
|
||||||
|
|||||||
@@ -3886,7 +3886,8 @@ void MainWindow::startDetection()
|
|||||||
_preferencesDialog->getSourceDatabaseStampsUsed()?-1:_preferencesDialog->getGeneralInputRate(),
|
_preferencesDialog->getSourceDatabaseStampsUsed()?-1:_preferencesDialog->getGeneralInputRate(),
|
||||||
_preferencesDialog->getSourceDatabaseOdometryIgnored(),
|
_preferencesDialog->getSourceDatabaseOdometryIgnored(),
|
||||||
_preferencesDialog->getSourceDatabaseGoalDelayIgnored(),
|
_preferencesDialog->getSourceDatabaseGoalDelayIgnored(),
|
||||||
_preferencesDialog->getSourceDatabaseGoalsIgnored());
|
_preferencesDialog->getSourceDatabaseGoalsIgnored(),
|
||||||
|
_preferencesDialog->getSourceDatabaseCameraIndex());
|
||||||
|
|
||||||
//Create odometry thread if rgdb slam
|
//Create odometry thread if rgdb slam
|
||||||
if(uStr2Bool(parameters.at(Parameters::kRGBDEnabled()).c_str()) &&
|
if(uStr2Bool(parameters.at(Parameters::kRGBDEnabled()).c_str()) &&
|
||||||
|
|||||||
@@ -427,6 +427,7 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
|
|||||||
connect(_ui->source_checkBox_ignoreGoals, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
|
connect(_ui->source_checkBox_ignoreGoals, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
|
||||||
connect(_ui->source_spinBox_databaseStartPos, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
|
connect(_ui->source_spinBox_databaseStartPos, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
|
||||||
connect(_ui->source_checkBox_useDbStamps, SIGNAL(stateChanged(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()));
|
||||||
|
|
||||||
//openni group
|
//openni group
|
||||||
_ui->stackedWidget_rgbd->setCurrentIndex(_ui->comboBox_cameraRGBD->currentIndex());
|
_ui->stackedWidget_rgbd->setCurrentIndex(_ui->comboBox_cameraRGBD->currentIndex());
|
||||||
@@ -1248,6 +1249,7 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
|
|||||||
_ui->source_checkBox_ignoreGoalDelay->setChecked(true);
|
_ui->source_checkBox_ignoreGoalDelay->setChecked(true);
|
||||||
_ui->source_checkBox_ignoreGoals->setChecked(true);
|
_ui->source_checkBox_ignoreGoals->setChecked(true);
|
||||||
_ui->source_spinBox_databaseStartPos->setValue(0);
|
_ui->source_spinBox_databaseStartPos->setValue(0);
|
||||||
|
_ui->source_spinBox_database_cameraIndex->setValue(-1);
|
||||||
_ui->source_checkBox_useDbStamps->setChecked(true);
|
_ui->source_checkBox_useDbStamps->setChecked(true);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -1702,6 +1704,7 @@ void PreferencesDialog::readCameraSettings(const QString & filePath)
|
|||||||
_ui->source_checkBox_ignoreGoalDelay->setChecked(settings.value("ignoreGoalDelay", _ui->source_checkBox_ignoreGoalDelay->isChecked()).toBool());
|
_ui->source_checkBox_ignoreGoalDelay->setChecked(settings.value("ignoreGoalDelay", _ui->source_checkBox_ignoreGoalDelay->isChecked()).toBool());
|
||||||
_ui->source_checkBox_ignoreGoals->setChecked(settings.value("ignoreGoals", _ui->source_checkBox_ignoreGoals->isChecked()).toBool());
|
_ui->source_checkBox_ignoreGoals->setChecked(settings.value("ignoreGoals", _ui->source_checkBox_ignoreGoals->isChecked()).toBool());
|
||||||
_ui->source_spinBox_databaseStartPos->setValue(settings.value("startPos", _ui->source_spinBox_databaseStartPos->value()).toInt());
|
_ui->source_spinBox_databaseStartPos->setValue(settings.value("startPos", _ui->source_spinBox_databaseStartPos->value()).toInt());
|
||||||
|
_ui->source_spinBox_database_cameraIndex->setValue(settings.value("cameraIndex", _ui->source_spinBox_database_cameraIndex->value()).toInt());
|
||||||
_ui->source_checkBox_useDbStamps->setChecked(settings.value("useDatabaseStamps", _ui->source_checkBox_useDbStamps->isChecked()).toBool());
|
_ui->source_checkBox_useDbStamps->setChecked(settings.value("useDatabaseStamps", _ui->source_checkBox_useDbStamps->isChecked()).toBool());
|
||||||
settings.endGroup(); // Database
|
settings.endGroup(); // Database
|
||||||
|
|
||||||
@@ -2109,6 +2112,7 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath) const
|
|||||||
settings.setValue("ignoreGoalDelay", _ui->source_checkBox_ignoreGoalDelay->isChecked());
|
settings.setValue("ignoreGoalDelay", _ui->source_checkBox_ignoreGoalDelay->isChecked());
|
||||||
settings.setValue("ignoreGoals", _ui->source_checkBox_ignoreGoals->isChecked());
|
settings.setValue("ignoreGoals", _ui->source_checkBox_ignoreGoals->isChecked());
|
||||||
settings.setValue("startPos", _ui->source_spinBox_databaseStartPos->value());
|
settings.setValue("startPos", _ui->source_spinBox_databaseStartPos->value());
|
||||||
|
settings.setValue("cameraIndex", _ui->source_spinBox_database_cameraIndex->value());
|
||||||
settings.setValue("useDatabaseStamps", _ui->source_checkBox_useDbStamps->isChecked());
|
settings.setValue("useDatabaseStamps", _ui->source_checkBox_useDbStamps->isChecked());
|
||||||
settings.endGroup(); // Database
|
settings.endGroup(); // Database
|
||||||
|
|
||||||
@@ -2680,6 +2684,7 @@ void PreferencesDialog::selectSourceDatabase()
|
|||||||
_ui->source_checkBox_ignoreOdometry->setChecked(r != QMessageBox::Yes);
|
_ui->source_checkBox_ignoreOdometry->setChecked(r != QMessageBox::Yes);
|
||||||
_ui->source_database_lineEdit_path->setText(paths.size()==1?paths.front():paths.join(";"));
|
_ui->source_database_lineEdit_path->setText(paths.size()==1?paths.front():paths.join(";"));
|
||||||
_ui->source_spinBox_databaseStartPos->setValue(0);
|
_ui->source_spinBox_databaseStartPos->setValue(0);
|
||||||
|
_ui->source_spinBox_database_cameraIndex->setValue(-1);
|
||||||
_ui->source_checkBox_useDbStamps->setChecked(true);
|
_ui->source_checkBox_useDbStamps->setChecked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3906,6 +3911,10 @@ int PreferencesDialog::getSourceDatabaseStartPos() const
|
|||||||
{
|
{
|
||||||
return _ui->source_spinBox_databaseStartPos->value();
|
return _ui->source_spinBox_databaseStartPos->value();
|
||||||
}
|
}
|
||||||
|
int PreferencesDialog::getSourceDatabaseCameraIndex() const
|
||||||
|
{
|
||||||
|
return _ui->source_spinBox_database_cameraIndex->value();
|
||||||
|
}
|
||||||
bool PreferencesDialog::getSourceDatabaseStampsUsed() const
|
bool PreferencesDialog::getSourceDatabaseStampsUsed() const
|
||||||
{
|
{
|
||||||
return _ui->source_checkBox_useDbStamps->isChecked();
|
return _ui->source_checkBox_useDbStamps->isChecked();
|
||||||
@@ -4370,7 +4379,9 @@ void PreferencesDialog::testOdometry()
|
|||||||
DBReader dbReader(_ui->source_database_lineEdit_path->text().toStdString(),
|
DBReader dbReader(_ui->source_database_lineEdit_path->text().toStdString(),
|
||||||
_ui->source_checkBox_useDbStamps->isChecked()?-1:this->getGeneralInputRate(),
|
_ui->source_checkBox_useDbStamps->isChecked()?-1:this->getGeneralInputRate(),
|
||||||
true,
|
true,
|
||||||
true);
|
true,
|
||||||
|
true,
|
||||||
|
_ui->source_spinBox_database_cameraIndex->value());
|
||||||
Camera * camera = 0;
|
Camera * camera = 0;
|
||||||
if(this->getSourceType() == kSrcDatabase)
|
if(this->getSourceType() == kSrcDatabase)
|
||||||
{
|
{
|
||||||
@@ -4464,8 +4475,10 @@ void PreferencesDialog::testCamera()
|
|||||||
DBReader dbReader(_ui->source_database_lineEdit_path->text().toStdString(),
|
DBReader dbReader(_ui->source_database_lineEdit_path->text().toStdString(),
|
||||||
_ui->source_checkBox_useDbStamps->isChecked()?-1:this->getGeneralInputRate(),
|
_ui->source_checkBox_useDbStamps->isChecked()?-1:this->getGeneralInputRate(),
|
||||||
true,
|
true,
|
||||||
true);
|
true,
|
||||||
if(!dbReader.init())
|
true,
|
||||||
|
_ui->source_spinBox_database_cameraIndex->value());
|
||||||
|
if(!dbReader.init(_ui->source_images_spinBox_startPos->value()))
|
||||||
{
|
{
|
||||||
QMessageBox::warning(this, tr("Camera viewer"), tr("Failed to initialize the database reader!"));
|
QMessageBox::warning(this, tr("Camera viewer"), tr("Failed to initialize the database reader!"));
|
||||||
delete window;
|
delete window;
|
||||||
|
|||||||
@@ -63,9 +63,9 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>-360</y>
|
||||||
<width>681</width>
|
<width>686</width>
|
||||||
<height>2044</height>
|
<height>2023</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_16">
|
<layout class="QVBoxLayout" name="verticalLayout_16">
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>14</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="page_22">
|
<widget class="QWidget" name="page_22">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_29" stretch="0,1">
|
<layout class="QVBoxLayout" name="verticalLayout_29" stretch="0,1">
|
||||||
@@ -2307,7 +2307,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QStackedWidget" name="stackedWidget_src">
|
<widget class="QStackedWidget" name="stackedWidget_src">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="page_41">
|
<widget class="QWidget" name="page_41">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_64">
|
<layout class="QVBoxLayout" name="verticalLayout_64">
|
||||||
@@ -3813,7 +3813,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="1">
|
<item row="7" column="1">
|
||||||
<spacer name="verticalSpacer_35">
|
<spacer name="verticalSpacer_35">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@@ -3859,7 +3859,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>999999999</number>
|
<number>99999</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -3916,6 +3916,29 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="6" 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="6" 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>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="textInteractionFlags">
|
||||||
|
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user