diff --git a/corelib/include/rtabmap/core/CameraRGBD.h b/corelib/include/rtabmap/core/CameraRGBD.h index 3f7b6638..e3ac14fa 100644 --- a/corelib/include/rtabmap/core/CameraRGBD.h +++ b/corelib/include/rtabmap/core/CameraRGBD.h @@ -263,7 +263,8 @@ public: float maxDepth = 12.0f, bool bilateralFiltering = true, bool edgeAwareFiltering = true, - bool noiseFiltering = true); + bool noiseFiltering = true, + const std::string & pipelineName = ""); virtual ~CameraFreenect2(); virtual bool init(const std::string & calibrationFolder = ".", const std::string & cameraName = ""); @@ -287,6 +288,7 @@ private: bool bilateralFiltering_; bool edgeAwareFiltering_; bool noiseFiltering_; + std::string pipelineName_; #endif }; diff --git a/corelib/src/CameraRGBD.cpp b/corelib/src/CameraRGBD.cpp index fdfc4471..648d2410 100644 --- a/corelib/src/CameraRGBD.cpp +++ b/corelib/src/CameraRGBD.cpp @@ -1343,7 +1343,8 @@ CameraFreenect2::CameraFreenect2( float maxDepth, bool bilateralFiltering, bool edgeAwareFiltering, - bool noiseFiltering) : + bool noiseFiltering, + const std::string & pipelineName) : Camera(imageRate, localTransform) #ifdef RTABMAP_FREENECT2 , @@ -1357,7 +1358,8 @@ CameraFreenect2::CameraFreenect2( maxKinect2Depth_(maxDepth), bilateralFiltering_(bilateralFiltering), edgeAwareFiltering_(edgeAwareFiltering), - noiseFiltering_(noiseFiltering) + noiseFiltering_(noiseFiltering), + pipelineName_(pipelineName) #endif { #ifdef RTABMAP_FREENECT2 @@ -1410,6 +1412,72 @@ CameraFreenect2::~CameraFreenect2() #endif } +libfreenect2::PacketPipeline *createPacketPipelineByName(const std::string & name) +{ + std::string availablePipelines; +#if defined(LIBFREENECT2_WITH_OPENGL_SUPPORT) + availablePipelines += "gl "; + if (name == "gl") + { + UINFO("Using 'gl' pipeline."); + return new libfreenect2::OpenGLPacketPipeline(); + } +#endif +#if defined(LIBFREENECT2_WITH_CUDA_SUPPORT) + availablePipelines += "cuda cudakde "; + if (name == "cuda") + { + UINFO("Using 'cuda' pipeline."); + return new libfreenect2::CudaPacketPipeline(); + } + if (name == "cudakde") + { + UINFO("Using 'cudakde' pipeline."); + return new libfreenect2::CudaKdePacketPipeline(); + } +#endif +#if defined(LIBFREENECT2_WITH_OPENCL_SUPPORT) + availablePipelines += "cl clkde "; + if (name == "cl") + { + UINFO("Using 'cl' pipeline."); + return new libfreenect2::OpenCLPacketPipeline(); + } + if (name == "clkde") + { + UINFO("Using 'clkde' pipeline."); + return new libfreenect2::OpenCLKdePacketPipeline(); + } +#endif + availablePipelines += "cpu"; + if (name == "cpu") + { + UINFO("Using 'cpu' pipeline."); + return new libfreenect2::CpuPacketPipeline(); + } + + if (!name.empty()) + { + UERROR("'%s' pipeline is not available. Available pipelines are: \"%s\". Default one is used instead (first one in the list).", + name.c_str(), availablePipelines.c_str()); + } + + // create default pipeline +#if defined(LIBFREENECT2_WITH_OPENGL_SUPPORT) + UINFO("Using 'gl' pipeline."); + return new libfreenect2::OpenGLPacketPipeline(); +#elif defined(LIBFREENECT2_WITH_CUDA_SUPPORT) + UINFO("Using 'cuda' pipeline."); + return new libfreenect2::CudaPacketPipeline(); +#elif defined(LIBFREENECT2_WITH_OPENCL_SUPPORT) + UINFO("Using 'cl' pipeline."); + return new libfreenect2::OpenCLPacketPipeline(); +#else + UINFO("Using 'cpu' pipeline."); + return new libfreenect2::CpuPacketPipeline(); +#endif +} + bool CameraFreenect2::init(const std::string & calibrationFolder, const std::string & cameraName) { #ifdef RTABMAP_FREENECT2 @@ -1426,20 +1494,7 @@ bool CameraFreenect2::init(const std::string & calibrationFolder, const std::str reg_ = 0; } - libfreenect2::PacketPipeline * pipeline; -#ifdef LIBFREENECT2_WITH_CUDA_SUPPORT - pipeline = new libfreenect2::CudaPacketPipeline(); -#else -#ifdef LIBFREENECT2_WITH_OPENGL_SUPPORT - pipeline = new libfreenect2::OpenGLPacketPipeline(); -#else -#ifdef LIBFREENECT2_WITH_OPENCL_SUPPORT - pipeline = new libfreenect2::OpenCLPacketPipeline(); -#else - pipeline = new libfreenect2::CpuPacketPipeline(); -#endif -#endif -#endif + libfreenect2::PacketPipeline * pipeline = createPacketPipelineByName(pipelineName_); if(deviceId_ <= 0) { diff --git a/corelib/src/Rtabmap.cpp b/corelib/src/Rtabmap.cpp index c81ba226..3d4ba1f8 100644 --- a/corelib/src/Rtabmap.cpp +++ b/corelib/src/Rtabmap.cpp @@ -2820,15 +2820,13 @@ void Rtabmap::setWorkingDirectory(std::string path) ULOGGER_DEBUG("Comparing new working directory path \"%s\" with \"%s\"", path.c_str(), _wDir.c_str()); if(path.compare(_wDir) != 0) { + if (_foutFloat || _foutInt) + { + UWARN("Working directory has been changed from \"%s\" with \"%s\", new log files will be created.", + path.c_str(), _wDir.c_str()); + } _wDir = path; - if(_memory) - { - this->resetMemory(); - } - else - { - setupLogFiles(); - } + setupLogFiles(); } } else if(path.empty()) diff --git a/guilib/src/MainWindow.cpp b/guilib/src/MainWindow.cpp index 788faef0..11462857 100644 --- a/guilib/src/MainWindow.cpp +++ b/guilib/src/MainWindow.cpp @@ -3821,15 +3821,6 @@ void MainWindow::applyPrefSettings(const rtabmap::ParametersMap & parameters, bo if(_state != kIdle && parametersModified.size()) { - if(parametersModified.erase(Parameters::kRtabmapWorkingDirectory()) && - _state != kMonitoring && - _state != kMonitoringPaused) - { - QMessageBox::information(this, tr("Working memory changed"), - tr("The working directory can't be changed while the " - "detector is running (state=%1). This will be " - "applied when the detector will stop.").arg(_state)); - } if(postParamEvent) { this->post(new ParamEvent(parametersModified)); diff --git a/guilib/src/PreferencesDialog.cpp b/guilib/src/PreferencesDialog.cpp index 1e7d968f..12028e7e 100644 --- a/guilib/src/PreferencesDialog.cpp +++ b/guilib/src/PreferencesDialog.cpp @@ -520,6 +520,7 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) : connect(_ui->checkBox_freenect2BilateralFiltering, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->checkBox_freenect2EdgeAwareFiltering, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->checkBox_freenect2NoiseFiltering, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); + connect(_ui->lineEdit_freenect2Pipeline, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->comboBox_realsensePresetRGB, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->comboBox_realsensePresetDepth, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->checkbox_realsenseOdom, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); @@ -1516,6 +1517,7 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox) _ui->checkBox_freenect2BilateralFiltering->setChecked(true); _ui->checkBox_freenect2EdgeAwareFiltering->setChecked(true); _ui->checkBox_freenect2NoiseFiltering->setChecked(true); + _ui->lineEdit_freenect2Pipeline->setText(""); _ui->comboBox_realsensePresetRGB->setCurrentIndex(0); _ui->comboBox_realsensePresetDepth->setCurrentIndex(2); _ui->checkbox_realsenseOdom->setChecked(false); @@ -1888,6 +1890,7 @@ void PreferencesDialog::readCameraSettings(const QString & filePath) _ui->checkBox_freenect2BilateralFiltering->setChecked(settings.value("bilateralFiltering", _ui->checkBox_freenect2BilateralFiltering->isChecked()).toBool()); _ui->checkBox_freenect2EdgeAwareFiltering->setChecked(settings.value("edgeAwareFiltering", _ui->checkBox_freenect2EdgeAwareFiltering->isChecked()).toBool()); _ui->checkBox_freenect2NoiseFiltering->setChecked(settings.value("noiseFiltering", _ui->checkBox_freenect2NoiseFiltering->isChecked()).toBool()); + _ui->lineEdit_freenect2Pipeline->setText(settings.value("pipeline", _ui->lineEdit_freenect2Pipeline->text()).toString()); settings.endGroup(); // Freenect2 settings.beginGroup("RealSense"); @@ -2279,6 +2282,7 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath) const settings.setValue("bilateralFiltering", _ui->checkBox_freenect2BilateralFiltering->isChecked()); settings.setValue("edgeAwareFiltering", _ui->checkBox_freenect2EdgeAwareFiltering->isChecked()); settings.setValue("noiseFiltering", _ui->checkBox_freenect2NoiseFiltering->isChecked()); + settings.setValue("pipeline", _ui->lineEdit_freenect2Pipeline->text()); settings.endGroup(); // Freenect2 settings.beginGroup("RealSense"); @@ -4740,7 +4744,8 @@ Camera * PreferencesDialog::createCamera(bool useRawImages, bool useColor) _ui->doubleSpinBox_freenect2MaxDepth->value(), _ui->checkBox_freenect2BilateralFiltering->isChecked(), _ui->checkBox_freenect2EdgeAwareFiltering->isChecked(), - _ui->checkBox_freenect2NoiseFiltering->isChecked()); + _ui->checkBox_freenect2NoiseFiltering->isChecked(), + _ui->lineEdit_freenect2Pipeline->text().toStdString()); } else if (driver == kSrcRealSense) { diff --git a/guilib/src/ui/preferencesDialog.ui b/guilib/src/ui/preferencesDialog.ui index bb4c83a9..4240ae7e 100644 --- a/guilib/src/ui/preferencesDialog.ui +++ b/guilib/src/ui/preferencesDialog.ui @@ -63,16 +63,25 @@ 0 - 0 - 673 - 2749 + -317 + 677 + 2682 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -86,7 +95,7 @@ QFrame::Raised - 12 + 5 @@ -2741,7 +2750,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki - 1 + 0 @@ -2851,7 +2860,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki - 7 + 5 @@ -3150,10 +3159,10 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki Freenect2 - - + + - Format. + Depth edge aware filtering. true @@ -3163,18 +3172,15 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki - - - - Qt::Vertical + + + + 65.000000000000000 - - - 20 - 0 - + + 12.000000000000000 - + @@ -3208,6 +3214,16 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki + + + + + + + true + + + @@ -3221,6 +3237,16 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki + + + + + + + true + + + @@ -3234,10 +3260,10 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki - - + + - Depth edge aware filtering. + Format. true @@ -3247,33 +3273,42 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki - - + + + + Qt::Vertical + + + + 20 + 0 + + + + + + - 65.000000000000000 + 64.000000000000000 + + + 0.100000000000000 - 12.000000000000000 + 0.300000000000000 - - + + - + Depth noise filtering. - + true - - - - - - - - - true + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse @@ -3290,19 +3325,6 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki - - - - 64.000000000000000 - - - 0.100000000000000 - - - 0.300000000000000 - - - @@ -3313,10 +3335,10 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki - - + + - Depth noise filtering. + Pipeline, any one of "gl cl clkde cuda cudakde cpu". If empty, default one is used. Depending on how libfreenect2 was built, the selected pipeline may not be available. true @@ -3326,6 +3348,13 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki + + + + + + + @@ -4561,7 +4590,16 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki Directory of images (optional settings) - + + 0 + + + 0 + + + 0 + + 0 @@ -12710,7 +12748,16 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag - + + 0 + + + 0 + + + 0 + + 0 @@ -12850,7 +12897,16 @@ Lower the ratio -> higher the precision. 0 means disabled, matching the neare - + + 0 + + + 0 + + + 0 + + 0 @@ -13008,7 +13064,16 @@ Lower the ratio -> higher the precision. 0 means disabled, matching the neare 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -13088,7 +13153,16 @@ Lower the ratio -> higher the precision. 0 means disabled, matching the neare 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -13200,7 +13274,16 @@ Lower the ratio -> higher the precision. 0 means disabled, matching the neare 0 - + + 0 + + + 0 + + + 0 + + 0