Refactoring CameraRGBD class (now including OpenNI, OpenNI2, OpenNI from OpenCV and Freenect)

Added tool to test RGB-D camera: rtabmap-rgbd_camera
Fixed Freenect corrupted depth image (after some time)

git-svn-id: http://rtabmap.googlecode.com/svn/trunk/rtabmap@1366 f169173b-cf89-36c8-b27e-44dbe73f0c83
This commit is contained in:
matlabbe
2014-06-15 03:31:35 +00:00
parent 81b3b49f97
commit c18f1501d4
25 changed files with 1248 additions and 1579 deletions

View File

@@ -205,8 +205,6 @@ private:
State _state;
rtabmap::CameraThread * _camera;
rtabmap::DBReader * _dbReader;
rtabmap::CameraOpenni * _cameraOpenni;
rtabmap::CameraFreenect * _cameraOpenKinect;
rtabmap::OdometryThread * _odomThread;
SrcType _srcType;

View File

@@ -49,8 +49,6 @@ class QDoubleSpinBox;
namespace rtabmap {
class CameraOpenni;
class CameraFreenect;
class OdometryThread;
class CameraThread;
class Signature;
@@ -151,12 +149,10 @@ public:
bool isSourceDatabaseUsed() const;
bool isSourceOpenniUsed() const;
OdomType getOdometryType() const;
bool getGeneralAutoRestart() const;
int getSourceImageType() const;
QString getSourceImageTypeStr() const;
int getSourceWidth() const;
int getSourceHeight() const;
int getFramesDropped() const;
QString getSourceImagesPath() const; //Images group
QString getSourceImagesSuffix() const; //Images group
int getSourceImagesSuffixIndex() const; //Images group
@@ -196,7 +192,6 @@ public slots:
void setInputRate(double value);
void setDetectionRate(double value);
void setHardThr(int value);
void setAutoRestart(bool value);
void setTimeLimit(float value);
void setSLAMMode(bool enabled);
void selectSourceImage(Src src = kSrcUndef);
@@ -279,9 +274,7 @@ private:
QProgressDialog * _progressDialog;
//Odometry test
CameraOpenni * _odomCameraOpenNI;
CameraFreenect * _odomCameraFreenect;
CameraThread * _odomCameraOpenNICv;
CameraThread * _cameraThread;
OdometryThread * _odomThread;
QVector<QCheckBox*> _3dRenderingShowClouds;

View File

@@ -65,8 +65,7 @@
#include <QtGui/QInputDialog>
//RGB-D stuff
#include "rtabmap/core/CameraOpenni.h"
#include "rtabmap/core/CameraFreenect.h"
#include "rtabmap/core/CameraRGBD.h"
#include "rtabmap/core/Odometry.h"
#include "rtabmap/core/OdometryEvent.h"
#include "rtabmap/core/util3d.h"
@@ -97,8 +96,6 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
_state(kIdle),
_camera(0),
_dbReader(0),
_cameraOpenni(0),
_cameraOpenKinect(0),
_odomThread(0),
_srcType(kSrcUndefined),
_preferencesDialog(0),
@@ -291,8 +288,8 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
_ui->actionFreenect->setEnabled(CameraFreenect::available());
connect(_ui->actionOpenNI_CV, SIGNAL(triggered()), this, SLOT(selectOpenniCv()));
connect(_ui->actionOpenNI_CV_ASUS, SIGNAL(triggered()), this, SLOT(selectOpenniCvAsus()));
_ui->actionOpenNI_CV->setEnabled(CameraRGBD::available());
_ui->actionOpenNI_CV_ASUS->setEnabled(CameraRGBD::available());
_ui->actionOpenNI_CV->setEnabled(CameraOpenNICV::available());
_ui->actionOpenNI_CV_ASUS->setEnabled(CameraOpenNICV::available());
connect(_ui->actionOpenNI2, SIGNAL(triggered()), this, SLOT(selectOpenni2()));
_ui->actionOpenNI2->setEnabled(CameraOpenNI2::available());
@@ -420,18 +417,6 @@ void MainWindow::closeEvent(QCloseEvent* event)
delete _dbReader;
_dbReader = 0;
}
if(_cameraOpenni)
{
UERROR("CameraOpenni must be already deleted here!");
delete _cameraOpenni;
_cameraOpenni = 0;
}
if(_cameraOpenKinect)
{
UERROR("CameraOpenKinect must be already deleted here!");
delete _cameraOpenKinect;
_cameraOpenKinect = 0;
}
if(_odomThread)
{
UERROR("OdomThread must be already deleted here!");
@@ -1530,23 +1515,12 @@ void MainWindow::applyPrefSettings(PreferencesDialog::PANEL_FLAGS flags)
if(_camera)
{
_camera->getCamera()->setImageRate(_preferencesDialog->getGeneralInputRate());
_camera->setAutoRestart(_preferencesDialog->getGeneralAutoRestart());
_camera->setImageRate(_preferencesDialog->getGeneralInputRate());
}
if(_dbReader)
{
_dbReader->setFrameRate(_preferencesDialog->getGeneralInputRate());
}
if(_cameraOpenni)
{
_cameraOpenni->setFrameRate(_preferencesDialog->getGeneralInputRate());
}
if(_cameraOpenKinect)
{
_cameraOpenKinect->setFrameRate(_preferencesDialog->getGeneralInputRate());
}
}
if(flags & PreferencesDialog::kPanelGeneral)
@@ -1965,24 +1939,6 @@ void MainWindow::startDetection()
emit stateChanged(kIdle);
return;
}
if(_cameraOpenni != 0)
{
QMessageBox::warning(this,
tr("RTAB-Map"),
tr("An Openni camera is running, stop it first."));
UWARN("_cameraOpenni is not null... it must be stopped first");
emit stateChanged(kIdle);
return;
}
if(_cameraOpenKinect != 0)
{
QMessageBox::warning(this,
tr("RTAB-Map"),
tr("A Freenect camera is running, stop it first."));
UWARN("_cameraOpenKinect is not null... it must be stopped first");
emit stateChanged(kIdle);
return;
}
// Adjust pre-requirements
if( !_preferencesDialog->isSourceImageUsed() &&
@@ -2029,112 +1985,61 @@ void MainWindow::startDetection()
_odomThread->start();
}
if(_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcFreenect)
CameraRGBD * camera = 0;
if(_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_PCL)
{
_cameraOpenKinect = new CameraFreenect(
_preferencesDialog->getSourceOpenniDevice().isEmpty()?0:atoi(_preferencesDialog->getSourceOpenniDevice().toStdString().c_str()),
_preferencesDialog->getGeneralInputRate(),
_preferencesDialog->getSourceOpenniLocalTransform());
if(!_cameraOpenKinect->init())
{
ULOGGER_WARN("init CameraFreenect failed... ");
if(!_cameraOpenKinect->available())
{
QMessageBox::warning(this,
tr("RTAB-Map"),
tr("Freenect camera unavailable! RTAB-Map is not built with Freenect support (libfreenect)."));
}
else
{
QMessageBox::warning(this,
tr("RTAB-Map"),
tr("Freenect camera initialization failed!"));
}
emit stateChanged(kIdle);
delete _cameraOpenKinect;
_cameraOpenKinect = 0;
if(_odomThread)
{
delete _odomThread;
_odomThread = 0;
}
return;
}
if(_odomThread)
{
UEventsManager::createPipe(_cameraOpenKinect, _odomThread, "CameraEvent");
}
camera = new CameraOpenni(
_preferencesDialog->getSourceOpenniDevice().toStdString(),
_preferencesDialog->getGeneralInputRate(),
_preferencesDialog->getSourceOpenniLocalTransform());
}
else if(_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI2)
{
camera = new CameraOpenNI2(
_preferencesDialog->getGeneralInputRate(),
_preferencesDialog->getSourceOpenniLocalTransform());
}
else if(_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcFreenect)
{
camera = new CameraFreenect(
_preferencesDialog->getSourceOpenniDevice().isEmpty()?0:atoi(_preferencesDialog->getSourceOpenniDevice().toStdString().c_str()),
_preferencesDialog->getGeneralInputRate(),
_preferencesDialog->getSourceOpenniLocalTransform());
}
else if(_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_CV ||
_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_CV_ASUS ||
_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI2)
_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_CV_ASUS)
{
Camera * camera = 0;
if(_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI2)
{
camera = new CameraOpenNI2(
_preferencesDialog->getGeneralInputRate());
}
else
{
camera = new CameraRGBD(
_preferencesDialog->getGeneralInputRate(),
_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_CV_ASUS);
}
camera->setLocalTransform(_preferencesDialog->getSourceOpenniLocalTransform());
if(!camera->init())
{
ULOGGER_WARN("init camera failed... ");
QMessageBox::warning(this,
tr("RTAB-Map"),
tr("Camera initialization failed..."));
emit stateChanged(kIdle);
delete camera;
camera = 0;
if(_odomThread)
{
delete _odomThread;
_odomThread = 0;
}
return;
}
_camera = new CameraThread(camera);
if(_odomThread)
{
UEventsManager::createPipe(_camera, _odomThread, "CameraEvent");
}
camera = new CameraOpenNICV(
_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_CV_ASUS,
_preferencesDialog->getGeneralInputRate(),
_preferencesDialog->getSourceOpenniLocalTransform());
}
else
{
_cameraOpenni = new CameraOpenni(
_preferencesDialog->getSourceOpenniDevice().toStdString(),
_preferencesDialog->getGeneralInputRate(),
_preferencesDialog->getSourceOpenniLocalTransform());
UFATAL("RGBD Source type undefined!");
}
if(!_cameraOpenni->init())
{
ULOGGER_WARN("init CameraOpenni failed... ");
QMessageBox::warning(this,
tr("RTAB-Map"),
tr("Openni camera initialization failed!"));
emit stateChanged(kIdle);
delete _cameraOpenni;
_cameraOpenni = 0;
if(_odomThread)
{
delete _odomThread;
_odomThread = 0;
}
return;
}
if(!camera->init())
{
ULOGGER_WARN("init camera failed... ");
QMessageBox::warning(this,
tr("RTAB-Map"),
tr("Camera initialization failed..."));
emit stateChanged(kIdle);
delete camera;
camera = 0;
if(_odomThread)
{
UEventsManager::createPipe(_cameraOpenni, _odomThread, "CameraEvent");
delete _odomThread;
_odomThread = 0;
}
return;
}
_camera = new CameraThread(camera);
if(_odomThread)
{
UEventsManager::createPipe(_camera, _odomThread, "CameraEvent");
}
}
else if(_preferencesDialog->isSourceDatabaseUsed())
@@ -2211,9 +2116,7 @@ void MainWindow::startDetection()
_preferencesDialog->getSourceImagesRefreshDir(),
_preferencesDialog->getGeneralInputRate(),
_preferencesDialog->getSourceWidth(),
_preferencesDialog->getSourceHeight(),
_preferencesDialog->getFramesDropped()
);
_preferencesDialog->getSourceHeight());
}
else if(sourceType == 2)
{
@@ -2221,8 +2124,7 @@ void MainWindow::startDetection()
_preferencesDialog->getSourceVideoPath().toStdString(),
_preferencesDialog->getGeneralInputRate(),
_preferencesDialog->getSourceWidth(),
_preferencesDialog->getSourceHeight(),
_preferencesDialog->getFramesDropped());
_preferencesDialog->getSourceHeight());
}
else //if(sourceType == 0)
{
@@ -2230,8 +2132,7 @@ void MainWindow::startDetection()
_preferencesDialog->getSourceUsbDeviceId(),
_preferencesDialog->getGeneralInputRate(),
_preferencesDialog->getSourceWidth(),
_preferencesDialog->getSourceHeight(),
_preferencesDialog->getFramesDropped());
_preferencesDialog->getSourceHeight());
}
if(!camera->init())
@@ -2274,7 +2175,7 @@ void MainWindow::startDetection()
// Could not be in the main thread here! (see handleEvents())
void MainWindow::pauseDetection()
{
if(_camera || _dbReader || _cameraOpenni || _cameraOpenKinect)
if(_camera || _dbReader)
{
if(_state == kPaused && (QApplication::keyboardModifiers() & Qt::ShiftModifier))
{
@@ -2308,16 +2209,14 @@ void MainWindow::pauseDetection()
void MainWindow::stopDetection()
{
if(_state == kIdle || (!_camera && !_dbReader && !_cameraOpenni && !_cameraOpenKinect))
if(_state == kIdle || (!_camera && !_dbReader))
{
return;
}
if(_state == kDetecting &&
( (_camera && _camera->isRunning()) ||
(_dbReader && _dbReader->isRunning()) ||
(_cameraOpenni && _cameraOpenni->isRunning()) ||
(_cameraOpenKinect && _cameraOpenKinect->isRunning()) ) )
(_dbReader && _dbReader->isRunning()) ) )
{
QMessageBox::StandardButton button = QMessageBox::question(this, tr("Stopping process..."), tr("Are you sure you want to stop the process?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
@@ -2339,16 +2238,6 @@ void MainWindow::stopDetection()
_dbReader->join(true);
}
if(_cameraOpenni)
{
_cameraOpenni->kill();
}
if(_cameraOpenKinect)
{
_cameraOpenKinect->join(true);
}
if(_odomThread)
{
_ui->actionReset_Odometry->setEnabled(false);
@@ -2366,16 +2255,6 @@ void MainWindow::stopDetection()
delete _dbReader;
_dbReader = 0;
}
if(_cameraOpenni)
{
delete _cameraOpenni;
_cameraOpenni = 0;
}
if(_cameraOpenKinect)
{
delete _cameraOpenKinect;
_cameraOpenKinect = 0;
}
if(_odomThread)
{
delete _odomThread;
@@ -3815,16 +3694,6 @@ void MainWindow::changeState(MainWindow::State newState)
{
_dbReader->start();
}
if(_cameraOpenni)
{
_cameraOpenni->start();
}
if(_cameraOpenKinect)
{
_cameraOpenKinect->start();
}
break;
case kPaused:
@@ -3853,16 +3722,6 @@ void MainWindow::changeState(MainWindow::State newState)
{
_dbReader->start();
}
if(_cameraOpenni)
{
_cameraOpenni->start();
}
if(_cameraOpenKinect)
{
_cameraOpenKinect->start();
}
}
else if(_state == kDetecting)
{
@@ -3889,16 +3748,6 @@ void MainWindow::changeState(MainWindow::State newState)
{
_dbReader->join(true);
}
if(_cameraOpenni)
{
_cameraOpenni->pause();
}
if(_cameraOpenKinect)
{
_cameraOpenKinect->join(true);
}
}
break;
case kMonitoring:

View File

@@ -49,7 +49,7 @@ OdometryViewer::OdometryViewer(int maxClouds, int decimation, float voxelSize, i
void OdometryViewer::processData()
{
rtabmap::Image data;
int quality;
int quality = 0;
dataMutex_.lock();
if(data_.size())
{

View File

@@ -38,8 +38,7 @@
#include "rtabmap/core/Rtabmap.h"
#include "rtabmap/core/Parameters.h"
#include "rtabmap/core/Odometry.h"
#include "rtabmap/core/CameraOpenni.h"
#include "rtabmap/core/CameraFreenect.h"
#include "rtabmap/core/CameraRGBD.h"
#include "rtabmap/core/CameraThread.h"
#include "rtabmap/core/Camera.h"
#include "rtabmap/core/Memory.h"
@@ -64,9 +63,7 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
_ui(0),
_indexModel(0),
_initialized(false),
_odomCameraOpenNI(0),
_odomCameraFreenect(0),
_odomCameraOpenNICv(0),
_cameraThread(0),
_odomThread(0)
{
ULOGGER_DEBUG("");
@@ -210,12 +207,10 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
_ui->stackedWidget_image->setCurrentIndex(_ui->source_comboBox_image_type->currentIndex());
connect(_ui->source_comboBox_image_type, SIGNAL(currentIndexChanged(int)), _ui->stackedWidget_image, SLOT(setCurrentIndex(int)));
connect(_ui->source_comboBox_image_type, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->general_checkBox_autoRestart, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
//usbDevice group
connect(_ui->source_usbDevice_spinBox_id, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->source_spinBox_imgWidth, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->source_spinBox_imgheight, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->source_spinBox_framesDropped, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
//images group
connect(_ui->source_images_toolButton_selectSource, SIGNAL(clicked()), this, SLOT(selectSourceImage()));
connect(_ui->source_images_lineEdit_path, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel()));
@@ -238,8 +233,8 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
_ui->radioButton_freenect->setEnabled(CameraFreenect::available());
connect(_ui->radioButton_opennicv, SIGNAL(toggled(bool)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->radioButton_opennicvasus, SIGNAL(toggled(bool)), this, SLOT(makeObsoleteSourcePanel()));
_ui->radioButton_opennicv->setEnabled(CameraRGBD::available());
_ui->radioButton_opennicvasus->setEnabled(CameraRGBD::available());
_ui->radioButton_opennicv->setEnabled(CameraOpenNICV::available());
_ui->radioButton_opennicvasus->setEnabled(CameraOpenNICV::available());
connect(_ui->radioButton_openni2, SIGNAL(toggled(bool)), this, SLOT(makeObsoleteSourcePanel()));
_ui->radioButton_openni2->setEnabled(CameraOpenNI2::available());
connect(_ui->lineEdit_openniDevice, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel()));
@@ -765,8 +760,6 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
_ui->groupBox_sourceImage->setChecked(false);
_ui->source_spinBox_imgWidth->setValue(0);
_ui->source_spinBox_imgheight->setValue(0);
_ui->source_spinBox_framesDropped->setValue(0);
_ui->general_checkBox_autoRestart->setChecked(false);
_ui->source_images_spinBox_startPos->setValue(1);
_ui->source_images_refreshDir->setChecked(false);
@@ -987,11 +980,9 @@ void PreferencesDialog::readCameraSettings(const QString & filePath)
settings.beginGroup("Camera");
_ui->groupBox_sourceImage->setChecked(settings.value("imageUsed", _ui->groupBox_sourceImage->isChecked()).toBool());
_ui->general_doubleSpinBox_imgRate->setValue(settings.value("imgRate", _ui->general_doubleSpinBox_imgRate->value()).toDouble());
_ui->general_checkBox_autoRestart->setChecked(settings.value("autoRestart", _ui->general_checkBox_autoRestart->isChecked()).toBool());
_ui->source_comboBox_image_type->setCurrentIndex(settings.value("type", _ui->source_comboBox_image_type->currentIndex()).toInt());
_ui->source_spinBox_imgWidth->setValue(settings.value("imgWidth",_ui->source_spinBox_imgWidth->value()).toInt());
_ui->source_spinBox_imgheight->setValue(settings.value("imgHeight",_ui->source_spinBox_imgheight->value()).toInt());
_ui->source_spinBox_framesDropped->setValue(settings.value("framesDropped",_ui->source_spinBox_framesDropped->value()).toInt());
//usbDevice group
settings.beginGroup("usbDevice");
_ui->source_usbDevice_spinBox_id->setValue(settings.value("id",_ui->source_usbDevice_spinBox_id->value()).toInt());
@@ -1196,11 +1187,9 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath)
settings.beginGroup("Camera");
settings.setValue("imageUsed", _ui->groupBox_sourceImage->isChecked());
settings.setValue("imgRate", _ui->general_doubleSpinBox_imgRate->value());
settings.setValue("autoRestart", _ui->general_checkBox_autoRestart->isChecked());
settings.setValue("type", _ui->source_comboBox_image_type->currentIndex());
settings.setValue("imgWidth", _ui->source_spinBox_imgWidth->value());
settings.setValue("imgHeight", _ui->source_spinBox_imgheight->value());
settings.setValue("framesDropped", _ui->source_spinBox_framesDropped->value());
//usbDevice group
settings.beginGroup("usbDevice");
settings.setValue("id", _ui->source_usbDevice_spinBox_id->value());
@@ -2467,10 +2456,6 @@ PreferencesDialog::OdomType PreferencesDialog::getOdometryType() const
return kOdomICP;
}
bool PreferencesDialog::getGeneralAutoRestart() const
{
return _ui->general_checkBox_autoRestart->isChecked();
}
int PreferencesDialog::getSourceImageType() const
{
return _ui->source_comboBox_image_type->currentIndex();
@@ -2487,10 +2472,6 @@ int PreferencesDialog::getSourceHeight() const
{
return _ui->source_spinBox_imgheight->value();
}
int PreferencesDialog::getFramesDropped() const
{
return _ui->source_spinBox_framesDropped->value();
}
QString PreferencesDialog::getSourceImagesPath() const
{
return _ui->source_images_lineEdit_path->text();
@@ -2666,23 +2647,6 @@ void PreferencesDialog::setDetectionRate(double value)
}
}
void PreferencesDialog::setAutoRestart(bool value)
{
ULOGGER_DEBUG("autoRestart=%d", value);
if(_ui->general_checkBox_autoRestart->isChecked() != value)
{
_ui->general_checkBox_autoRestart->setChecked(value);
if(validateForm())
{
this->writeSettings();
}
else
{
this->readSettingsBegin();
}
}
}
void PreferencesDialog::setTimeLimit(float value)
{
ULOGGER_DEBUG("timeLimit=%fs", value);
@@ -2735,77 +2699,53 @@ void PreferencesDialog::testOdometry()
void PreferencesDialog::testOdometry(OdomType type)
{
UASSERT(_odomCameraOpenNI == 0 && _odomCameraFreenect == 0 && _odomThread == 0 && _odomCameraOpenNICv == 0);
UASSERT(_odomThread == 0 && _cameraThread == 0);
if(this->getSourceRGBD() == kSrcFreenect)
CameraRGBD * camera = 0;
if(this->getSourceRGBD() == kSrcOpenNI_PCL)
{
_odomCameraFreenect = new CameraFreenect(
this->getSourceOpenniDevice().isEmpty()?0:atoi(this->getSourceOpenniDevice().toStdString().c_str()),
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform());
if(!_odomCameraFreenect->init())
{
if(!_odomCameraFreenect->available())
{
QMessageBox::warning(this,
tr("RTAB-Map"),
tr("Freenect camera unavailable! RTAB-Map is not built with Freenect support (libfreenect)."));
}
else
{
QMessageBox::warning(this,
tr("RTAB-Map"),
tr("Freenect camera initialization failed!"));
}
delete _odomCameraFreenect;
_odomCameraFreenect = 0;
}
camera = new CameraOpenni(
this->getSourceOpenniDevice().toStdString(),
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform());
}
else if(this->getSourceRGBD() == kSrcOpenNI_CV ||
this->getSourceRGBD() == kSrcOpenNI_CV_ASUS ||
this->getSourceRGBD() == kSrcOpenNI2)
else if(this->getSourceRGBD() == kSrcOpenNI2)
{
Camera * camera = 0;
if(this->getSourceRGBD() == kSrcOpenNI2)
{
camera = new CameraOpenNI2(
this->getGeneralInputRate());
camera = new CameraOpenNI2(
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform());
}
else
{
camera = new CameraRGBD(
this->getGeneralInputRate(),
this->getSourceRGBD() == kSrcOpenNI_CV_ASUS);
}
camera->setLocalTransform(this->getSourceOpenniLocalTransform());
_odomCameraOpenNICv = new CameraThread(camera);
if(!_odomCameraOpenNICv->init())
{
QMessageBox::warning(this,
tr("RTAB-Map"),
tr("OpenNI-CV camera initialization failed!"));
delete _odomCameraOpenNICv;
_odomCameraOpenNICv = 0;
}
}
else if(this->getSourceRGBD() == kSrcFreenect)
{
camera = new CameraFreenect(
this->getSourceOpenniDevice().isEmpty()?0:atoi(this->getSourceOpenniDevice().toStdString().c_str()),
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform());
}
else if(this->getSourceRGBD() == kSrcOpenNI_CV || this->getSourceRGBD() == kSrcOpenNI_CV_ASUS)
{
camera = new CameraOpenNICV(
this->getSourceRGBD() == kSrcOpenNI_CV_ASUS,
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform());
}
else
{
_odomCameraOpenNI = new CameraOpenni(
this->getSourceOpenniDevice().toStdString(),
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform());
if(!_odomCameraOpenNI->init())
{
QMessageBox::warning(this,
tr("RTAB-Map"),
tr("OpenNI camera initialization failed!"));
delete _odomCameraOpenNI;
_odomCameraOpenNI = 0;
}
UFATAL("RGBD Source type undefined!");
}
if(_odomCameraOpenNI || _odomCameraFreenect || _odomCameraOpenNICv)
if(!camera->init())
{
QMessageBox::warning(this,
tr("RTAB-Map"),
tr("RGBD camera initialization failed!"));
delete camera;
camera = 0;
}
if(camera)
{
Odometry * odometry;
ParametersMap parameters = this->getAllParameters();
@@ -2841,18 +2781,8 @@ void PreferencesDialog::testOdometry(OdomType type)
UEventsManager::addHandler(_odomThread);
UEventsManager::addHandler(odomViewer);
if(_odomCameraFreenect)
{
UEventsManager::createPipe(_odomCameraFreenect, _odomThread, "CameraEvent");
}
else if(_odomCameraOpenNICv)
{
UEventsManager::createPipe(_odomCameraOpenNICv, _odomThread, "CameraEvent");
}
else
{
UEventsManager::createPipe(_odomCameraOpenNI, _odomThread, "CameraEvent");
}
_cameraThread = new CameraThread(camera);
UEventsManager::createPipe(_cameraThread, _odomThread, "CameraEvent");
UEventsManager::createPipe(_odomThread, odomViewer, "OdometryEvent");
window->showNormal();
@@ -2862,41 +2792,18 @@ void PreferencesDialog::testOdometry(OdomType type)
QApplication::processEvents();
_odomThread->start();
if(_odomCameraFreenect)
{
_odomCameraFreenect->start();
}
else if(_odomCameraOpenNICv)
{
_odomCameraOpenNICv->start();
}
else
{
_odomCameraOpenNI->start();
}
_cameraThread->start();
}
}
void PreferencesDialog::cleanOdometryTest()
{
UDEBUG("");
if(_odomCameraOpenNI)
if(_cameraThread)
{
_odomCameraOpenNI->kill();
delete _odomCameraOpenNI;
_odomCameraOpenNI = 0;
}
if(_odomCameraFreenect)
{
_odomCameraFreenect->join(true);
delete _odomCameraFreenect;
_odomCameraFreenect = 0;
}
if(_odomCameraOpenNICv)
{
_odomCameraOpenNICv->join(true);
delete _odomCameraOpenNICv;
_odomCameraOpenNICv = 0;
_cameraThread->join(true);
delete _cameraThread;
_cameraThread = 0;
}
if(_odomThread)
{

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>908</width>
<height>406</height>
<height>494</height>
</rect>
</property>
<property name="sizePolicy">
@@ -63,9 +63,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-331</y>
<width>609</width>
<height>657</height>
<y>0</y>
<width>707</width>
<height>752</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
@@ -1363,21 +1363,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="general_checkBox_autoRestart">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Auto restart.</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Image width (set to 0 to use the default size of the source).</string>
@@ -1387,7 +1373,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property>
</widget>
</item>
<item row="3" column="1">
<item row="2" column="1">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Image height (set to 0 to use the default size of the source).</string>
@@ -1397,7 +1383,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property>
</widget>
</item>
<item row="2" column="0">
<item row="1" column="0">
<widget class="QSpinBox" name="source_spinBox_imgWidth">
<property name="minimum">
<number>0</number>
@@ -1413,7 +1399,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property>
</widget>
</item>
<item row="3" column="0">
<item row="2" column="0">
<widget class="QSpinBox" name="source_spinBox_imgheight">
<property name="minimum">
<number>0</number>
@@ -1429,46 +1415,6 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="general_checkBox_cameraKeypoints">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Keypoints extraction post threatement.</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_128">
<property name="text">
<string>Frames dropped (ignore X frames after each frame acquired, used to decrease source framerate)</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QSpinBox" name="source_spinBox_framesDropped">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>999999999</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
<item>