-Refactored HypVerification classes (added verification by signatures' similarity), there is no more complicated rejectedHypReason, now it's only true if valide or false if verification fails...

git-svn-id: http://rtabmap.googlecode.com/svn/branches/0.3/rtabmap@86 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
matlabbe
2011-06-09 02:56:31 +00:00
parent c59d461c81
commit 25c2a9f07e
13 changed files with 202 additions and 367 deletions

View File

@@ -303,9 +303,9 @@ void MainWindow::handleEvent(UEvent* anEvent)
RtabmapEvent * rtabmapEvent = (RtabmapEvent*)anEvent;
const Statistics & stats = rtabmapEvent->getStats();
int highestHypothesisId = int(uValue(stats.data(), Statistics::kLoopHighest_hypothesis_id(), 0.0f));
int rejectLoopReason = int(uValue(stats.data(), Statistics::kLoopRejected_reason(), 0.0f));
bool rejectedHyp = bool(uValue(stats.data(), Statistics::kLoopRejectedHypothesis(), 0.0f));
if((stats.loopClosureId() > 0 && _ui->actionPause_on_match->isChecked()) ||
(stats.loopClosureId() == 0 && highestHypothesisId > 0 && _ui->actionPause_when_a_loop_hypothesis_is_rejected->isChecked() && (rejectLoopReason >= 12 || (rejectLoopReason == 3 && uValue(stats.data(), Statistics::kLoopHighest_hypothesis_value(), 0.0f)>=_preferencesDialog->getLoopThr()))))
(stats.loopClosureId() == 0 && highestHypothesisId > 0 && _ui->actionPause_when_a_loop_hypothesis_is_rejected->isChecked() && rejectedHyp))
{
if(_state != kPaused)
{
@@ -423,7 +423,7 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
}
ULOGGER_DEBUG("");
_ui->imageView_loopClosure->setBackgroundBrush(QBrush(Qt::black));
int rejectLoopReason = int(uValue(stat.data(), Statistics::kLoopRejected_reason(), 0.0f));
int rejectedHyp = bool(uValue(stat.data(), Statistics::kLoopRejectedHypothesis(), 0.0f));
if(stat.loopClosureId()>0)
{
_ui->label_stats_loopClosuresDetected->setText(QString::number(_ui->label_stats_loopClosuresDetected->text().toInt() + 1));
@@ -453,8 +453,7 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
_ui->imageView_loopClosure->scene()->addPixmap(QPixmap::fromImage(img))->setVisible(this->_ui->checkBox_showImageLoop->isChecked());
}
}
else if(rejectLoopReason>=12 ||
(rejectLoopReason == 3 && uValue(stat.data(), Statistics::kLoopHighest_hypothesis_value(), 0.0f)>=_preferencesDialog->getLoopThr()))
else if(rejectedHyp)
{
ULOGGER_DEBUG("");
_ui->label_stats_loopClosuresRejected->setText(QString::number(_ui->label_stats_loopClosuresRejected->text().toInt() + 1));
@@ -462,87 +461,37 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
if(_preferencesDialog->imageRejectedShown())
{
// rejectLoopReason,
// 1 is for not enough hypotheses, [not supposed to occur if highestHypothesisId is set]
// 10 to ... means rejecting reasons from the hypotheses verification step.
// UNDEFINED, 10
// ACCEPTED, 11
// NO_HYPOTHESIS, 12
// MEMORY_IS_NULL, 13
// NOT_ENOUGH_MATCHING_PAIRS, 14
// EPIPOLAR_CONSTRAINT_FAILED, 15
// NULL_MATCHING_SURF_SIGNATURES 16
// FUNDAMENTAL_MATRIX_NOT_FOUND 17
if(rejectLoopReason == 3 ||
((rejectLoopReason-10)>=0 && (rejectLoopReason-10) < 12))
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())
{
QColor color;
QGraphicsTextItem * textItem = 0;
switch(rejectLoopReason)
if(!img.loadFromData(iter.value(), "JPEG"))
{
case 3:
textItem = _ui->imageView_loopClosure->scene()->addText(tr("Rejected by hypothesis ratio"));
color = Qt::yellow;
break;
case 13:
textItem = _ui->imageView_loopClosure->scene()->addText(tr("Memory is null (Intern error)"));
color = Qt::blue;
break;
case 14:
textItem = _ui->imageView_loopClosure->scene()->addText(tr("Not enough matching pairs"));
color = Qt::red;
break;
case 15:
textItem = _ui->imageView_loopClosure->scene()->addText(tr("Epipolar geometry verification failed"));
color = Qt::cyan;
break;
case 16:
textItem = _ui->imageView_loopClosure->scene()->addText(tr("Signatures are not the same type"));
color = Qt::magenta;
break;
case 17:
textItem = _ui->imageView_loopClosure->scene()->addText(tr("Fundamental matrix not found"));
color = Qt::yellow;
break;
default:
textItem = _ui->imageView_loopClosure->scene()->addText(tr("Undefined rejecting reason!?"));
color = Qt::blue;
break;
}
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())
{
if(!img.loadFromData(iter.value(), "JPEG"))
{
ULOGGER_ERROR("conversion from QByteArray to QImage failed");
img = QImage();
}
}
else if(stat.loopClosureImage())
{
img = Ipl2QImage(stat.loopClosureImage());
}
if(!img.isNull())
{
_ui->imageView_loopClosure->scene()->addPixmap(QPixmap::fromImage(img));
ULOGGER_ERROR("conversion from QByteArray to QImage failed");
img = QImage();
}
}
else
else if(stat.loopClosureImage())
{
ULOGGER_ERROR("rejectLoopReason=%d-10 is outside of the range of Qt::GlobalColor", rejectLoopReason);
img = Ipl2QImage(stat.loopClosureImage());
}
if(!img.isNull())
{
_ui->imageView_loopClosure->scene()->addPixmap(QPixmap::fromImage(img));
}
}
}
ULOGGER_DEBUG("");
if((stat.loopClosureId()>0 || rejectLoopReason>=12) && 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()));
}
}
ULOGGER_DEBUG("");

