mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 17:40:23 +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:
@@ -155,6 +155,7 @@ ImageView::ImageView(QWidget * parent) :
|
||||
QWidget(parent),
|
||||
_savedFileName((QDir::homePath()+ "/") + "picture" + ".png"),
|
||||
_alpha(50),
|
||||
_featuresSize(0.0f),
|
||||
_defaultBgColor(Qt::black),
|
||||
_imageItem(0),
|
||||
_imageDepthItem(0)
|
||||
@@ -178,6 +179,7 @@ ImageView::ImageView(QWidget * parent) :
|
||||
_showFeatures = _menu->addAction(tr("Show features"));
|
||||
_showFeatures->setCheckable(true);
|
||||
_showFeatures->setChecked(true);
|
||||
_setFeaturesSize = _menu->addAction(tr("Set features size..."));
|
||||
_showLines = _menu->addAction(tr("Show lines"));
|
||||
_showLines->setCheckable(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("depth_shown", this->isImageDepthShown());
|
||||
settings.setValue("features_shown", this->isFeaturesShown());
|
||||
settings.setValue("features_size", this->getFeaturesSize());
|
||||
settings.setValue("lines_shown", this->isLinesShown());
|
||||
settings.setValue("alpha", this->getAlpha());
|
||||
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->setImageDepthShown(settings.value("depth_shown", this->isImageDepthShown()).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->setAlpha(settings.value("alpha", this->getAlpha()).toInt());
|
||||
this->setDefaultBackgroundColor(settings.value("bg_color", this->getDefaultBackgroundColor()).value<QColor>());
|
||||
@@ -641,6 +645,16 @@ void ImageView::contextMenuEvent(QContextMenuEvent * e)
|
||||
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)
|
||||
{
|
||||
@@ -738,6 +752,10 @@ void ImageView::addFeature(int id, const cv::KeyPoint & kpt, float depth, QColor
|
||||
{
|
||||
color.setAlpha(this->getAlpha());
|
||||
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);
|
||||
item->setVisible(isFeaturesShown());
|
||||
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)
|
||||
{
|
||||
_graphicsView->scene()->setSceneRect(rect);
|
||||
|
||||
Reference in New Issue
Block a user