mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-04 08:47:45 +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 saveSettings(QSettings & settings, const QString & group = "") const;
|
||||||
void loadSettings(QSettings & settings, const QString & group = "");
|
void loadSettings(QSettings & settings, const QString & group = "");
|
||||||
|
|
||||||
|
QRectF sceneRect() const;
|
||||||
bool isImageShown() const;
|
bool isImageShown() const;
|
||||||
bool isImageDepthShown() const;
|
bool isImageDepthShown() const;
|
||||||
bool isFeaturesShown() 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
|
bool ImageView::isImageShown() const
|
||||||
{
|
{
|
||||||
return _showImage->isChecked();
|
return _showImage->isChecked();
|
||||||
@@ -770,6 +775,9 @@ void ImageView::clear()
|
|||||||
}
|
}
|
||||||
_imageDepth = QPixmap();
|
_imageDepth = QPixmap();
|
||||||
|
|
||||||
|
_graphicsView->scene()->setSceneRect(QRectF());
|
||||||
|
_graphicsView->setScene(_graphicsView->scene());
|
||||||
|
|
||||||
if(!_graphicsView->isVisible())
|
if(!_graphicsView->isVisible())
|
||||||
{
|
{
|
||||||
this->update();
|
this->update();
|
||||||
|
|||||||
+22
-16
@@ -1099,12 +1099,6 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
|
|||||||
{
|
{
|
||||||
_ui->imageView_loopClosure->setImageDepth(lcDepth);
|
_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());
|
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...
|
// Draw lines between corresponding features...
|
||||||
float scale = _ui->imageView_source->viewScale();
|
float scaleSource = _ui->imageView_source->viewScale();
|
||||||
UDEBUG("scale=%f", scale);
|
float scaleLoop = _ui->imageView_loopClosure->viewScale();
|
||||||
float deltaX = _ui->imageView_source->width()/scale;
|
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;
|
float deltaY = 0;
|
||||||
|
|
||||||
if(_preferencesDialog->isVerticalLayoutUsed())
|
if(_preferencesDialog->isVerticalLayoutUsed())
|
||||||
{
|
{
|
||||||
deltaX = 0;
|
deltaY = _ui->label_matchId->height() + _ui->imageView_source->height();
|
||||||
deltaY = _ui->imageView_source->height()/scale;
|
|
||||||
deltaY += _ui->label_matchId->height()/scale;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
deltaX = _ui->imageView_source->width();
|
||||||
|
}
|
||||||
|
|
||||||
for(QList<QPair<cv::Point2f, cv::Point2f> >::iterator iter = uniqueCorrespondences.begin();
|
for(QList<QPair<cv::Point2f, cv::Point2f> >::iterator iter = uniqueCorrespondences.begin();
|
||||||
iter!=uniqueCorrespondences.end();
|
iter!=uniqueCorrespondences.end();
|
||||||
++iter)
|
++iter)
|
||||||
{
|
{
|
||||||
|
|
||||||
_ui->imageView_source->addLine(
|
_ui->imageView_source->addLine(
|
||||||
iter->first.x,
|
iter->first.x,
|
||||||
iter->first.y,
|
iter->first.y,
|
||||||
iter->second.x+deltaX,
|
(iter->second.x*scaleLoop+loopMarginX+deltaX-sourceMarginX)/scaleSource,
|
||||||
iter->second.y+deltaY,
|
(iter->second.y*scaleLoop+loopMarginY+deltaY-sourceMarginY)/scaleSource,
|
||||||
Qt::cyan);
|
Qt::cyan);
|
||||||
|
|
||||||
_ui->imageView_loopClosure->addLine(
|
_ui->imageView_loopClosure->addLine(
|
||||||
iter->first.x-deltaX,
|
(iter->first.x*scaleSource+sourceMarginX-deltaX-loopMarginX)/scaleLoop,
|
||||||
iter->first.y-deltaY,
|
(iter->first.y*scaleSource+sourceMarginY-deltaY-loopMarginY)/scaleLoop,
|
||||||
iter->second.x,
|
iter->second.x,
|
||||||
iter->second.y,
|
iter->second.y,
|
||||||
Qt::cyan);
|
Qt::cyan);
|
||||||
|
|||||||
Reference in New Issue
Block a user