mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-04 00:37:46 +08:00
DBReader: added camera selection
This commit is contained in:
@@ -51,12 +51,14 @@ public:
|
||||
float frameRate = 0.0f,
|
||||
bool odometryIgnored = false,
|
||||
bool ignoreGoalDelay = false,
|
||||
bool goalsIgnored = false);
|
||||
bool goalsIgnored = false,
|
||||
int cameraIndex = -1);
|
||||
DBReader(const std::list<std::string> & databasePaths,
|
||||
float frameRate = 0.0f,
|
||||
bool odometryIgnored = false,
|
||||
bool ignoreGoalDelay = false,
|
||||
bool goalsIgnored = false);
|
||||
bool goalsIgnored = false,
|
||||
int cameraIndex = -1);
|
||||
virtual ~DBReader();
|
||||
|
||||
bool init(int startIndex=0);
|
||||
@@ -73,6 +75,7 @@ private:
|
||||
bool _odometryIgnored;
|
||||
bool _ignoreGoalDelay;
|
||||
bool _goalsIgnored;
|
||||
int _cameraIndex;
|
||||
|
||||
DBDriver * _dbDriver;
|
||||
UTimer _timer;
|
||||
|
||||
@@ -46,12 +46,14 @@ DBReader::DBReader(const std::string & databasePath,
|
||||
float frameRate,
|
||||
bool odometryIgnored,
|
||||
bool ignoreGoalDelay,
|
||||
bool goalsIgnored) :
|
||||
bool goalsIgnored,
|
||||
int cameraIndex) :
|
||||
_paths(uSplit(databasePath, ';')),
|
||||
_frameRate(frameRate),
|
||||
_odometryIgnored(odometryIgnored),
|
||||
_ignoreGoalDelay(ignoreGoalDelay),
|
||||
_goalsIgnored(goalsIgnored),
|
||||
_cameraIndex(cameraIndex),
|
||||
_dbDriver(0),
|
||||
_currentId(_ids.end()),
|
||||
_previousStamp(0),
|
||||
@@ -63,12 +65,14 @@ DBReader::DBReader(const std::list<std::string> & databasePaths,
|
||||
float frameRate,
|
||||
bool odometryIgnored,
|
||||
bool ignoreGoalDelay,
|
||||
bool goalsIgnored) :
|
||||
bool goalsIgnored,
|
||||
int cameraIndex) :
|
||||
_paths(databasePaths),
|
||||
_frameRate(frameRate),
|
||||
_odometryIgnored(odometryIgnored),
|
||||
_ignoreGoalDelay(ignoreGoalDelay),
|
||||
_goalsIgnored(goalsIgnored),
|
||||
_cameraIndex(cameraIndex),
|
||||
_dbDriver(0),
|
||||
_currentId(_ids.end()),
|
||||
_previousStamp(0),
|
||||
@@ -368,6 +372,37 @@ OdometryEvent DBReader::getNextData()
|
||||
if(!this->isKilled())
|
||||
{
|
||||
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.setStamp(stamp);
|
||||
data.setGroundTruth(groundTruth);
|
||||
|
||||
@@ -209,6 +209,7 @@ public:
|
||||
bool getSourceDatabaseGoalsIgnored() const; //Database group
|
||||
int getSourceDatabaseStartPos() const; //Database group
|
||||
bool getSourceDatabaseStampsUsed() const;//Database group
|
||||
int getSourceDatabaseCameraIndex() const; //Database group
|
||||
bool isSourceRGBDColorOnly() const;
|
||||
int getSourceImageDecimation() const;
|
||||
bool isSourceStereoDepthGenerated() const;
|
||||
|
||||
@@ -3886,7 +3886,8 @@ void MainWindow::startDetection()
|
||||
_preferencesDialog->getSourceDatabaseStampsUsed()?-1:_preferencesDialog->getGeneralInputRate(),
|
||||
_preferencesDialog->getSourceDatabaseOdometryIgnored(),
|
||||
_preferencesDialog->getSourceDatabaseGoalDelayIgnored(),
|
||||
_preferencesDialog->getSourceDatabaseGoalsIgnored());
|
||||
_preferencesDialog->getSourceDatabaseGoalsIgnored(),
|
||||
_preferencesDialog->getSourceDatabaseCameraIndex());
|
||||
|
||||
//Create odometry thread if rgdb slam
|
||||
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_spinBox_databaseStartPos, 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()));
|
||||
|
||||
//openni group
|
||||
_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_ignoreGoals->setChecked(true);
|
||||
_ui->source_spinBox_databaseStartPos->setValue(0);
|
||||
_ui->source_spinBox_database_cameraIndex->setValue(-1);
|
||||
_ui->source_checkBox_useDbStamps->setChecked(true);
|
||||
|
||||
#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_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_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());
|
||||
settings.endGroup(); // Database
|
||||
|
||||
@@ -2109,6 +2112,7 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath) const
|
||||
settings.setValue("ignoreGoalDelay", _ui->source_checkBox_ignoreGoalDelay->isChecked());
|
||||
settings.setValue("ignoreGoals", _ui->source_checkBox_ignoreGoals->isChecked());
|
||||
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.endGroup(); // Database
|
||||
|
||||
@@ -2680,6 +2684,7 @@ void PreferencesDialog::selectSourceDatabase()
|
||||
_ui->source_checkBox_ignoreOdometry->setChecked(r != QMessageBox::Yes);
|
||||
_ui->source_database_lineEdit_path->setText(paths.size()==1?paths.front():paths.join(";"));
|
||||
_ui->source_spinBox_databaseStartPos->setValue(0);
|
||||
_ui->source_spinBox_database_cameraIndex->setValue(-1);
|
||||
_ui->source_checkBox_useDbStamps->setChecked(true);
|
||||
}
|
||||
}
|
||||
@@ -3906,6 +3911,10 @@ int PreferencesDialog::getSourceDatabaseStartPos() const
|
||||
{
|
||||
return _ui->source_spinBox_databaseStartPos->value();
|
||||
}
|
||||
int PreferencesDialog::getSourceDatabaseCameraIndex() const
|
||||
{
|
||||
return _ui->source_spinBox_database_cameraIndex->value();
|
||||
}
|
||||
bool PreferencesDialog::getSourceDatabaseStampsUsed() const
|
||||
{
|
||||
return _ui->source_checkBox_useDbStamps->isChecked();
|
||||
@@ -4370,7 +4379,9 @@ void PreferencesDialog::testOdometry()
|
||||
DBReader dbReader(_ui->source_database_lineEdit_path->text().toStdString(),
|
||||
_ui->source_checkBox_useDbStamps->isChecked()?-1:this->getGeneralInputRate(),
|
||||
true,
|
||||
true);
|
||||
true,
|
||||
true,
|
||||
_ui->source_spinBox_database_cameraIndex->value());
|
||||
Camera * camera = 0;
|
||||
if(this->getSourceType() == kSrcDatabase)
|
||||
{
|
||||
@@ -4464,8 +4475,10 @@ void PreferencesDialog::testCamera()
|
||||
DBReader dbReader(_ui->source_database_lineEdit_path->text().toStdString(),
|
||||
_ui->source_checkBox_useDbStamps->isChecked()?-1:this->getGeneralInputRate(),
|
||||
true,
|
||||
true);
|
||||
if(!dbReader.init())
|
||||
true,
|
||||
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!"));
|
||||
delete window;
|
||||
|
||||
@@ -63,9 +63,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>681</width>
|
||||
<height>2044</height>
|
||||
<y>-360</y>
|
||||
<width>686</width>
|
||||
<height>2023</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_16">
|
||||
@@ -86,7 +86,7 @@
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>14</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_22">
|
||||
<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>
|
||||
<widget class="QStackedWidget" name="stackedWidget_src">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_41">
|
||||
<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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="7" column="1">
|
||||
<spacer name="verticalSpacer_35">
|
||||
<property name="orientation">
|
||||
<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>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999999</number>
|
||||
<number>99999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -3916,6 +3916,29 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user