View File

@@ -184,6 +184,7 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
// verifyHypotheses
_ui->comboBox_vh_strategy->setObjectName(Parameters::kRtabmapVhStrategy().c_str());
_ui->vh_doubleSpinBox_similarity->setObjectName(Parameters::kVhSimilarity().c_str());
_ui->surf_spinBox_matchCountMinAccepted->setObjectName(Parameters::kVhEpMatchCountMin().c_str());
_ui->surf_doubleSpinBox_ransacParam1->setObjectName(Parameters::kVhEpRansacParam1().c_str());
_ui->surf_doubleSpinBox_ransacParam2->setObjectName(Parameters::kVhEpRansacParam2().c_str());
@@ -1047,7 +1048,11 @@ void PreferencesDialog::addParameter(const QObject * object, int value)
{
// No panel related...
}
else if(value == 1) // 1 epipolar
else if(value == 1) // 1 similarity
{
this->addParameters(_ui->groupBox_vh_similarity);
}
else if(value == 2) // 2 epipolar
{
this->addParameters(_ui->groupBox_vh_epipolar);
}

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>892</width>
<height>792</height>
<height>796</height>
</rect>
</property>
<property name="sizePolicy">
@@ -46,9 +46,6 @@
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
<item>
@@ -68,7 +65,7 @@
<enum>QFrame::Raised</enum>
</property>
<property name="currentIndex">
<number>2</number>
<number>14</number>
</property>
<widget class="QWidget" name="page_22">
<layout class="QVBoxLayout" name="verticalLayout_29">
@@ -1093,8 +1090,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>26</width>
<height>78</height>
<width>98</width>
<height>71</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
@@ -2710,6 +2707,11 @@ Lower the ratio -&gt; higher the precision</string>
<string>No verification</string>
</property>
</item>
<item>
<property name="text">
<string>Similarity</string>
</property>
</item>
<item>
<property name="text">
<string>Epipolar constraints</string>
@@ -2742,6 +2744,58 @@ Lower the ratio -&gt; higher the precision</string>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_15">
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QGroupBox" name="groupBox_vh_similarity">
<property name="title">
<string>2Similarity verification</string>
</property>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,10">
<item row="0" column="0">
<widget class="QDoubleSpinBox" name="vh_doubleSpinBox_similarity">
<property name="decimals">
<number>2</number>
</property>
<property name="maximum">
<double>0.990000000000000</double>
</property>
<property name="singleStep">
<double>0.010000000000000</double>
</property>
<property name="value">
<double>0.500000000000000</double>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_55">
<property name="text">
<string>Minimum similarity to accept an hypothesis</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>619</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_21">
<layout class="QVBoxLayout" name="verticalLayout_25">
<item>