Added PyDetector (#677)

* Added PyDetector. Refactored PyMatcher.

* Fixed python freezing with multi-threading
This commit is contained in:
matlabbe
2021-01-17 01:56:27 -05:00
committed by GitHub
parent 0bc483b6d3
commit c49785061f
26 changed files with 733 additions and 115 deletions

View File

@@ -79,14 +79,14 @@ AboutDialog::AboutDialog(QWidget * parent) :
_ui->label_orboctree->setText("No");
_ui->label_orboctree_license->setEnabled(false);
#endif
#ifdef RTABMAP_SUPERPOINT_TORCH
#ifdef RTABMAP_TORCH
_ui->label_sptorch->setText("Yes");
_ui->label_sptorch_license->setEnabled(true);
#else
_ui->label_sptorch->setText("No");
_ui->label_sptorch_license->setEnabled(false);
#endif
#ifdef RTABMAP_PYMATCHER
#ifdef RTABMAP_PYTHON
_ui->label_pymatcher->setText("Yes");
_ui->label_pymatcher_license->setEnabled(true);
#else

View File

@@ -231,12 +231,14 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
_ui->vis_feature_detector->setItemData(10, 0, Qt::UserRole - 1);
#endif
#ifndef RTABMAP_SUPERPOINT_TORCH
#ifndef RTABMAP_TORCH
_ui->comboBox_detector_strategy->setItemData(11, 0, Qt::UserRole - 1);
_ui->vis_feature_detector->setItemData(11, 0, Qt::UserRole - 1);
#endif
#ifndef RTABMAP_PYMATCHER
#ifndef RTABMAP_PYTHON
_ui->comboBox_detector_strategy->setItemData(15, 0, Qt::UserRole - 1);
_ui->vis_feature_detector->setItemData(15, 0, Qt::UserRole - 1);
_ui->reextract_nn->setItemData(6, 0, Qt::UserRole - 1);
#endif
@@ -1009,7 +1011,12 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
_ui->pymatcher_iterations->setObjectName(Parameters::kPyMatcherIterations().c_str());
_ui->checkBox_pymatcher_cuda->setObjectName(Parameters::kPyMatcherCuda().c_str());
_ui->lineEdit_pymatcher_model->setObjectName(Parameters::kPyMatcherModel().c_str());
connect(_ui->toolButton_pymatcher_model, SIGNAL(clicked()), this, SLOT(changePyMatcherPath()));
connect(_ui->toolButton_pymatcher_model, SIGNAL(clicked()), this, SLOT(changePyMatcherModel()));
// PyDetector
_ui->lineEdit_pydetector_path->setObjectName(Parameters::kPyDetectorPath().c_str());
connect(_ui->toolButton_pydetector_path, SIGNAL(clicked()), this, SLOT(changePyDetectorPath()));
_ui->checkBox_pydetector_cuda->setObjectName(Parameters::kPyDetectorCuda().c_str());
// GMS
_ui->checkBox_gms_withRotation->setObjectName(Parameters::kGMSWithRotation().c_str());
@@ -4922,11 +4929,11 @@ void PreferencesDialog::changePyMatcherModel()
QString path;
if(_ui->lineEdit_pymatcher_model->text().isEmpty())
{
path = QFileDialog::getOpenFileName(this, tr("Select file"), this->getWorkingDirectory(), tr("PyTorch model (*.pth, *.pt)"));
path = QFileDialog::getOpenFileName(this, tr("Select file"), this->getWorkingDirectory(), tr("PyTorch model (*.pth *.pt)"));
}
else
{
path = QFileDialog::getOpenFileName(this, tr("Select file"), _ui->lineEdit_pymatcher_model->text(), tr("PyTorch model (*.pth, *.pt)"));
path = QFileDialog::getOpenFileName(this, tr("Select file"), _ui->lineEdit_pymatcher_model->text(), tr("PyTorch model (*.pth *.pt)"));
}
if(!path.isEmpty())
{
@@ -4934,6 +4941,23 @@ void PreferencesDialog::changePyMatcherModel()
}
}
void PreferencesDialog::changePyDetectorPath()
{
QString path;
if(_ui->lineEdit_pydetector_path->text().isEmpty())
{
path = QFileDialog::getOpenFileName(this, tr("Select file"), this->getWorkingDirectory(), tr("Python wrapper (*.py)"));
}
else
{
path = QFileDialog::getOpenFileName(this, tr("Select file"), _ui->lineEdit_pydetector_path->text(), tr("Python wrapper (*.py)"));
}
if(!path.isEmpty())
{
_ui->lineEdit_pydetector_path->setText(path);
}
}
void PreferencesDialog::updateSourceGrpVisibility()
{
_ui->groupBox_sourceRGBD->setVisible(_ui->comboBox_sourceType->currentIndex() == 0);

View File

@@ -63,7 +63,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-687</y>
<y>0</y>
<width>686</width>
<height>3357</height>
</rect>
@@ -95,7 +95,7 @@
<enum>QFrame::Raised</enum>
</property>
<property name="currentIndex">
<number>5</number>
<number>37</number>
</property>
<widget class="QWidget" name="page_22">
<layout class="QVBoxLayout" name="verticalLayout_29" stretch="0,1">
@@ -9159,6 +9159,11 @@ generate the number of words requested.</string>
<string>SURF+DAISY</string>
</property>
</item>
<item>
<property name="text">
<string>PyDetector</string>
</property>
</item>
</widget>
</item>
<item row="7" column="0">
@@ -17786,7 +17791,7 @@ Lower the ratio -&gt; higher the precision.</string>
<item>
<widget class="QLabel" name="label_586">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Python wrapper for python matcher like &lt;a href=&quot;https://github.com/magicleap/SuperGluePretrainedNetwork&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;SuperGlue&lt;/span&gt;&lt;/a&gt; or &lt;a href=&quot;https://github.com/zjhthu/OANet&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;OANet&lt;/span&gt;&lt;/a&gt;. Download the &lt;a href=&quot;https://github.com/introlab/rtabmap/tree/master/corelib/src/pymatcher&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;scripts&lt;/span&gt;&lt;/a&gt; and copy them at the root folder of SuperGlue git or in demo folder of OANet respectively, then set its path below. &lt;span style=&quot; font-weight:600;&quot;&gt;Important&lt;/span&gt;: Only float descriptors are allowed and SuperGlue works only with SuperPoint descriptors! You may have to train a new model for the feature used.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Python wrapper for python matcher like &lt;a href=&quot;https://github.com/magicleap/SuperGluePretrainedNetwork&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;SuperGlue&lt;/span&gt;&lt;/a&gt; or &lt;a href=&quot;https://github.com/zjhthu/OANet&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;OANet&lt;/span&gt;&lt;/a&gt;. Download the &lt;a href=&quot;https://github.com/introlab/rtabmap/tree/master/corelib/src/python&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;scripts&lt;/span&gt;&lt;/a&gt; and copy them at the root folder of SuperGlue git or in demo folder of OANet respectively, then set its path below. &lt;span style=&quot; font-weight:600;&quot;&gt;Important&lt;/span&gt;: Only float descriptors are allowed and SuperGlue works only with SuperPoint descriptors! You may have to train a new model for the feature used.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@@ -18539,6 +18544,11 @@ Lower the ratio -&gt; higher the precision.</string>
<string>SURF+DAISY</string>
</property>
</item>
<item>
<property name="text">
<string>PyDetector</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
@@ -22349,7 +22359,96 @@ Lower the ratio -&gt; higher the precision.</string>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>2964</height>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_87">
<layout class="QVBoxLayout" name="verticalLayout_153">
<item>
<widget class="QGroupBox" name="groupBox_pydetector2">
<property name="title">
<string>PyDetector</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_152">
<item>
<widget class="QLabel" name="label_614">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Python wrapper for python feature detector like &lt;a href=&quot;https://github.com/magicleap/SuperPointPretrainedNetwork&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;SuperPoint&lt;/span&gt;&lt;/a&gt;. Download the &lt;a href=&quot;https://github.com/introlab/rtabmap/tree/master/corelib/src/python&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;script&lt;/span&gt;&lt;/a&gt; and copy it at the root folder of SuperPoint git, then set its path below.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_118" columnstretch="0,0,1">
<item row="0" column="2">
<widget class="QLabel" name="label_615">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;[Required] Path to python script file.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_pydetector_path"/>
</item>
<item row="0" column="0">
<widget class="QToolButton" name="toolButton_pydetector_path">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="checkBox_pydetector_cuda">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_618">
<property name="text">
<string>Use Cuda device for Torch, otherwise CPU device is used by default.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_88">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>3128</height>
</size>
</property>
</spacer>