mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-01 17:10:26 +08:00
Fixed how images are scaled to handle images with different size
This commit is contained in:
@@ -55,6 +55,7 @@ public:
|
||||
void saveSettings(QSettings & settings, const QString & group = "") const;
|
||||
void loadSettings(QSettings & settings, const QString & group = "");
|
||||
|
||||
QRectF sceneRect() const;
|
||||
bool isImageShown() const;
|
||||
bool isImageDepthShown() const;
|
||||
bool isFeaturesShown() const;
|
||||
|
||||
@@ -127,6 +127,11 @@ void ImageView::loadSettings(QSettings & settings, const QString & group)
|
||||
}
|
||||
}
|
||||
|
||||
QRectF ImageView::sceneRect() const
|
||||
{
|
||||
return _graphicsView->scene()->sceneRect();
|
||||
}
|
||||
|
||||
bool ImageView::isImageShown() const
|
||||
{
|
||||
return _showImage->isChecked();
|
||||
@@ -770,6 +775,9 @@ void ImageView::clear()
|
||||
}
|
||||
_imageDepth = QPixmap();
|
||||
|
||||
_graphicsView->scene()->setSceneRect(QRectF());
|
||||
_graphicsView->setScene(_graphicsView->scene());
|
||||
|
||||
if(!_graphicsView->isVisible())
|
||||
{
|
||||
this->update();
|
||||
|
||||
@@ -1099,12 +1099,6 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
|
||||
{
|
||||
_ui->imageView_loopClosure->setImageDepth(lcDepth);
|
||||
}
|
||||
if(img.rect().isValid())
|
||||
{
|
||||
QRectF sceneRect = img.rect();
|
||||
_ui->imageView_source->setSceneRect(sceneRect);
|
||||
_ui->imageView_loopClosure->setSceneRect(sceneRect);
|
||||
}
|
||||
}
|
||||
|
||||
UDEBUG("time= %d ms", time.restart());
|
||||
@@ -2263,30 +2257,42 @@ void MainWindow::drawKeypoints(const std::multimap<int, cv::KeyPoint> & refWords
|
||||
}
|
||||
|
||||
// Draw lines between corresponding features...
|
||||
float scale = _ui->imageView_source->viewScale();
|
||||
UDEBUG("scale=%f", scale);
|
||||
float deltaX = _ui->imageView_source->width()/scale;
|
||||
float scaleSource = _ui->imageView_source->viewScale();
|
||||
float scaleLoop = _ui->imageView_loopClosure->viewScale();
|
||||
UDEBUG("scale source=%f loop=%f", scaleSource, scaleLoop);
|
||||
// Delta in actual window pixels
|
||||
float sourceMarginX = (_ui->imageView_source->width() - _ui->imageView_source->sceneRect().width()*scaleSource)/2.0f;
|
||||
float sourceMarginY = (_ui->imageView_source->height() - _ui->imageView_source->sceneRect().height()*scaleSource)/2.0f;
|
||||
float loopMarginX = (_ui->imageView_loopClosure->width() - _ui->imageView_loopClosure->sceneRect().width()*scaleLoop)/2.0f;
|
||||
float loopMarginY = (_ui->imageView_loopClosure->height() - _ui->imageView_loopClosure->sceneRect().height()*scaleLoop)/2.0f;
|
||||
|
||||
float deltaX = 0;
|
||||
float deltaY = 0;
|
||||
|
||||
if(_preferencesDialog->isVerticalLayoutUsed())
|
||||
{
|
||||
deltaX = 0;
|
||||
deltaY = _ui->imageView_source->height()/scale;
|
||||
deltaY += _ui->label_matchId->height()/scale;
|
||||
deltaY = _ui->label_matchId->height() + _ui->imageView_source->height();
|
||||
}
|
||||
else
|
||||
{
|
||||
deltaX = _ui->imageView_source->width();
|
||||
}
|
||||
|
||||
for(QList<QPair<cv::Point2f, cv::Point2f> >::iterator iter = uniqueCorrespondences.begin();
|
||||
iter!=uniqueCorrespondences.end();
|
||||
++iter)
|
||||
{
|
||||
|
||||
_ui->imageView_source->addLine(
|
||||
iter->first.x,
|
||||
iter->first.y,
|
||||
iter->second.x+deltaX,
|
||||
iter->second.y+deltaY,
|
||||
(iter->second.x*scaleLoop+loopMarginX+deltaX-sourceMarginX)/scaleSource,
|
||||
(iter->second.y*scaleLoop+loopMarginY+deltaY-sourceMarginY)/scaleSource,
|
||||
Qt::cyan);
|
||||
|
||||
_ui->imageView_loopClosure->addLine(
|
||||
iter->first.x-deltaX,
|
||||
iter->first.y-deltaY,
|
||||
(iter->first.x*scaleSource+sourceMarginX-deltaX-loopMarginX)/scaleLoop,
|
||||
(iter->first.y*scaleSource+sourceMarginY-deltaY-loopMarginY)/scaleLoop,
|
||||
iter->second.x,
|
||||
iter->second.y,
|
||||
Qt::cyan);
|
||||
|
||||
Reference in New Issue
Block a user