mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 17:40:23 +08:00
Updated CameraFreenect2 with latest freenect2 library (commit cdeb07917c)
This commit is contained in:
@@ -29,6 +29,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <rtabmap/core/CameraEvent.h>
|
||||
#include <rtabmap/core/util3d.h>
|
||||
#include <rtabmap/core/util2d.h>
|
||||
#include <rtabmap/gui/ImageView.h>
|
||||
#include <rtabmap/gui/CloudViewer.h>
|
||||
#include <rtabmap/utilite/UCv2Qt.h>
|
||||
@@ -36,6 +37,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <QtCore/QMetaType>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QSpinBox>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
namespace rtabmap {
|
||||
@@ -45,7 +48,8 @@ CameraViewer::CameraViewer(QWidget * parent) :
|
||||
QDialog(parent),
|
||||
imageView_(new ImageView(this)),
|
||||
cloudView_(new CloudViewer(this)),
|
||||
processingImages_(false)
|
||||
processingImages_(false),
|
||||
validDecimationValue_(1)
|
||||
{
|
||||
qRegisterMetaType<rtabmap::SensorData>("rtabmap::SensorData");
|
||||
|
||||
@@ -56,15 +60,27 @@ CameraViewer::CameraViewer(QWidget * parent) :
|
||||
layout->addWidget(imageView_,1);
|
||||
layout->addWidget(cloudView_,1);
|
||||
|
||||
QLabel * decimationLabel = new QLabel("Decimation", this);
|
||||
decimationSpin_ = new QSpinBox(this);
|
||||
decimationSpin_->setMinimum(1);
|
||||
decimationSpin_->setMaximum(16);
|
||||
decimationSpin_->setValue(1);
|
||||
|
||||
QDialogButtonBox * buttonBox = new QDialogButtonBox(this);
|
||||
buttonBox->setStandardButtons(QDialogButtonBox::Close);
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
|
||||
QHBoxLayout * layout2 = new QHBoxLayout();
|
||||
layout2->addWidget(decimationLabel);
|
||||
layout2->addWidget(decimationSpin_);
|
||||
layout2->addStretch(1);
|
||||
layout2->addWidget(buttonBox);
|
||||
|
||||
QVBoxLayout * vlayout = new QVBoxLayout(this);
|
||||
vlayout->setMargin(0);
|
||||
vlayout->setSpacing(0);
|
||||
vlayout->addLayout(layout, 1);
|
||||
vlayout->addWidget(buttonBox);
|
||||
vlayout->addLayout(layout2);
|
||||
|
||||
this->setLayout(vlayout);
|
||||
}
|
||||
@@ -76,26 +92,48 @@ CameraViewer::~CameraViewer()
|
||||
|
||||
void CameraViewer::showImage(const rtabmap::SensorData & data)
|
||||
{
|
||||
if(!data.imageRaw().empty() || !data.depthOrRightRaw().empty())
|
||||
{
|
||||
if(data.imageRaw().cols % decimationSpin_->value() == 0 &&
|
||||
data.imageRaw().rows % decimationSpin_->value() == 0 &&
|
||||
data.depthOrRightRaw().cols % decimationSpin_->value() == 0 &&
|
||||
data.depthOrRightRaw().rows % decimationSpin_->value() == 0)
|
||||
{
|
||||
validDecimationValue_ = decimationSpin_->value();
|
||||
}
|
||||
else
|
||||
{
|
||||
UWARN("Decimation (%d) must be a denominator of the width and height of "
|
||||
"the image (color=%d/%d depth=%d/%d). Using last valid decimation value (%d).",
|
||||
decimationSpin_->value(),
|
||||
data.imageRaw().cols,
|
||||
data.imageRaw().rows,
|
||||
data.depthOrRightRaw().cols,
|
||||
data.depthOrRightRaw().rows,
|
||||
validDecimationValue_);
|
||||
}
|
||||
}
|
||||
|
||||
processingImages_ = true;
|
||||
if(!data.imageRaw().empty())
|
||||
{
|
||||
imageView_->setImage(uCvMat2QImage(data.imageRaw()));
|
||||
imageView_->setImage(uCvMat2QImage(util2d::decimate(data.imageRaw(), validDecimationValue_)));
|
||||
}
|
||||
if(!data.depthOrRightRaw().empty())
|
||||
{
|
||||
imageView_->setImageDepth(uCvMat2QImage(data.depthOrRightRaw()));
|
||||
imageView_->setImageDepth(uCvMat2QImage(util2d::decimate(data.depthOrRightRaw(), validDecimationValue_)));
|
||||
}
|
||||
if((data.stereoCameraModel().isValid() || (data.cameraModels().size() && data.cameraModels().at(0).isValid())))
|
||||
{
|
||||
if(!data.imageRaw().empty() && !data.depthOrRightRaw().empty())
|
||||
{
|
||||
cloudView_->addOrUpdateCloud("cloud", util3d::cloudRGBFromSensorData(data));
|
||||
cloudView_->addOrUpdateCloud("cloud", util3d::cloudRGBFromSensorData(data, validDecimationValue_));
|
||||
cloudView_->setVisible(true);
|
||||
cloudView_->update();
|
||||
}
|
||||
else if(!data.depthOrRightRaw().empty())
|
||||
{
|
||||
cloudView_->addOrUpdateCloud("cloud", util3d::cloudFromSensorData(data));
|
||||
cloudView_->addOrUpdateCloud("cloud", util3d::cloudFromSensorData(data, validDecimationValue_));
|
||||
cloudView_->setVisible(true);
|
||||
cloudView_->update();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user