mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 01:20:25 +08:00
Added option in GUI to show image of the highest hypothesis
git-svn-id: http://rtabmap.googlecode.com/svn/branches/0.3/rtabmap@95 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
@@ -389,6 +389,7 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
|
||||
_ui->imageView_loopClosure->scene()->clear();
|
||||
_ui->imageView_source->resetTransform();
|
||||
_ui->imageView_loopClosure->resetTransform();
|
||||
_ui->imageView_loopClosure->setBackgroundBrush(QBrush(Qt::black));
|
||||
|
||||
_ui->label_matchId->clear();
|
||||
QPixmap refPixmap;
|
||||
@@ -413,9 +414,10 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
|
||||
_ui->imageView_loopClosure->setSceneRect(sceneRect);
|
||||
}
|
||||
ULOGGER_DEBUG("");
|
||||
QImage lcImg;
|
||||
if(stat.loopClosureImage())
|
||||
{
|
||||
QImage img = Ipl2QImage(stat.loopClosureImage());
|
||||
lcImg = Ipl2QImage(stat.loopClosureImage());
|
||||
//Only kept if it not added as a child in the core, that
|
||||
//means it will never used for a loop closure detection
|
||||
if(_preferencesDialog->isImagesKept())
|
||||
@@ -426,81 +428,76 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
|
||||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
img.save(&buffer, "JPEG"); // writes image into JPEG format
|
||||
lcImg.save(&buffer, "JPEG"); // writes image into JPEG format
|
||||
_imagesMap.insert(id, ba);
|
||||
}
|
||||
}
|
||||
}
|
||||
ULOGGER_DEBUG("");
|
||||
_ui->imageView_loopClosure->setBackgroundBrush(QBrush(Qt::black));
|
||||
int rejectedHyp = bool(uValue(stat.data(), Statistics::kLoopRejectedHypothesis(), 0.0f));
|
||||
if(stat.loopClosureId()>0)
|
||||
if(highestHypothesisId > 0)
|
||||
{
|
||||
_ui->label_stats_loopClosuresDetected->setText(QString::number(_ui->label_stats_loopClosuresDetected->text().toInt() + 1));
|
||||
if(highestHypothesisIsSaved)
|
||||
bool show = true;
|
||||
if(stat.loopClosureId() > 0)
|
||||
{
|
||||
_ui->label_stats_loopClosuresReactivatedDetected->setText(QString::number(_ui->label_stats_loopClosuresReactivatedDetected->text().toInt() + 1));
|
||||
}
|
||||
_ui->label_matchId->setText(QString("Match ID = %1").arg(stat.loopClosureId()));
|
||||
|
||||
QImage img;
|
||||
QMap<int, QByteArray>::iterator iter = _imagesMap.find(stat.loopClosureId());
|
||||
if(iter != _imagesMap.end())
|
||||
{
|
||||
if(!img.loadFromData(iter.value(), "JPEG"))
|
||||
_ui->imageView_loopClosure->setBackgroundBrush(QBrush(Qt::green));
|
||||
_ui->label_stats_loopClosuresDetected->setText(QString::number(_ui->label_stats_loopClosuresDetected->text().toInt() + 1));
|
||||
if(highestHypothesisIsSaved)
|
||||
{
|
||||
ULOGGER_ERROR("conversion from QByteArray to QImage failed");
|
||||
img = QImage();
|
||||
_ui->label_stats_loopClosuresReactivatedDetected->setText(QString::number(_ui->label_stats_loopClosuresReactivatedDetected->text().toInt() + 1));
|
||||
}
|
||||
_ui->label_matchId->setText(QString("Match ID = %1").arg(stat.loopClosureId()));
|
||||
}
|
||||
else if(rejectedHyp)
|
||||
{
|
||||
show = _preferencesDialog->imageRejectedShown() || _preferencesDialog->imageHighestHypShown();;
|
||||
if(show)
|
||||
{
|
||||
QColor color(Qt::red);
|
||||
_ui->imageView_loopClosure->setBackgroundBrush(QBrush(color));
|
||||
_ui->label_stats_loopClosuresRejected->setText(QString::number(_ui->label_stats_loopClosuresRejected->text().toInt() + 1));
|
||||
_ui->label_matchId->setText(QString("Loop hypothesis (%1) rejected!").arg(highestHypothesisId));
|
||||
QGraphicsTextItem * textItem = _ui->imageView_loopClosure->scene()->addText(tr("Rejected hypothesis"));
|
||||
textItem->setDefaultTextColor(QColor(255-color.red(), 255-color.green(), 255-color.blue())); // color inverted
|
||||
textItem->setZValue(2);
|
||||
}
|
||||
}
|
||||
else if(stat.loopClosureImage())
|
||||
else
|
||||
{
|
||||
img = Ipl2QImage(stat.loopClosureImage());
|
||||
}
|
||||
|
||||
if(!img.isNull())
|
||||
{
|
||||
_ui->imageView_loopClosure->scene()->addPixmap(QPixmap::fromImage(img))->setVisible(this->_ui->checkBox_showImageLoop->isChecked());
|
||||
}
|
||||
}
|
||||
else if(rejectedHyp)
|
||||
{
|
||||
ULOGGER_DEBUG("");
|
||||
_ui->label_stats_loopClosuresRejected->setText(QString::number(_ui->label_stats_loopClosuresRejected->text().toInt() + 1));
|
||||
_ui->label_matchId->setText(QString("Loop hypothesis (%1) rejected!").arg(highestHypothesisId));
|
||||
|
||||
if(_preferencesDialog->imageRejectedShown())
|
||||
{
|
||||
QColor color = Qt::yellow;
|
||||
QGraphicsTextItem * textItem = _ui->imageView_loopClosure->scene()->addText(tr("Rejected hypothesis"));
|
||||
|
||||
textItem->setDefaultTextColor(QColor(255-color.red(), 255-color.green(), 255-color.blue())); // color inverted
|
||||
textItem->setZValue(2);
|
||||
|
||||
_ui->imageView_loopClosure->setBackgroundBrush(QBrush(color));
|
||||
QImage img;
|
||||
QMap<int, QByteArray>::iterator iter = _imagesMap.find(highestHypothesisId);
|
||||
if(iter != _imagesMap.end())
|
||||
show = _preferencesDialog->imageHighestHypShown();
|
||||
if(show)
|
||||
{
|
||||
if(!img.loadFromData(iter.value(), "JPEG"))
|
||||
_ui->label_matchId->setText(QString("Highest hypothesis (%1)").arg(highestHypothesisId));
|
||||
}
|
||||
}
|
||||
|
||||
if(show)
|
||||
{
|
||||
if(lcImg.isNull())
|
||||
{
|
||||
QMap<int, QByteArray>::iterator iter = _imagesMap.find(stat.loopClosureId());
|
||||
if(iter != _imagesMap.end())
|
||||
{
|
||||
ULOGGER_ERROR("conversion from QByteArray to QImage failed");
|
||||
img = QImage();
|
||||
if(!lcImg.loadFromData(iter.value(), "JPEG"))
|
||||
{
|
||||
ULOGGER_ERROR("conversion from QByteArray to QImage failed");
|
||||
lcImg = QImage();
|
||||
}
|
||||
}
|
||||
else if(stat.loopClosureImage())
|
||||
{
|
||||
lcImg = Ipl2QImage(stat.loopClosureImage());
|
||||
}
|
||||
}
|
||||
else if(stat.loopClosureImage())
|
||||
{
|
||||
img = Ipl2QImage(stat.loopClosureImage());
|
||||
}
|
||||
|
||||
if(!img.isNull())
|
||||
if(!lcImg.isNull())
|
||||
{
|
||||
_ui->imageView_loopClosure->scene()->addPixmap(QPixmap::fromImage(img));
|
||||
_ui->imageView_loopClosure->scene()->addPixmap(QPixmap::fromImage(lcImg))->setVisible(this->_ui->checkBox_showImageLoop->isChecked());
|
||||
}
|
||||
if(highestHypothesisIsSaved)
|
||||
{
|
||||
_ui->label_matchId->setText(QString("[Retrieved!] ").append(_ui->label_matchId->text()));
|
||||
}
|
||||
}
|
||||
if(highestHypothesisIsSaved)
|
||||
{
|
||||
_ui->label_matchId->setText(QString("[Retrieved!] ").append(_ui->label_matchId->text()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -506,6 +506,7 @@ void PreferencesDialog::readGuiSettings(const QString & filePath)
|
||||
_ui->checkBox_verticalLayoutUsed->setChecked(settings.value("verticalLayoutUsed", _ui->checkBox_verticalLayoutUsed->isChecked()).toBool());
|
||||
_ui->checkBox_imageFlipped->setChecked(settings.value("imageFlipped", _ui->checkBox_imageFlipped->isChecked()).toBool());
|
||||
_ui->checkBox_imageRejectedShown->setChecked(settings.value("imageRejectedShown", _ui->checkBox_imageRejectedShown->isChecked()).toBool());
|
||||
_ui->checkBox_imageHighestHypShown->setChecked(settings.value("imageHighestHypShown", _ui->checkBox_imageHighestHypShown->isChecked()).toBool());
|
||||
_ui->checkBox_beep->setChecked(settings.value("beep", _ui->checkBox_beep->isChecked()).toBool());
|
||||
_ui->horizontalSlider_keypointsOpacity->setValue(settings.value("keypointsOpacity", _ui->horizontalSlider_keypointsOpacity->value()).toInt());
|
||||
|
||||
@@ -646,6 +647,7 @@ void PreferencesDialog::writeGuiSettings(const QString & filePath)
|
||||
settings.setValue("verticalLayoutUsed", _ui->checkBox_verticalLayoutUsed->isChecked());
|
||||
settings.setValue("imageFlipped", _ui->checkBox_imageFlipped->isChecked());
|
||||
settings.setValue("imageRejectedShown", _ui->checkBox_imageRejectedShown->isChecked());
|
||||
settings.setValue("imageHighestHypShown", _ui->checkBox_imageHighestHypShown->isChecked());
|
||||
settings.setValue("beep", _ui->checkBox_beep->isChecked());
|
||||
settings.setValue("keypointsOpacity", _ui->horizontalSlider_keypointsOpacity->value());
|
||||
settings.endGroup(); // General
|
||||
@@ -1478,6 +1480,10 @@ bool PreferencesDialog::imageRejectedShown() const
|
||||
{
|
||||
return _ui->checkBox_imageRejectedShown->isChecked();
|
||||
}
|
||||
bool PreferencesDialog::imageHighestHypShown() const
|
||||
{
|
||||
return _ui->checkBox_imageHighestHypShown->isChecked();
|
||||
}
|
||||
bool PreferencesDialog::beepOnPause() const
|
||||
{
|
||||
return _ui->checkBox_beep->isChecked();
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_22">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_29">
|
||||
@@ -327,7 +327,7 @@ when using the file type, logs are saved in Logrtabmap.txt (located in the worki
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="2">
|
||||
<item row="11" column="2">
|
||||
<widget class="QLabel" name="label_88">
|
||||
<property name="text">
|
||||
<string>Beep! on special events (finished processing the data set, an error has occured, ...)</string>
|
||||
@@ -337,14 +337,14 @@ when using the file type, logs are saved in Logrtabmap.txt (located in the worki
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<item row="11" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_beep">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<item row="12" column="0">
|
||||
<widget class="QSlider" name="horizontalSlider_keypointsOpacity">
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
@@ -360,7 +360,7 @@ when using the file type, logs are saved in Logrtabmap.txt (located in the worki
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="2">
|
||||
<item row="12" column="2">
|
||||
<widget class="QLabel" name="label_102">
|
||||
<property name="text">
|
||||
<string>Keypoints opacity</string>
|
||||
@@ -370,6 +370,26 @@ when using the file type, logs are saved in Logrtabmap.txt (located in the worki
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="2">
|
||||
<widget class="QLabel" name="label_105">
|
||||
<property name="text">
|
||||
<string>Show the image of the highest hypothesis</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QCheckBox" name="checkBox_imageHighestHypShown">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -1093,8 +1113,8 @@ We can edit how will like the prediction used in the Bayes filter when there is
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>524</width>
|
||||
<height>138</height>
|
||||
<width>26</width>
|
||||
<height>78</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
|
||||
Reference in New Issue
Block a user