mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 01:20:25 +08:00
RegVis: fixed out-of-range vector error when guess is used and we match to projections. ImageView: Added right-click menu option to set a fixed size for features
This commit is contained in:
@@ -845,7 +845,7 @@ Transform RegistrationVis::computeTransformationImpl(
|
|||||||
{
|
{
|
||||||
std::vector<std::vector<cv::DMatch> > matches;
|
std::vector<std::vector<cv::DMatch> > matches;
|
||||||
cv::BFMatcher matcher(descriptors.type()==CV_8U?cv::NORM_HAMMING:cv::NORM_L2SQR);
|
cv::BFMatcher matcher(descriptors.type()==CV_8U?cv::NORM_HAMMING:cv::NORM_L2SQR);
|
||||||
matcher.knnMatch(descriptorsTo.row(i), descriptors, matches, 2);
|
matcher.knnMatch(descriptorsTo.row(i), cv::Mat(descriptors, cv::Range(0, oi)), matches, 2);
|
||||||
UASSERT(matches.size() == 1);
|
UASSERT(matches.size() == 1);
|
||||||
UASSERT(matches[0].size() == 2);
|
UASSERT(matches[0].size() == 2);
|
||||||
if(matches[0].at(0).distance < _nndr * matches[0].at(1).distance)
|
if(matches[0].at(0).distance < _nndr * matches[0].at(1).distance)
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ pcl::PointCloud<pcl::PointXYZ>::Ptr voxelize(
|
|||||||
}
|
}
|
||||||
else if(cloud->size() && !cloud->is_dense && indices->size() == 0)
|
else if(cloud->size() && !cloud->is_dense && indices->size() == 0)
|
||||||
{
|
{
|
||||||
UWARN("Cannot voxelize a cloud not dense with empty indices! (input=%d pts)", (int)cloud->size());
|
UWARN("Cannot voxelize a not dense (organized) cloud with empty indices! (input=%d pts). Returning empty cloud!", (int)cloud->size());
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ public:
|
|||||||
bool isFeaturesShown() const;
|
bool isFeaturesShown() const;
|
||||||
bool isLinesShown() const;
|
bool isLinesShown() const;
|
||||||
int getAlpha() const {return _alpha;}
|
int getAlpha() const {return _alpha;}
|
||||||
|
int getFeaturesSize() const {return _featuresSize;}
|
||||||
bool isGraphicsViewMode() const;
|
bool isGraphicsViewMode() const;
|
||||||
bool isGraphicsViewScaled() const;
|
bool isGraphicsViewScaled() const;
|
||||||
const QColor & getDefaultBackgroundColor() const;
|
const QColor & getDefaultBackgroundColor() const;
|
||||||
@@ -86,6 +87,7 @@ public:
|
|||||||
void setFeatureColor(int id, QColor color);
|
void setFeatureColor(int id, QColor color);
|
||||||
void setFeaturesColor(QColor color);
|
void setFeaturesColor(QColor color);
|
||||||
void setAlpha(int alpha);
|
void setAlpha(int alpha);
|
||||||
|
void setFeaturesSize(int size);
|
||||||
void setSceneRect(const QRectF & rect);
|
void setSceneRect(const QRectF & rect);
|
||||||
|
|
||||||
const QMultiMap<int, rtabmap::KeypointItem *> & getFeatures() const {return _features;}
|
const QMultiMap<int, rtabmap::KeypointItem *> & getFeatures() const {return _features;}
|
||||||
@@ -114,6 +116,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
QString _savedFileName;
|
QString _savedFileName;
|
||||||
int _alpha;
|
int _alpha;
|
||||||
|
int _featuresSize;
|
||||||
QColor _defaultBgColor;
|
QColor _defaultBgColor;
|
||||||
|
|
||||||
QMenu * _menu;
|
QMenu * _menu;
|
||||||
@@ -123,6 +126,7 @@ private:
|
|||||||
QAction * _showLines;
|
QAction * _showLines;
|
||||||
QAction * _saveImage;
|
QAction * _saveImage;
|
||||||
QAction * _setAlpha;
|
QAction * _setAlpha;
|
||||||
|
QAction * _setFeaturesSize;
|
||||||
QAction * _graphicsViewMode;
|
QAction * _graphicsViewMode;
|
||||||
QAction * _graphicsViewScaled;
|
QAction * _graphicsViewScaled;
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public:
|
|||||||
virtual ~KeypointItem();
|
virtual ~KeypointItem();
|
||||||
|
|
||||||
void setColor(const QColor & color);
|
void setColor(const QColor & color);
|
||||||
|
const cv::KeyPoint & keypoint() const {return _kpt;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
|
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ ImageView::ImageView(QWidget * parent) :
|
|||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
_savedFileName((QDir::homePath()+ "/") + "picture" + ".png"),
|
_savedFileName((QDir::homePath()+ "/") + "picture" + ".png"),
|
||||||
_alpha(50),
|
_alpha(50),
|
||||||
|
_featuresSize(0.0f),
|
||||||
_defaultBgColor(Qt::black),
|
_defaultBgColor(Qt::black),
|
||||||
_imageItem(0),
|
_imageItem(0),
|
||||||
_imageDepthItem(0)
|
_imageDepthItem(0)
|
||||||
@@ -178,6 +179,7 @@ ImageView::ImageView(QWidget * parent) :
|
|||||||
_showFeatures = _menu->addAction(tr("Show features"));
|
_showFeatures = _menu->addAction(tr("Show features"));
|
||||||
_showFeatures->setCheckable(true);
|
_showFeatures->setCheckable(true);
|
||||||
_showFeatures->setChecked(true);
|
_showFeatures->setChecked(true);
|
||||||
|
_setFeaturesSize = _menu->addAction(tr("Set features size..."));
|
||||||
_showLines = _menu->addAction(tr("Show lines"));
|
_showLines = _menu->addAction(tr("Show lines"));
|
||||||
_showLines->setCheckable(true);
|
_showLines->setCheckable(true);
|
||||||
_showLines->setChecked(true);
|
_showLines->setChecked(true);
|
||||||
@@ -208,6 +210,7 @@ void ImageView::saveSettings(QSettings & settings, const QString & group) const
|
|||||||
settings.setValue("image_shown", this->isImageShown());
|
settings.setValue("image_shown", this->isImageShown());
|
||||||
settings.setValue("depth_shown", this->isImageDepthShown());
|
settings.setValue("depth_shown", this->isImageDepthShown());
|
||||||
settings.setValue("features_shown", this->isFeaturesShown());
|
settings.setValue("features_shown", this->isFeaturesShown());
|
||||||
|
settings.setValue("features_size", this->getFeaturesSize());
|
||||||
settings.setValue("lines_shown", this->isLinesShown());
|
settings.setValue("lines_shown", this->isLinesShown());
|
||||||
settings.setValue("alpha", this->getAlpha());
|
settings.setValue("alpha", this->getAlpha());
|
||||||
settings.setValue("bg_color", this->getDefaultBackgroundColor());
|
settings.setValue("bg_color", this->getDefaultBackgroundColor());
|
||||||
@@ -228,6 +231,7 @@ void ImageView::loadSettings(QSettings & settings, const QString & group)
|
|||||||
this->setImageShown(settings.value("image_shown", this->isImageShown()).toBool());
|
this->setImageShown(settings.value("image_shown", this->isImageShown()).toBool());
|
||||||
this->setImageDepthShown(settings.value("depth_shown", this->isImageDepthShown()).toBool());
|
this->setImageDepthShown(settings.value("depth_shown", this->isImageDepthShown()).toBool());
|
||||||
this->setFeaturesShown(settings.value("features_shown", this->isFeaturesShown()).toBool());
|
this->setFeaturesShown(settings.value("features_shown", this->isFeaturesShown()).toBool());
|
||||||
|
this->setFeaturesSize(settings.value("features_size", this->getFeaturesSize()).toInt());
|
||||||
this->setLinesShown(settings.value("lines_shown", this->isLinesShown()).toBool());
|
this->setLinesShown(settings.value("lines_shown", this->isLinesShown()).toBool());
|
||||||
this->setAlpha(settings.value("alpha", this->getAlpha()).toInt());
|
this->setAlpha(settings.value("alpha", this->getAlpha()).toInt());
|
||||||
this->setDefaultBackgroundColor(settings.value("bg_color", this->getDefaultBackgroundColor()).value<QColor>());
|
this->setDefaultBackgroundColor(settings.value("bg_color", this->getDefaultBackgroundColor()).value<QColor>());
|
||||||
@@ -641,6 +645,16 @@ void ImageView::contextMenuEvent(QContextMenuEvent * e)
|
|||||||
emit configChanged();
|
emit configChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(action == _setFeaturesSize)
|
||||||
|
{
|
||||||
|
bool ok = false;
|
||||||
|
int value = QInputDialog::getInt(this, tr("Set features size"), tr("Size (0 means actual keypoint size)"), _featuresSize, 0, 999, 1, &ok);
|
||||||
|
if(ok)
|
||||||
|
{
|
||||||
|
this->setFeaturesSize(value);
|
||||||
|
emit configChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(action == _showImage || action ==_showImageDepth)
|
if(action == _showImage || action ==_showImageDepth)
|
||||||
{
|
{
|
||||||
@@ -738,6 +752,10 @@ void ImageView::addFeature(int id, const cv::KeyPoint & kpt, float depth, QColor
|
|||||||
{
|
{
|
||||||
color.setAlpha(this->getAlpha());
|
color.setAlpha(this->getAlpha());
|
||||||
rtabmap::KeypointItem * item = new rtabmap::KeypointItem(id, kpt, depth, color);
|
rtabmap::KeypointItem * item = new rtabmap::KeypointItem(id, kpt, depth, color);
|
||||||
|
if(_featuresSize>0.0f)
|
||||||
|
{
|
||||||
|
item->setRect(kpt.pt.x-_featuresSize/2.0f, kpt.pt.y-_featuresSize/2.0f, _featuresSize, _featuresSize);
|
||||||
|
}
|
||||||
_features.insert(id, item);
|
_features.insert(id, item);
|
||||||
item->setVisible(isFeaturesShown());
|
item->setVisible(isFeaturesShown());
|
||||||
item->setZValue(1);
|
item->setZValue(1);
|
||||||
@@ -890,6 +908,26 @@ void ImageView::setAlpha(int alpha)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImageView::setFeaturesSize(int size)
|
||||||
|
{
|
||||||
|
_featuresSize = size;
|
||||||
|
for(QMultiMap<int, KeypointItem*>::iterator iter=_features.begin(); iter!=_features.end(); ++iter)
|
||||||
|
{
|
||||||
|
const cv::KeyPoint & kpt = iter.value()->keypoint();
|
||||||
|
if(size <= 0.0f)
|
||||||
|
{
|
||||||
|
size = kpt.size==0?3:kpt.size;
|
||||||
|
}
|
||||||
|
float sizef = size;
|
||||||
|
iter.value()->setRect(kpt.pt.x-sizef/2.0f, kpt.pt.y-sizef/2.0f, sizef, sizef);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!_graphicsView->isVisible())
|
||||||
|
{
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ImageView::setSceneRect(const QRectF & rect)
|
void ImageView::setSceneRect(const QRectF & rect)
|
||||||
{
|
{
|
||||||
_graphicsView->scene()->setSceneRect(rect);
|
_graphicsView->scene()->setSceneRect(rect);
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ int main(int argc, char * argv[])
|
|||||||
std::vector<float> slamTime;
|
std::vector<float> slamTime;
|
||||||
slamTime.reserve(ids.size());
|
slamTime.reserve(ids.size());
|
||||||
float rmse = -1;
|
float rmse = -1;
|
||||||
|
float maxRMSE = -1;
|
||||||
for(std::set<int>::iterator iter=ids.begin(); iter!=ids.end(); ++iter)
|
for(std::set<int>::iterator iter=ids.begin(); iter!=ids.end(); ++iter)
|
||||||
{
|
{
|
||||||
Transform p, gt;
|
Transform p, gt;
|
||||||
@@ -100,6 +101,10 @@ int main(int argc, char * argv[])
|
|||||||
if(uContains(stat, Statistics::kGtTranslational_rmse()))
|
if(uContains(stat, Statistics::kGtTranslational_rmse()))
|
||||||
{
|
{
|
||||||
rmse = stat.at(Statistics::kGtTranslational_rmse());
|
rmse = stat.at(Statistics::kGtTranslational_rmse());
|
||||||
|
if(maxRMSE==-1 || maxRMSE < rmse)
|
||||||
|
{
|
||||||
|
maxRMSE = rmse;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(uContains(stat, std::string("Camera/TotalTime/ms")))
|
if(uContains(stat, std::string("Camera/TotalTime/ms")))
|
||||||
{
|
{
|
||||||
@@ -115,10 +120,11 @@ int main(int argc, char * argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf(" %s (%d): %fm, slam: avg=%dms max=%dms, odom: avg=%dms max=%dms, camera: avg=%dms max=%dms\n",
|
printf(" %s (%d): %fm (max=%fm), slam: avg=%dms max=%dms, odom: avg=%dms max=%dms, camera: avg=%dms max=%dms\n",
|
||||||
fileName.c_str(),
|
fileName.c_str(),
|
||||||
(int)ids.size(),
|
(int)ids.size(),
|
||||||
rmse,
|
rmse,
|
||||||
|
maxRMSE,
|
||||||
(int)uMean(slamTime), (int)uMax(slamTime),
|
(int)uMean(slamTime), (int)uMax(slamTime),
|
||||||
(int)uMean(odomTime), (int)uMax(odomTime),
|
(int)uMean(odomTime), (int)uMax(odomTime),
|
||||||
(int)uMean(cameraTime), (int)uMax(cameraTime));
|
(int)uMean(cameraTime), (int)uMax(cameraTime));
|
||||||
|
|||||||
Reference in New Issue
Block a user