mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 17:40:23 +08:00
Added Depth information to ImageView's keypoint items
This commit is contained in:
@@ -1446,7 +1446,7 @@ void DatabaseViewer::update(int value,
|
||||
|
||||
if(data.getWords().size())
|
||||
{
|
||||
view->setFeatures(data.getWords());
|
||||
view->setFeatures(data.getWords(), data.getDepthRaw().type() == CV_8UC1?cv::Mat():data.getDepthRaw(), Qt::yellow);
|
||||
}
|
||||
|
||||
Transform odomPose;
|
||||
@@ -2934,8 +2934,8 @@ bool DatabaseViewer::addConstraint(int from, int to, bool silent, bool updateGra
|
||||
|
||||
if(!silent)
|
||||
{
|
||||
ui_->graphicsView_A->setFeatures(tmpMemory.getSignature(from)->getWords());
|
||||
ui_->graphicsView_B->setFeatures(tmpMemory.getSignature(to)->getWords());
|
||||
ui_->graphicsView_A->setFeatures(tmpMemory.getSignature(from)->getWords(), dataFrom.depth());
|
||||
ui_->graphicsView_B->setFeatures(tmpMemory.getSignature(to)->getWords(), dataTo.depth());
|
||||
updateWordsMatching();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <QVBoxLayout>
|
||||
#include "rtabmap/utilite/ULogger.h"
|
||||
#include "rtabmap/gui/KeypointItem.h"
|
||||
#include "rtabmap/core/util3d.h"
|
||||
|
||||
namespace rtabmap {
|
||||
|
||||
@@ -543,14 +544,14 @@ void ImageView::updateOpacity()
|
||||
}
|
||||
}
|
||||
|
||||
void ImageView::setFeatures(const std::multimap<int, cv::KeyPoint> & refWords, const QColor & color)
|
||||
void ImageView::setFeatures(const std::multimap<int, cv::KeyPoint> & refWords, const cv::Mat & depth, const QColor & color)
|
||||
{
|
||||
qDeleteAll(_features);
|
||||
_features.clear();
|
||||
|
||||
for(std::multimap<int, cv::KeyPoint>::const_iterator iter = refWords.begin(); iter != refWords.end(); ++iter )
|
||||
{
|
||||
addFeature(iter->first, iter->second, color);
|
||||
addFeature(iter->first, iter->second, depth.empty()?0:util3d::getDepth(depth, iter->second.pt.x, iter->second.pt.y, false), color);
|
||||
}
|
||||
|
||||
if(!_graphicsView->isVisible())
|
||||
@@ -559,14 +560,14 @@ void ImageView::setFeatures(const std::multimap<int, cv::KeyPoint> & refWords, c
|
||||
}
|
||||
}
|
||||
|
||||
void ImageView::setFeatures(const std::vector<cv::KeyPoint> & features, const QColor & color)
|
||||
void ImageView::setFeatures(const std::vector<cv::KeyPoint> & features, const cv::Mat & depth, const QColor & color)
|
||||
{
|
||||
qDeleteAll(_features);
|
||||
_features.clear();
|
||||
|
||||
for(unsigned int i = 0; i< features.size(); ++i )
|
||||
{
|
||||
addFeature(i, features[i], color);
|
||||
addFeature(i, features[i], depth.empty()?0:util3d::getDepth(depth, features[i].pt.x, features[i].pt.y, false), color);
|
||||
}
|
||||
|
||||
if(!_graphicsView->isVisible())
|
||||
@@ -575,10 +576,10 @@ void ImageView::setFeatures(const std::vector<cv::KeyPoint> & features, const QC
|
||||
}
|
||||
}
|
||||
|
||||
void ImageView::addFeature(int id, const cv::KeyPoint & kpt, QColor color)
|
||||
void ImageView::addFeature(int id, const cv::KeyPoint & kpt, float depth, QColor color)
|
||||
{
|
||||
color.setAlpha(this->getAlpha());
|
||||
rtabmap::KeypointItem * item = new rtabmap::KeypointItem(id, kpt, color);
|
||||
rtabmap::KeypointItem * item = new rtabmap::KeypointItem(id, kpt, depth, color);
|
||||
_features.insert(id, item);
|
||||
item->setVisible(isFeaturesShown());
|
||||
item->setZValue(1);
|
||||
|
||||
@@ -34,11 +34,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
namespace rtabmap {
|
||||
|
||||
KeypointItem::KeypointItem(int id, const cv::KeyPoint & kpt, const QColor & color, QGraphicsItem * parent) :
|
||||
KeypointItem::KeypointItem(int id, const cv::KeyPoint & kpt, float depth, const QColor & color, QGraphicsItem * parent) :
|
||||
QGraphicsEllipseItem(kpt.pt.x-(kpt.size==0?3.0f:kpt.size)/2.0f, kpt.pt.y-(kpt.size==0?3.0f:kpt.size)/2.0f, kpt.size==0?3.0f:kpt.size, kpt.size==0?3.0f:kpt.size, parent),
|
||||
_id(id),
|
||||
_kpt(kpt),
|
||||
_placeHolder(0)
|
||||
_placeHolder(0),
|
||||
_depth(depth)
|
||||
{
|
||||
this->setColor(color);
|
||||
this->setAcceptHoverEvents(true);
|
||||
@@ -69,12 +70,25 @@ void KeypointItem::showDescription()
|
||||
_placeHolder->setBrush(QBrush(QColor ( 0, 0, 0, 170 ))); // Black transparent background
|
||||
QGraphicsTextItem * text = new QGraphicsTextItem(_placeHolder);
|
||||
text->setDefaultTextColor(this->pen().color().rgb());
|
||||
text->setPlainText(QString( "Id = %1\n"
|
||||
"Dir = %3\n"
|
||||
"Hessian = %4\n"
|
||||
"X = %5\n"
|
||||
"Y = %6\n"
|
||||
"Size = %7").arg(_id).arg(_kpt.angle).arg(_kpt.response).arg(_kpt.pt.x).arg(_kpt.pt.y).arg(_kpt.size));
|
||||
if(_depth <= 0)
|
||||
{
|
||||
text->setPlainText(QString( "Id = %1\n"
|
||||
"Dir = %3\n"
|
||||
"Hessian = %4\n"
|
||||
"X = %5\n"
|
||||
"Y = %6\n"
|
||||
"Size = %7").arg(_id).arg(_kpt.angle).arg(_kpt.response).arg(_kpt.pt.x).arg(_kpt.pt.y).arg(_kpt.size));
|
||||
}
|
||||
else
|
||||
{
|
||||
text->setPlainText(QString( "Id = %1\n"
|
||||
"Dir = %3\n"
|
||||
"Hessian = %4\n"
|
||||
"X = %5\n"
|
||||
"Y = %6\n"
|
||||
"Size = %7\n"
|
||||
"Depth = %8 m").arg(_id).arg(_kpt.angle).arg(_kpt.response).arg(_kpt.pt.x).arg(_kpt.pt.y).arg(_kpt.size).arg(_depth));
|
||||
}
|
||||
_placeHolder->setRect(text->boundingRect());
|
||||
}
|
||||
|
||||
|
||||
@@ -845,13 +845,13 @@ void MainWindow::processOdometry(const rtabmap::SensorData & data, const rtabmap
|
||||
{
|
||||
if(info.type == 0)
|
||||
{
|
||||
_ui->imageView_odometry->setFeatures(info.words, Qt::yellow);
|
||||
_ui->imageView_odometry->setFeatures(info.words, data.depth(), Qt::yellow);
|
||||
}
|
||||
else if(info.type == 1)
|
||||
{
|
||||
std::vector<cv::KeyPoint> kpts;
|
||||
cv::KeyPoint::convert(info.refCorners, kpts);
|
||||
_ui->imageView_odometry->setFeatures(kpts, Qt::red);
|
||||
_ui->imageView_odometry->setFeatures(kpts, data.depth(), Qt::red);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2187,7 +2187,7 @@ void MainWindow::drawKeypoints(const std::multimap<int, cv::KeyPoint> & refWords
|
||||
// GREEN = NEW
|
||||
color = Qt::green;
|
||||
}
|
||||
_ui->imageView_source->addFeature(iter->first, iter->second, color);
|
||||
_ui->imageView_source->addFeature(iter->first, iter->second, 0, color);
|
||||
}
|
||||
ULOGGER_DEBUG("source time = %f s", timer.ticks());
|
||||
|
||||
@@ -2225,7 +2225,7 @@ void MainWindow::drawKeypoints(const std::multimap<int, cv::KeyPoint> & refWords
|
||||
// GREEN = NEW
|
||||
color = Qt::green;
|
||||
}
|
||||
_ui->imageView_loopClosure->addFeature(iter->first, iter->second, color);
|
||||
_ui->imageView_loopClosure->addFeature(iter->first, iter->second, 0, color);
|
||||
}
|
||||
|
||||
ULOGGER_DEBUG("loop closure time = %f s", timer.ticks());
|
||||
|
||||
@@ -270,13 +270,13 @@ void OdometryViewer::processData(const rtabmap::SensorData & data, const rtabmap
|
||||
{
|
||||
if(info.type == 0)
|
||||
{
|
||||
imageView_->setFeatures(info.words, Qt::yellow);
|
||||
imageView_->setFeatures(info.words, data.depth(), Qt::yellow);
|
||||
}
|
||||
else if(info.type == 1)
|
||||
{
|
||||
std::vector<cv::KeyPoint> kpts;
|
||||
cv::KeyPoint::convert(info.refCorners, kpts);
|
||||
imageView_->setFeatures(kpts, Qt::red);
|
||||
imageView_->setFeatures(kpts, data.depth(), Qt::red);
|
||||
}
|
||||
|
||||
imageView_->clearLines();
|
||||
|
||||
Reference in New Issue
Block a user