/* Copyright (c) 2010-2014, Mathieu Labbe - IntRoLab - Universite de Sherbrooke All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Universite de Sherbrooke nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "rtabmap/gui/PreferencesDialog.h" #include "rtabmap/gui/DatabaseViewer.h" #include "rtabmap/gui/OdometryViewer.h" #include "rtabmap/gui/CalibrationDialog.h" #include #include #include #include #include #include #include #include #include #include #include #include "ui_preferencesDialog.h" #include "rtabmap/core/Version.h" #include "rtabmap/core/Rtabmap.h" #include "rtabmap/core/Parameters.h" #include "rtabmap/core/Odometry.h" #include "rtabmap/core/OdometryThread.h" #include "rtabmap/core/CameraRGBD.h" #include "rtabmap/core/CameraThread.h" #include "rtabmap/core/CameraRGB.h" #include "rtabmap/core/CameraStereo.h" #include "rtabmap/core/Memory.h" #include "rtabmap/core/VWDictionary.h" #include "rtabmap/core/Optimizer.h" #include "rtabmap/core/DBReader.h" #include "rtabmap/gui/LoopClosureViewer.h" #include "rtabmap/gui/CameraViewer.h" #include "rtabmap/gui/CloudViewer.h" #include "rtabmap/gui/ImageView.h" #include "rtabmap/gui/GraphViewer.h" #include "ExportCloudsDialog.h" #include "PostProcessingDialog.h" #include "CreateSimpleCalibrationDialog.h" #include #include #include #include #include "rtabmap/utilite/UPlot.h" #include #if CV_MAJOR_VERSION < 3 #include #else #include #endif using namespace rtabmap; namespace rtabmap { PreferencesDialog::PreferencesDialog(QWidget * parent) : QDialog(parent), _obsoletePanels(kPanelDummy), _ui(0), _indexModel(0), _initialized(false), _calibrationDialog(new CalibrationDialog(false, ".", this)) { ULOGGER_DEBUG(""); _calibrationDialog->setWindowFlags(Qt::Window); _calibrationDialog->setWindowTitle(tr("Calibration")); _ui = new Ui_preferencesDialog(); _ui->setupUi(this); bool haveCuda = false; #if CV_MAJOR_VERSION < 3 haveCuda = cv::gpu::getCudaEnabledDeviceCount() != 0; #else haveCuda = cv::cuda::getCudaEnabledDeviceCount() != 0; #ifndef HAVE_OPENCV_CUDAFEATURES2D haveCuda = false; #endif #endif if(!haveCuda) { _ui->surf_checkBox_gpuVersion->setChecked(false); _ui->surf_checkBox_gpuVersion->setEnabled(false); _ui->label_surf_checkBox_gpuVersion->setEnabled(false); _ui->surf_doubleSpinBox_gpuKeypointsRatio->setEnabled(false); _ui->label_surf_checkBox_gpuKeypointsRatio->setEnabled(false); _ui->fastGpu->setChecked(false); _ui->fastGpu->setEnabled(false); _ui->label_fastGPU->setEnabled(false); _ui->fastKeypointRatio->setEnabled(false); _ui->label_fastGPUKptRatio->setEnabled(false); _ui->checkBox_ORBGpu->setChecked(false); _ui->checkBox_ORBGpu->setEnabled(false); _ui->label_orbGpu->setEnabled(false); // remove BruteForceGPU option _ui->comboBox_dictionary_strategy->removeItem(4); _ui->reextract_nn->removeItem(4); } #if PCL_VERSION_COMPARE(<, 1, 7, 2) _ui->checkBox_map_shown->setChecked(false); _ui->checkBox_map_shown->setEnabled(false); _ui->label_map_shown->setText(_ui->label_map_shown->text() + " (Disabled, PCL >=1.7.2 required)"); #endif if(RTABMAP_NONFREE == 0) { _ui->comboBox_detector_strategy->setItemData(0, 0, Qt::UserRole - 1); _ui->comboBox_detector_strategy->setItemData(1, 0, Qt::UserRole - 1); _ui->reextract_type->setItemData(0, 0, Qt::UserRole - 1); _ui->reextract_type->setItemData(1, 0, Qt::UserRole - 1); _ui->comboBox_dictionary_strategy->setItemData(1, 0, Qt::UserRole - 1); _ui->reextract_nn->setItemData(1, 0, Qt::UserRole - 1); #if CV_MAJOR_VERSION == 3 _ui->comboBox_detector_strategy->setItemData(0, 0, Qt::UserRole - 1); _ui->comboBox_detector_strategy->setItemData(1, 0, Qt::UserRole - 1); _ui->comboBox_detector_strategy->setItemData(3, 0, Qt::UserRole - 1); _ui->comboBox_detector_strategy->setItemData(4, 0, Qt::UserRole - 1); _ui->comboBox_detector_strategy->setItemData(5, 0, Qt::UserRole - 1); _ui->comboBox_detector_strategy->setItemData(6, 0, Qt::UserRole - 1); _ui->reextract_type->setItemData(0, 0, Qt::UserRole - 1); _ui->reextract_type->setItemData(1, 0, Qt::UserRole - 1); _ui->reextract_type->setItemData(3, 0, Qt::UserRole - 1); _ui->reextract_type->setItemData(4, 0, Qt::UserRole - 1); _ui->reextract_type->setItemData(5, 0, Qt::UserRole - 1); _ui->reextract_type->setItemData(6, 0, Qt::UserRole - 1); #endif } if(!Optimizer::isAvailable(Optimizer::kTypeG2O)) { _ui->graphOptimization_type->setItemData(1, 0, Qt::UserRole - 1); } if(!Optimizer::isAvailable(Optimizer::kTypeGTSAM)) { _ui->graphOptimization_type->setItemData(2, 0, Qt::UserRole - 1); } if(!Optimizer::isAvailable(Optimizer::kTypeG2O) && !Optimizer::isAvailable(Optimizer::kTypeGTSAM)) { _ui->graphOptimization_robust->setEnabled(false); } if(!CameraOpenni::available()) { _ui->comboBox_cameraRGBD->setItemData(0, 0, Qt::UserRole - 1); } if(!CameraFreenect::available()) { _ui->comboBox_cameraRGBD->setItemData(1, 0, Qt::UserRole - 1); } if(!CameraOpenNICV::available()) { _ui->comboBox_cameraRGBD->setItemData(2, 0, Qt::UserRole - 1); _ui->comboBox_cameraRGBD->setItemData(3, 0, Qt::UserRole - 1); } if(!CameraOpenNI2::available()) { _ui->comboBox_cameraRGBD->setItemData(4, 0, Qt::UserRole - 1); } if(!CameraFreenect2::available()) { _ui->comboBox_cameraRGBD->setItemData(5, 0, Qt::UserRole - 1); } if(!CameraStereoDC1394::available()) { _ui->comboBox_cameraStereo->setItemData(0, 0, Qt::UserRole - 1); } if(!CameraStereoFlyCapture2::available()) { _ui->comboBox_cameraStereo->setItemData(1, 0, Qt::UserRole - 1); } _ui->openni2_exposure->setEnabled(CameraOpenNI2::exposureGainAvailable()); _ui->openni2_gain->setEnabled(CameraOpenNI2::exposureGainAvailable()); // Default Driver connect(_ui->comboBox_sourceType, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSourceGrpVisibility())); connect(_ui->comboBox_cameraRGBD, SIGNAL(currentIndexChanged(int)), this, SLOT(updateRGBDCameraGroupBoxVisibility())); connect(_ui->source_comboBox_image_type, SIGNAL(currentIndexChanged(int)), this, SLOT(updateRGBCameraGroupBoxVisibility())); connect(_ui->comboBox_cameraStereo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateStereoCameraGroupBoxVisibility())); this->resetSettings(_ui->groupBox_source0); _ui->predictionPlot->showLegend(false); QButtonGroup * buttonGroup = new QButtonGroup(this); buttonGroup->addButton(_ui->radioButton_basic); buttonGroup->addButton(_ui->radioButton_advanced); // Connect connect(_ui->buttonBox_global, SIGNAL(clicked(QAbstractButton *)), this, SLOT(closeDialog(QAbstractButton *))); connect(_ui->buttonBox_local, SIGNAL(clicked(QAbstractButton *)), this, SLOT(resetApply(QAbstractButton *))); connect(_ui->pushButton_loadConfig, SIGNAL(clicked()), this, SLOT(loadConfigFrom())); connect(_ui->pushButton_saveConfig, SIGNAL(clicked()), this, SLOT(saveConfigTo())); connect(_ui->pushButton_resetConfig, SIGNAL(clicked()), this, SLOT(resetConfig())); connect(_ui->radioButton_basic, SIGNAL(toggled(bool)), this, SLOT(setupTreeView())); connect(_ui->pushButton_testOdometry, SIGNAL(clicked()), this, SLOT(testOdometry())); connect(_ui->pushButton_test_camera, SIGNAL(clicked()), this, SLOT(testCamera())); // General panel connect(_ui->general_checkBox_imagesKept, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteGeneralPanel())); connect(_ui->checkBox_verticalLayoutUsed, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteGeneralPanel())); connect(_ui->checkBox_imageRejectedShown, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteGeneralPanel())); connect(_ui->checkBox_imageHighestHypShown, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteGeneralPanel())); connect(_ui->checkBox_beep, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteGeneralPanel())); connect(_ui->checkBox_notifyWhenNewGlobalPathIsReceived, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteGeneralPanel())); connect(_ui->spinBox_odomQualityWarnThr, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteGeneralPanel())); connect(_ui->checkBox_posteriorGraphView, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteGeneralPanel())); // Cloud rendering panel _3dRenderingShowClouds.resize(2); _3dRenderingShowClouds[0] = _ui->checkBox_showClouds; _3dRenderingShowClouds[1] = _ui->checkBox_showOdomClouds; _3dRenderingVoxelSize.resize(2); _3dRenderingVoxelSize[0] = _ui->doubleSpinBox_voxelSize; _3dRenderingVoxelSize[1] = _ui->doubleSpinBox_voxelSize_odom; _3dRenderingDecimation.resize(2); _3dRenderingDecimation[0] = _ui->spinBox_decimation; _3dRenderingDecimation[1] = _ui->spinBox_decimation_odom; _3dRenderingMaxDepth.resize(2); _3dRenderingMaxDepth[0] = _ui->doubleSpinBox_maxDepth; _3dRenderingMaxDepth[1] = _ui->doubleSpinBox_maxDepth_odom; _3dRenderingOpacity.resize(2); _3dRenderingOpacity[0] = _ui->doubleSpinBox_opacity; _3dRenderingOpacity[1] = _ui->doubleSpinBox_opacity_odom; _3dRenderingPtSize.resize(2); _3dRenderingPtSize[0] = _ui->spinBox_ptsize; _3dRenderingPtSize[1] = _ui->spinBox_ptsize_odom; _3dRenderingShowScans.resize(2); _3dRenderingShowScans[0] = _ui->checkBox_showScans; _3dRenderingShowScans[1] = _ui->checkBox_showOdomScans; _3dRenderingDownsamplingScan.resize(2); _3dRenderingDownsamplingScan[0] = _ui->spinBox_downsamplingScan; _3dRenderingDownsamplingScan[1] = _ui->spinBox_downsamplingScan_odom; _3dRenderingVoxelSizeScan.resize(2); _3dRenderingVoxelSizeScan[0] = _ui->doubleSpinBox_voxelSizeScan; _3dRenderingVoxelSizeScan[1] = _ui->doubleSpinBox_voxelSizeScan_odom; _3dRenderingOpacityScan.resize(2); _3dRenderingOpacityScan[0] = _ui->doubleSpinBox_opacity_scan; _3dRenderingOpacityScan[1] = _ui->doubleSpinBox_opacity_odom_scan; _3dRenderingPtSizeScan.resize(2); _3dRenderingPtSizeScan[0] = _ui->spinBox_ptsize_scan; _3dRenderingPtSizeScan[1] = _ui->spinBox_ptsize_odom_scan; for(int i=0; i<2; ++i) { connect(_3dRenderingShowClouds[i], SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_3dRenderingVoxelSize[i], SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_3dRenderingDecimation[i], SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_3dRenderingMaxDepth[i], SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_3dRenderingShowScans[i], SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_3dRenderingDownsamplingScan[i], SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_3dRenderingVoxelSizeScan[i], SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_3dRenderingOpacity[i], SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_3dRenderingPtSize[i], SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_3dRenderingOpacityScan[i], SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_3dRenderingPtSizeScan[i], SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel())); } connect(_ui->checkBox_showGraphs, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_ui->checkBox_showLabels, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_ui->checkBox_meshing, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_ui->doubleSpinBox_gp3Radius, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_ui->doubleSpinBox_gp3Mu, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_ui->spinBox_normalKSearch, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_ui->checkBox_mls, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_ui->doubleSpinBox_mlsRadius, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_ui->checkBox_nodeFiltering, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_ui->checkBox_subtractFiltering, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_ui->doubleSpinBox_cloudFilterRadius, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_ui->doubleSpinBox_cloudFilterAngle, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_ui->spinBox_substractFilteringMinPts, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_ui->checkBox_map_shown, SIGNAL(clicked(bool)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_ui->doubleSpinBox_map_resolution, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_ui->doubleSpinBox_map_opacity, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_ui->checkBox_map_occupancyFrom3DCloud, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel())); connect(_ui->checkBox_map_erode, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteCloudRenderingPanel())); //Logging panel connect(_ui->comboBox_loggerLevel, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteLoggingPanel())); connect(_ui->comboBox_loggerEventLevel, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteLoggingPanel())); connect(_ui->comboBox_loggerPauseLevel, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteLoggingPanel())); connect(_ui->checkBox_logger_printTime, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteLoggingPanel())); connect(_ui->comboBox_loggerType, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteLoggingPanel())); //Source panel connect(_ui->general_doubleSpinBox_imgRate, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->source_mirroring, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->toolButton_source_path_calibration, SIGNAL(clicked()), this, SLOT(selectCalibrationPath())); connect(_ui->lineEdit_calibrationFile, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); _ui->stackedWidget_src->setCurrentIndex(_ui->comboBox_sourceType->currentIndex()); connect(_ui->comboBox_sourceType, SIGNAL(currentIndexChanged(int)), _ui->stackedWidget_src, SLOT(setCurrentIndex(int))); connect(_ui->comboBox_sourceType, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->lineEdit_sourceDevice, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->lineEdit_sourceLocalTransform, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); //Image source _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())); //images group connect(_ui->source_images_toolButton_selectSource, SIGNAL(clicked()), this, SLOT(selectSourceImagesPath())); connect(_ui->source_images_lineEdit_path, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->source_images_spinBox_startPos, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->source_images_refreshDir, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->checkBox_rgbImages_rectify, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); //video group connect(_ui->source_video_toolButton_selectSource, SIGNAL(clicked()), this, SLOT(selectSourceVideoPath())); connect(_ui->source_video_lineEdit_path, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->checkBox_rgbVideo_rectify, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); //database group connect(_ui->source_database_toolButton_selectSource, SIGNAL(clicked()), this, SLOT(selectSourceDatabase())); connect(_ui->toolButton_dbViewer, SIGNAL(clicked()), this, SLOT(openDatabaseViewer())); connect(_ui->groupBox_sourceDatabase, SIGNAL(toggled(bool)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->source_database_lineEdit_path, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->source_checkBox_ignoreOdometry, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->source_checkBox_ignoreGoalDelay, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->source_checkBox_ignoreGoals, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->source_spinBox_databaseStartPos, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->source_checkBox_useDbStamps, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); //openni group _ui->stackedWidget_rgbd->setCurrentIndex(_ui->comboBox_cameraRGBD->currentIndex()); connect(_ui->comboBox_cameraRGBD, SIGNAL(currentIndexChanged(int)), _ui->stackedWidget_rgbd, SLOT(setCurrentIndex(int))); connect(_ui->comboBox_cameraRGBD, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteSourcePanel())); _ui->stackedWidget_stereo->setCurrentIndex(_ui->comboBox_cameraStereo->currentIndex()); connect(_ui->comboBox_cameraStereo, SIGNAL(currentIndexChanged(int)), _ui->stackedWidget_stereo, SLOT(setCurrentIndex(int))); connect(_ui->comboBox_cameraStereo, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->openni2_autoWhiteBalance, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->openni2_autoExposure, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->openni2_exposure, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->openni2_gain, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->openni2_mirroring, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->openni2_stampsIdsUsed, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->comboBox_freenect2Format, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->doubleSpinBox_freenect2MinDepth, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->doubleSpinBox_freenect2MaxDepth, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteSourcePanel())); 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->toolButton_cameraRGBDImages_timestamps, SIGNAL(clicked()), this, SLOT(selectSourceRGBDImagesStamps())); connect(_ui->lineEdit_cameraRGBDImages_timestamps, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->toolButton_cameraRGBDImages_path_rgb, SIGNAL(clicked()), this, SLOT(selectSourceRGBDImagesPathRGB())); connect(_ui->toolButton_cameraRGBDImages_path_depth, SIGNAL(clicked()), this, SLOT(selectSourceRGBDImagesPathDepth())); connect(_ui->lineEdit_cameraRGBDImages_path_rgb, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->lineEdit_cameraRGBDImages_path_depth, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->checkBox_RGBDImages_timestamps, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->doubleSpinBox_cameraRGBDImages_scale, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->toolButton_cameraStereoImages_timestamps, SIGNAL(clicked()), this, SLOT(selectSourceStereoImagesStamps())); connect(_ui->lineEdit_cameraStereoImages_timestamps, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->toolButton_cameraStereoImages_path_left, SIGNAL(clicked()), this, SLOT(selectSourceStereoImagesPathLeft())); connect(_ui->toolButton_cameraStereoImages_path_right, SIGNAL(clicked()), this, SLOT(selectSourceStereoImagesPathRight())); connect(_ui->toolButton_cameraStereoImages_path_scans, SIGNAL(clicked()), this, SLOT(selectSourceStereoImagesPathScans())); connect(_ui->lineEdit_cameraStereoImages_path_left, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->lineEdit_cameraStereoImages_path_right, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->lineEdit_cameraStereoImages_path_scans, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->lineEdit_cameraStereoImages_laser_transform, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->spinBox_cameraStereoImages_max_scan_pts, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->checkBox_stereoImages_timestamps, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->checkBox_stereoImages_rectify, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->toolButton_cameraStereoVideo_path, SIGNAL(clicked()), this, SLOT(selectSourceStereoVideoPath())); connect(_ui->lineEdit_cameraStereoVideo_path, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->checkBox_stereoVideo_rectify, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->checkbox_rgbd_colorOnly, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->checkbox_stereo_depthGenerated, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->pushButton_calibrate, SIGNAL(clicked()), this, SLOT(calibrate())); connect(_ui->pushButton_calibrate_simple, SIGNAL(clicked()), this, SLOT(calibrateSimple())); connect(_ui->toolButton_openniOniPath, SIGNAL(clicked()), this, SLOT(selectSourceOniPath())); connect(_ui->toolButton_openni2OniPath, SIGNAL(clicked()), this, SLOT(selectSourceOni2Path())); connect(_ui->lineEdit_openniOniPath, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->lineEdit_openni2OniPath, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); //Rtabmap basic connect(_ui->general_doubleSpinBox_timeThr, SIGNAL(valueChanged(double)), _ui->general_doubleSpinBox_timeThr_2, SLOT(setValue(double))); connect(_ui->general_doubleSpinBox_hardThr, SIGNAL(valueChanged(double)), _ui->general_doubleSpinBox_hardThr_2, SLOT(setValue(double))); connect(_ui->doubleSpinBox_similarityThreshold, SIGNAL(valueChanged(double)), _ui->doubleSpinBox_similarityThreshold_2, SLOT(setValue(double))); connect(_ui->general_doubleSpinBox_detectionRate, SIGNAL(valueChanged(double)), _ui->general_doubleSpinBox_detectionRate_2, SLOT(setValue(double))); connect(_ui->general_spinBox_imagesBufferSize, SIGNAL(valueChanged(int)), _ui->general_spinBox_imagesBufferSize_2, SLOT(setValue(int))); connect(_ui->general_spinBox_maxStMemSize, SIGNAL(valueChanged(int)), _ui->general_spinBox_maxStMemSize_2, SLOT(setValue(int))); connect(_ui->general_doubleSpinBox_timeThr_2, SIGNAL(editingFinished()), this, SLOT(updateBasicParameter())); connect(_ui->general_doubleSpinBox_hardThr_2, SIGNAL(editingFinished()), this, SLOT(updateBasicParameter())); connect(_ui->doubleSpinBox_similarityThreshold_2, SIGNAL(editingFinished()), this, SLOT(updateBasicParameter())); connect(_ui->general_doubleSpinBox_detectionRate_2, SIGNAL(editingFinished()), this, SLOT(updateBasicParameter())); connect(_ui->general_spinBox_imagesBufferSize_2, SIGNAL(editingFinished()), this, SLOT(updateBasicParameter())); connect(_ui->general_spinBox_maxStMemSize_2, SIGNAL(editingFinished()), this, SLOT(updateBasicParameter())); connect(_ui->groupBox_publishing, SIGNAL(clicked(bool)), this, SLOT(updateBasicParameter())); connect(_ui->general_checkBox_publishStats_2, SIGNAL(stateChanged(int)), this, SLOT(updateBasicParameter())); connect(_ui->general_checkBox_activateRGBD, SIGNAL(stateChanged(int)), this, SLOT(updateBasicParameter())); connect(_ui->general_checkBox_activateRGBD_2, SIGNAL(stateChanged(int)), this, SLOT(updateBasicParameter())); connect(_ui->general_checkBox_SLAM_mode, SIGNAL(stateChanged(int)), this, SLOT(updateBasicParameter())); connect(_ui->general_checkBox_SLAM_mode_2, SIGNAL(stateChanged(int)), this, SLOT(updateBasicParameter())); // Map objects name with the corresponding parameter key, needed for the addParameter() slots //Rtabmap _ui->groupBox_publishing->setObjectName(Parameters::kRtabmapPublishStats().c_str()); _ui->general_checkBox_publishRawData->setObjectName(Parameters::kRtabmapPublishLastSignature().c_str()); _ui->general_checkBox_publishPdf->setObjectName(Parameters::kRtabmapPublishPdf().c_str()); _ui->general_checkBox_publishLikelihood->setObjectName(Parameters::kRtabmapPublishLikelihood().c_str()); _ui->general_checkBox_statisticLogsBufferedInRAM->setObjectName(Parameters::kRtabmapStatisticLogsBufferedInRAM().c_str()); _ui->groupBox_statistics->setObjectName(Parameters::kRtabmapStatisticLogged().c_str()); _ui->general_checkBox_statisticLoggedHeaders->setObjectName(Parameters::kRtabmapStatisticLoggedHeaders().c_str()); _ui->general_doubleSpinBox_timeThr->setObjectName(Parameters::kRtabmapTimeThr().c_str()); _ui->general_spinBox_memoryThr->setObjectName(Parameters::kRtabmapMemoryThr().c_str()); _ui->general_doubleSpinBox_detectionRate->setObjectName(Parameters::kRtabmapDetectionRate().c_str()); _ui->general_spinBox_imagesBufferSize->setObjectName(Parameters::kRtabmapImageBufferSize().c_str()); _ui->general_checkBox_createIntermediateNodes->setObjectName(Parameters::kRtabmapCreateIntermediateNodes().c_str()); _ui->general_spinBox_maxRetrieved->setObjectName(Parameters::kRtabmapMaxRetrieved().c_str()); _ui->general_checkBox_startNewMapOnLoopClosure->setObjectName(Parameters::kRtabmapStartNewMapOnLoopClosure().c_str()); _ui->lineEdit_workingDirectory->setObjectName(Parameters::kRtabmapWorkingDirectory().c_str()); connect(_ui->toolButton_workingDirectory, SIGNAL(clicked()), this, SLOT(changeWorkingDirectory())); // Memory _ui->general_checkBox_keepRawData->setObjectName(Parameters::kMemImageKept().c_str()); _ui->general_checkBox_keepBinaryData->setObjectName(Parameters::kMemBinDataKept().c_str()); _ui->general_checkBox_saveDepth16bits->setObjectName(Parameters::kMemSaveDepth16Format().c_str()); _ui->general_checkBox_reduceGraph->setObjectName(Parameters::kMemReduceGraph().c_str()); _ui->general_checkBox_keepNotLinkedNodes->setObjectName(Parameters::kMemNotLinkedNodesKept().c_str()); _ui->general_spinBox_maxStMemSize->setObjectName(Parameters::kMemSTMSize().c_str()); _ui->doubleSpinBox_similarityThreshold->setObjectName(Parameters::kMemRehearsalSimilarity().c_str()); _ui->general_checkBox_SLAM_mode->setObjectName(Parameters::kMemIncrementalMemory().c_str()); _ui->general_doubleSpinBox_recentWmRatio->setObjectName(Parameters::kMemRecentWmRatio().c_str()); _ui->general_checkBox_transferSortingByWeightId->setObjectName(Parameters::kMemTransferSortingByWeightId().c_str()); _ui->general_checkBox_RehearsalIdUpdatedToNewOne->setObjectName(Parameters::kMemRehearsalIdUpdatedToNewOne().c_str()); _ui->general_checkBox_generateIds->setObjectName(Parameters::kMemGenerateIds().c_str()); _ui->general_checkBox_badSignaturesIgnored->setObjectName(Parameters::kMemBadSignaturesIgnored().c_str()); _ui->general_checkBox_createMapLabels->setObjectName(Parameters::kMemMapLabelsAdded().c_str()); _ui->general_checkBox_initWMWithAllNodes->setObjectName(Parameters::kMemInitWMWithAllNodes().c_str()); _ui->checkBox_localSpaceScanMatchingIDsSaved->setObjectName(Parameters::kRGBDScanMatchingIdsSavedInLinks().c_str()); _ui->spinBox_imageDecimation->setObjectName(Parameters::kMemImageDecimation().c_str()); _ui->general_spinBox_laserScanDownsample->setObjectName(Parameters::kMemLaserScanDownsampleStepSize().c_str()); // Database _ui->checkBox_dbInMemory->setObjectName(Parameters::kDbSqlite3InMemory().c_str()); _ui->spinBox_dbCacheSize->setObjectName(Parameters::kDbSqlite3CacheSize().c_str()); _ui->comboBox_dbJournalMode->setObjectName(Parameters::kDbSqlite3JournalMode().c_str()); _ui->comboBox_dbSynchronous->setObjectName(Parameters::kDbSqlite3Synchronous().c_str()); _ui->comboBox_dbTempStore->setObjectName(Parameters::kDbSqlite3TempStore().c_str()); // Create hypotheses _ui->general_doubleSpinBox_hardThr->setObjectName(Parameters::kRtabmapLoopThr().c_str()); _ui->general_doubleSpinBox_loopRatio->setObjectName(Parameters::kRtabmapLoopRatio().c_str()); //Bayes _ui->general_doubleSpinBox_vp->setObjectName(Parameters::kBayesVirtualPlacePriorThr().c_str()); _ui->lineEdit_bayes_predictionLC->setObjectName(Parameters::kBayesPredictionLC().c_str()); _ui->checkBox_bayes_fullPredictionUpdate->setObjectName(Parameters::kBayesFullPredictionUpdate().c_str()); connect(_ui->lineEdit_bayes_predictionLC, SIGNAL(textChanged(const QString &)), this, SLOT(updatePredictionPlot())); //Keypoint-based _ui->comboBox_dictionary_strategy->setObjectName(Parameters::kKpNNStrategy().c_str()); _ui->checkBox_dictionary_incremental->setObjectName(Parameters::kKpIncrementalDictionary().c_str()); _ui->checkBox_kp_incrementalFlann->setObjectName(Parameters::kKpIncrementalFlann().c_str()); _ui->comboBox_detector_strategy->setObjectName(Parameters::kKpDetectorStrategy().c_str()); _ui->surf_doubleSpinBox_nndrRatio->setObjectName(Parameters::kKpNndrRatio().c_str()); _ui->surf_doubleSpinBox_maxDepth->setObjectName(Parameters::kKpMaxDepth().c_str()); _ui->surf_doubleSpinBox_minDepth->setObjectName(Parameters::kKpMinDepth().c_str()); _ui->surf_spinBox_wordsPerImageTarget->setObjectName(Parameters::kKpWordsPerImage().c_str()); _ui->surf_doubleSpinBox_ratioBadSign->setObjectName(Parameters::kKpBadSignRatio().c_str()); _ui->checkBox_kp_tfIdfLikelihoodUsed->setObjectName(Parameters::kKpTfIdfLikelihoodUsed().c_str()); _ui->checkBox_kp_parallelized->setObjectName(Parameters::kKpParallelized().c_str()); _ui->lineEdit_kp_roi->setObjectName(Parameters::kKpRoiRatios().c_str()); _ui->lineEdit_dictionaryPath->setObjectName(Parameters::kKpDictionaryPath().c_str()); connect(_ui->toolButton_dictionaryPath, SIGNAL(clicked()), this, SLOT(changeDictionaryPath())); _ui->checkBox_kp_newWordsComparedTogether->setObjectName(Parameters::kKpNewWordsComparedTogether().c_str()); _ui->subpix_winSize_kp->setObjectName(Parameters::kKpSubPixWinSize().c_str()); _ui->subpix_iterations_kp->setObjectName(Parameters::kKpSubPixIterations().c_str()); _ui->subpix_eps_kp->setObjectName(Parameters::kKpSubPixEps().c_str()); _ui->subpix_winSize->setObjectName(Parameters::kKpSubPixWinSize().c_str()); _ui->subpix_iterations->setObjectName(Parameters::kKpSubPixIterations().c_str()); _ui->subpix_eps->setObjectName(Parameters::kKpSubPixEps().c_str()); //SURF detector _ui->surf_doubleSpinBox_hessianThr->setObjectName(Parameters::kSURFHessianThreshold().c_str()); _ui->surf_spinBox_octaves->setObjectName(Parameters::kSURFOctaves().c_str()); _ui->surf_spinBox_octaveLayers->setObjectName(Parameters::kSURFOctaveLayers().c_str()); _ui->checkBox_surfExtended->setObjectName(Parameters::kSURFExtended().c_str()); _ui->surf_checkBox_upright->setObjectName(Parameters::kSURFUpright().c_str()); _ui->surf_checkBox_gpuVersion->setObjectName(Parameters::kSURFGpuVersion().c_str()); _ui->surf_doubleSpinBox_gpuKeypointsRatio->setObjectName(Parameters::kSURFGpuKeypointsRatio().c_str()); //SIFT detector _ui->sift_spinBox_nFeatures->setObjectName(Parameters::kSIFTNFeatures().c_str()); _ui->sift_spinBox_nOctaveLayers->setObjectName(Parameters::kSIFTNOctaveLayers().c_str()); _ui->sift_doubleSpinBox_contrastThr->setObjectName(Parameters::kSIFTContrastThreshold().c_str()); _ui->sift_doubleSpinBox_edgeThr->setObjectName(Parameters::kSIFTEdgeThreshold().c_str()); _ui->sift_doubleSpinBox_sigma->setObjectName(Parameters::kSIFTSigma().c_str()); //BRIEF descriptor _ui->briefBytes->setObjectName(Parameters::kBRIEFBytes().c_str()); //FAST detector _ui->fastSuppressNonMax->setObjectName(Parameters::kFASTNonmaxSuppression().c_str()); _ui->fastThreshold->setObjectName(Parameters::kFASTThreshold().c_str()); _ui->fastThresholdMin->setObjectName(Parameters::kFASTMinThreshold().c_str()); _ui->fastThresholdMax->setObjectName(Parameters::kFASTMaxThreshold().c_str()); _ui->fastGridRows->setObjectName(Parameters::kFASTGridRows().c_str()); _ui->fastGridCols->setObjectName(Parameters::kFASTGridCols().c_str()); _ui->fastGpu->setObjectName(Parameters::kFASTGpu().c_str()); _ui->fastKeypointRatio->setObjectName(Parameters::kFASTGpuKeypointsRatio().c_str()); //ORB detector _ui->doubleSpinBox_ORBScaleFactor->setObjectName(Parameters::kORBScaleFactor().c_str()); _ui->spinBox_ORBNLevels->setObjectName(Parameters::kORBNLevels().c_str()); _ui->spinBox_ORBEdgeThreshold->setObjectName(Parameters::kORBEdgeThreshold().c_str()); _ui->spinBox_ORBFirstLevel->setObjectName(Parameters::kORBFirstLevel().c_str()); _ui->spinBox_ORBWTA_K->setObjectName(Parameters::kORBWTA_K().c_str()); _ui->spinBox_ORBScoreType->setObjectName(Parameters::kORBScoreType().c_str()); _ui->spinBox_ORBPatchSize->setObjectName(Parameters::kORBPatchSize().c_str()); _ui->checkBox_ORBGpu->setObjectName(Parameters::kORBGpu().c_str()); //FREAK descriptor _ui->checkBox_FREAKOrientationNormalized->setObjectName(Parameters::kFREAKOrientationNormalized().c_str()); _ui->checkBox_FREAKScaleNormalized->setObjectName(Parameters::kFREAKScaleNormalized().c_str()); _ui->doubleSpinBox_FREAKPatternScale->setObjectName(Parameters::kFREAKPatternScale().c_str()); _ui->spinBox_FREAKNOctaves->setObjectName(Parameters::kFREAKNOctaves().c_str()); //GFTT detector _ui->doubleSpinBox_GFTT_qualityLevel->setObjectName(Parameters::kGFTTQualityLevel().c_str()); _ui->doubleSpinBox_GFTT_minDistance->setObjectName(Parameters::kGFTTMinDistance().c_str()); _ui->spinBox_GFTT_blockSize->setObjectName(Parameters::kGFTTBlockSize().c_str()); _ui->checkBox_GFTT_useHarrisDetector->setObjectName(Parameters::kGFTTUseHarrisDetector().c_str()); _ui->doubleSpinBox_GFTT_k->setObjectName(Parameters::kGFTTK().c_str()); //BRISK _ui->spinBox_BRISK_thresh->setObjectName(Parameters::kBRISKThresh().c_str()); _ui->spinBox_BRISK_octaves->setObjectName(Parameters::kBRISKOctaves().c_str()); _ui->doubleSpinBox_BRISK_patterScale->setObjectName(Parameters::kBRISKPatternScale().c_str()); // verifyHypotheses _ui->comboBox_vh_strategy->setObjectName(Parameters::kRtabmapVhStrategy().c_str()); _ui->surf_spinBox_matchCountMinAccepted->setObjectName(Parameters::kVhEpMatchCountMin().c_str()); _ui->surf_doubleSpinBox_ransacParam1->setObjectName(Parameters::kVhEpRansacParam1().c_str()); _ui->surf_doubleSpinBox_ransacParam2->setObjectName(Parameters::kVhEpRansacParam2().c_str()); // RGB-D SLAM _ui->general_checkBox_activateRGBD->setObjectName(Parameters::kRGBDEnabled().c_str()); _ui->rgdb_linearUpdate->setObjectName(Parameters::kRGBDLinearUpdate().c_str()); _ui->rgdb_angularUpdate->setObjectName(Parameters::kRGBDAngularUpdate().c_str()); _ui->rgdb_rehearsalWeightIgnoredWhileMoving->setObjectName(Parameters::kMemRehearsalWeightIgnoredWhileMoving().c_str()); _ui->rgdb_newMapOdomChange->setObjectName(Parameters::kRGBDNewMapOdomChangeDistance().c_str()); _ui->odomScanHistory->setObjectName(Parameters::kRGBDNeighborLinkRefining().c_str()); _ui->spinBox_maxLocalLocationsRetrieved->setObjectName(Parameters::kRGBDMaxLocalRetrieved().c_str()); _ui->graphOptimization_type->setObjectName(Parameters::kOptimizerStrategy().c_str()); _ui->graphOptimization_slam2d->setObjectName(Parameters::kOptimizerSlam2D().c_str()); _ui->graphOptimization_iterations->setObjectName(Parameters::kOptimizerIterations().c_str()); _ui->graphOptimization_covarianceIgnored->setObjectName(Parameters::kOptimizerVarianceIgnored().c_str()); _ui->graphOptimization_fromGraphEnd->setObjectName(Parameters::kRGBDOptimizeFromGraphEnd().c_str()); _ui->graphOptimization_maxError->setObjectName(Parameters::kRGBDOptimizeMaxError().c_str()); _ui->graphOptimization_stopEpsilon->setObjectName(Parameters::kOptimizerEpsilon().c_str()); _ui->graphOptimization_robust->setObjectName(Parameters::kOptimizerRobust().c_str()); _ui->graphPlan_goalReachedRadius->setObjectName(Parameters::kRGBDGoalReachedRadius().c_str()); _ui->graphPlan_goalsSavedInUserData->setObjectName(Parameters::kRGBDGoalsSavedInUserData().c_str()); _ui->graphPlan_stuckIterations->setObjectName(Parameters::kRGBDPlanStuckIterations().c_str()); _ui->graphPlan_linearVelocity->setObjectName(Parameters::kRGBDPlanLinearVelocity().c_str()); _ui->graphPlan_angularVelocity->setObjectName(Parameters::kRGBDPlanAngularVelocity().c_str()); _ui->groupBox_localDetection_time->setObjectName(Parameters::kRGBDProximityByTime().c_str()); _ui->groupBox_localDetection_space->setObjectName(Parameters::kRGBDProximityBySpace().c_str()); _ui->localDetection_radius->setObjectName(Parameters::kRGBDLocalRadius().c_str()); _ui->localDetection_maxDiffID->setObjectName(Parameters::kRGBDProximityMaxGraphDepth().c_str()); _ui->localDetection_pathFilteringRadius->setObjectName(Parameters::kRGBDProximityPathFilteringRadius().c_str()); _ui->checkBox_localSpacePathOdomPosesUsed->setObjectName(Parameters::kRGBDProximityPathRawPosesUsed().c_str()); _ui->checkBox_localSpaceAssembleScans->setObjectName(Parameters::kRGBDProximityPathScansMerged().c_str()); _ui->rgdb_localImmunizationRatio->setObjectName(Parameters::kRGBDLocalImmunizationRatio().c_str()); _ui->loopClosure_bowMinInliers->setObjectName(Parameters::kVisMinInliers().c_str()); _ui->loopClosure_bowInlierDistance->setObjectName(Parameters::kVisInlierDistance().c_str()); _ui->loopClosure_bowIterations->setObjectName(Parameters::kVisIterations().c_str()); _ui->loopClosure_bowRefineIterations->setObjectName(Parameters::kVisRefineIterations().c_str()); _ui->loopClosure_bowForce2D->setObjectName(Parameters::kVisForce2D().c_str()); _ui->loopClosure_estimationType->setObjectName(Parameters::kVisEstimationType().c_str()); connect(_ui->loopClosure_estimationType, SIGNAL(currentIndexChanged(int)), _ui->stackedWidget_loopClosureEstimation, SLOT(setCurrentIndex(int))); _ui->stackedWidget_loopClosureEstimation->setCurrentIndex(Parameters::defaultVisEstimationType()); _ui->loopClosure_bowEpipolarGeometryVar->setObjectName(Parameters::kVisEpipolarGeometryVar().c_str()); _ui->loopClosure_pnpReprojError->setObjectName(Parameters::kVisPnPReprojError().c_str()); _ui->loopClosure_pnpFlags->setObjectName(Parameters::kVisPnPFlags().c_str()); _ui->loopClosure_bowVarianceFromInliersCount->setObjectName(Parameters::kRegVarianceFromInliersCount().c_str()); _ui->loopClosure_reextract->setObjectName(Parameters::kRGBDLoopClosureReextractFeatures().c_str()); _ui->reextract_nn->setObjectName(Parameters::kVisNNType().c_str()); _ui->reextract_nndrRatio->setObjectName(Parameters::kVisNNDR().c_str()); _ui->reextract_type->setObjectName(Parameters::kVisFeatureType().c_str()); _ui->reextract_maxFeatures->setObjectName(Parameters::kVisMaxFeatures().c_str()); _ui->loopClosure_bowMaxDepth->setObjectName(Parameters::kVisMaxDepth().c_str()); _ui->loopClosure_bowMinDepth->setObjectName(Parameters::kVisMinDepth().c_str()); _ui->loopClosure_roi->setObjectName(Parameters::kVisRoiRatios().c_str()); _ui->subpix_winSize->setObjectName(Parameters::kVisSubPixWinSize().c_str()); _ui->subpix_iterations->setObjectName(Parameters::kVisSubPixIterations().c_str()); _ui->subpix_eps->setObjectName(Parameters::kVisSubPixEps().c_str()); _ui->loopClosure_icp->setObjectName(Parameters::kRGBDLoopClosureLinkRefining().c_str()); _ui->globalDetection_icpMaxTranslation->setObjectName(Parameters::kIcpMaxTranslation().c_str()); _ui->globalDetection_icpMaxRotation->setObjectName(Parameters::kIcpMaxRotation().c_str()); _ui->loopClosure_icp2D->setObjectName(Parameters::kIcp2D().c_str()); _ui->loopClosure_icpVoxelSize->setObjectName(Parameters::kIcpVoxelSize().c_str()); _ui->loopClosure_icpDownsamplingStep->setObjectName(Parameters::kIcpDownsamplingStep().c_str()); _ui->loopClosure_icpMaxCorrespondenceDistance->setObjectName(Parameters::kIcpMaxCorrespondenceDistance().c_str()); _ui->loopClosure_icpIterations->setObjectName(Parameters::kIcpIterations().c_str()); _ui->loopClosure_icpRatio->setObjectName(Parameters::kIcpCorrespondenceRatio().c_str()); _ui->loopClosure_icpPointToPlane->setObjectName(Parameters::kIcpPointToPlane().c_str()); _ui->loopClosure_icpPointToPlaneNormals->setObjectName(Parameters::kIcpPointToPlaneNormalNeighbors().c_str()); //Odometry _ui->odom_strategy->setObjectName(Parameters::kOdomStrategy().c_str()); _ui->odom_countdown->setObjectName(Parameters::kOdomResetCountdown().c_str()); _ui->odom_holonomic->setObjectName(Parameters::kOdomHolonomic().c_str()); _ui->odom_fillInfoData->setObjectName(Parameters::kOdomFillInfoData().c_str()); _ui->odom_dataBufferSize->setObjectName(Parameters::kOdomImageBufferSize().c_str()); //Odometry BOW _ui->odom_localHistory->setObjectName(Parameters::kOdomBowLocalHistorySize().c_str()); _ui->odom_fixedLocalMapPath->setObjectName(Parameters::kOdomBowFixedLocalMapPath().c_str()); connect(_ui->toolButton_odomBowFixedLocalMap, SIGNAL(clicked()), this, SLOT(changeOdomBowFixedLocalMapPath())); //Odometry Optical Flow _ui->odom_flow_winSize->setObjectName(Parameters::kOdomFlowWinSize().c_str()); _ui->odom_flow_maxLevel->setObjectName(Parameters::kOdomFlowMaxLevel().c_str()); _ui->odom_flow_iterations->setObjectName(Parameters::kOdomFlowIterations().c_str()); _ui->odom_flow_eps->setObjectName(Parameters::kOdomFlowEps().c_str()); //Odometry Mono _ui->doubleSpinBox_minFlow->setObjectName(Parameters::kOdomMonoInitMinFlow().c_str()); _ui->doubleSpinBox_minInitTranslation->setObjectName(Parameters::kOdomMonoInitMinTranslation().c_str()); _ui->doubleSpinBox_minTranslation->setObjectName(Parameters::kOdomMonoMinTranslation().c_str()); _ui->doubleSpinBox_maxVariance->setObjectName(Parameters::kOdomMonoMaxVariance().c_str()); //Odometry particle filter _ui->odom_particleFiltering->setObjectName(Parameters::kOdomParticleFiltering().c_str()); _ui->spinBox_particleSize->setObjectName(Parameters::kOdomParticleSize().c_str()); _ui->doubleSpinBox_particleNoiseT->setObjectName(Parameters::kOdomParticleNoiseT().c_str()); _ui->doubleSpinBox_particleLambdaT->setObjectName(Parameters::kOdomParticleLambdaT().c_str()); _ui->doubleSpinBox_particleNoiseR->setObjectName(Parameters::kOdomParticleNoiseR().c_str()); _ui->doubleSpinBox_particleLambdaR->setObjectName(Parameters::kOdomParticleLambdaR().c_str()); //Stereo _ui->stereo_flow_winSize->setObjectName(Parameters::kStereoWinSize().c_str()); _ui->stereo_flow_maxLevel->setObjectName(Parameters::kStereoMaxLevel().c_str()); _ui->stereo_flow_iterations->setObjectName(Parameters::kStereoIterations().c_str()); _ui->stereo_flow_eps->setObjectName(Parameters::kStereoEps().c_str()); _ui->stereo_maxSlope->setObjectName(Parameters::kStereoMaxSlope().c_str()); setupSignals(); // custom signals connect(_ui->doubleSpinBox_kp_roi0, SIGNAL(valueChanged(double)), this, SLOT(updateKpROI())); connect(_ui->doubleSpinBox_kp_roi1, SIGNAL(valueChanged(double)), this, SLOT(updateKpROI())); connect(_ui->doubleSpinBox_kp_roi2, SIGNAL(valueChanged(double)), this, SLOT(updateKpROI())); connect(_ui->doubleSpinBox_kp_roi3, SIGNAL(valueChanged(double)), this, SLOT(updateKpROI())); //Create a model from the stacked widgets // This will add all parameters to the parameters Map _ui->stackedWidget->setCurrentIndex(0); this->setupTreeView(); connect(_ui->treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(clicked(QModelIndex))); _obsoletePanels = kPanelAll; _progressDialog = new QProgressDialog(this); _progressDialog->setWindowTitle(tr("Read parameters...")); _progressDialog->setMaximum(2); } PreferencesDialog::~PreferencesDialog() { // remove tmp ini file QFile::remove(getTmpIniFilePath()); delete _ui; } void PreferencesDialog::init() { UDEBUG(""); //First set all default values const ParametersMap & defaults = Parameters::getDefaultParameters(); for(ParametersMap::const_iterator iter=defaults.begin(); iter!=defaults.end(); ++iter) { this->setParameter(iter->first, iter->second); } this->readSettings(); this->writeSettings(getTmpIniFilePath()); _initialized = true; } void PreferencesDialog::setCurrentPanelToSource() { QList boxes = this->getGroupBoxes(); for(int i =0;igroupBox_source0) { _ui->stackedWidget->setCurrentIndex(i); _ui->treeView->setCurrentIndex(_indexModel->index(i-2, 0)); break; } } } void PreferencesDialog::saveSettings() { writeSettings(); } void PreferencesDialog::setupTreeView() { if(_indexModel) { _ui->treeView->setModel(0); delete _indexModel; } _indexModel = new QStandardItemModel(this); // Parse the model QList boxes = this->getGroupBoxes(); if(_ui->radioButton_basic->isChecked()) { boxes = boxes.mid(0,5); } else // Advanced { boxes.removeAt(4); } QStandardItem * parentItem = _indexModel->invisibleRootItem(); int index = 0; this->parseModel(boxes, parentItem, 0, index); // recursive method if(_ui->radioButton_advanced->isChecked() && index != _ui->stackedWidget->count()-1) { ULOGGER_ERROR("The tree model is not the same size of the stacked widgets...%d vs %d advanced stacks", index, _ui->stackedWidget->count()-1); } int currentIndex = _ui->stackedWidget->currentIndex(); if(_ui->radioButton_basic->isChecked()) { if(currentIndex >= 4) { _ui->stackedWidget->setCurrentIndex(4); currentIndex = 4; } } else // Advanced { if(currentIndex == 4) { _ui->stackedWidget->setCurrentIndex(5); } } _ui->treeView->setModel(_indexModel); if(currentIndex == 0) // GUI { _ui->treeView->setCurrentIndex(_indexModel->index(0, 0)); } else if(currentIndex == 1) //3d rendering { _ui->treeView->setCurrentIndex(_indexModel->index(0, 0).child(0,0)); } else if(currentIndex == 2) // logging { _ui->treeView->setCurrentIndex(_indexModel->index(0, 0).child(1,0)); } else // source, rtabmap { _ui->treeView->setCurrentIndex(_indexModel->index(currentIndex-2, 0)); } _ui->treeView->expandToDepth(0); } // recursive... bool PreferencesDialog::parseModel(QList & boxes, QStandardItem * parentItem, int currentLevel, int & absoluteIndex) { if(parentItem == 0) { ULOGGER_ERROR("Parent item is null !"); return false; } QStandardItem * currentItem = 0; while(absoluteIndex < boxes.size()) { QString objectName = boxes.at(absoluteIndex)->objectName(); QString title = boxes.at(absoluteIndex)->title(); bool ok = false; int lvl = QString(objectName.at(objectName.size()-1)).toInt(&ok); if(!ok) { ULOGGER_ERROR("Error while parsing the first number of the QGroupBox title (%s), the first character must be the number in the hierarchy", title.toStdString().c_str()); return false; } if(lvl == currentLevel) { QStandardItem * item = new QStandardItem(title); item->setData(absoluteIndex); currentItem = item; //ULOGGER_DEBUG("PreferencesDialog::parseModel() lvl(%d) Added %s", currentLevel, title.toStdString().c_str()); parentItem->appendRow(item); ++absoluteIndex; } else if(lvl > currentLevel) { if(lvl>currentLevel+1) { ULOGGER_ERROR("Intermediary lvl doesn't exist, lvl %d to %d, indexes %d and %d", currentLevel, lvl, absoluteIndex-1, absoluteIndex); return false; } else { parseModel(boxes, currentItem, currentLevel+1, absoluteIndex); // recursive } } else { return false; } } return true; } void PreferencesDialog::setupSignals() { const rtabmap::ParametersMap & parameters = Parameters::getDefaultParameters(); for(rtabmap::ParametersMap::const_iterator iter=parameters.begin(); iter!=parameters.end(); ++iter) { QWidget * obj = _ui->stackedWidget->findChild((*iter).first.c_str()); if(obj) { // set tooltip as the parameter name obj->setToolTip(tr("%1 (Default=\"%2\")").arg(iter->first.c_str()).arg(iter->second.c_str())); QSpinBox * spin = qobject_cast(obj); QDoubleSpinBox * doubleSpin = qobject_cast(obj); QComboBox * combo = qobject_cast(obj); QCheckBox * check = qobject_cast(obj); QRadioButton * radio = qobject_cast(obj); QLineEdit * lineEdit = qobject_cast(obj); QGroupBox * groupBox = qobject_cast(obj); if(spin) { connect(spin, SIGNAL(valueChanged(int)), this, SLOT(addParameter(int))); } else if(doubleSpin) { connect(doubleSpin, SIGNAL(valueChanged(double)), this, SLOT(addParameter(double))); } else if(combo) { connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(addParameter(int))); } else if(check) { connect(check, SIGNAL(toggled(bool)), this, SLOT(addParameter(bool))); } else if(radio) { connect(radio, SIGNAL(toggled(bool)), this, SLOT(addParameter(bool))); } else if(lineEdit) { connect(lineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(addParameter(const QString &))); } else if(groupBox) { connect(groupBox, SIGNAL(clicked(bool)), this, SLOT(addParameter(bool))); } else { ULOGGER_WARN("QWidget called %s can't be cast to a supported widget", (*iter).first.c_str()); } } else { ULOGGER_WARN("Can't find the related QWidget for parameter %s", (*iter).first.c_str()); } } } void PreferencesDialog::clicked(const QModelIndex &index) { QStandardItem * item = _indexModel->itemFromIndex(index); if(item && item->isEnabled()) { int index = item->data().toInt(); if(_ui->radioButton_advanced->isChecked() && index >= 4) { ++index; } _ui->stackedWidget->setCurrentIndex(index); _ui->scrollArea->horizontalScrollBar()->setValue(0); _ui->scrollArea->verticalScrollBar()->setValue(0); } } void PreferencesDialog::closeEvent(QCloseEvent *event) { UDEBUG(""); _parameters.clear(); _obsoletePanels = kPanelDummy; this->readGuiSettings(getTmpIniFilePath()); this->readCameraSettings(getTmpIniFilePath()); event->accept(); } void PreferencesDialog::closeDialog ( QAbstractButton * button ) { UDEBUG(""); QDialogButtonBox::ButtonRole role = _ui->buttonBox_global->buttonRole(button); switch(role) { case QDialogButtonBox::RejectRole: _parameters.clear(); _obsoletePanels = kPanelDummy; this->readGuiSettings(getTmpIniFilePath()); this->readCameraSettings(getTmpIniFilePath()); this->reject(); break; case QDialogButtonBox::AcceptRole: updateBasicParameter();// make that changes without editing finished signal are updated. if((_obsoletePanels & kPanelAll) || _parameters.size()) { if(validateForm()) { writeSettings(getTmpIniFilePath()); this->accept(); } } else { this->accept(); } break; default: break; } } void PreferencesDialog::resetApply ( QAbstractButton * button ) { QDialogButtonBox::ButtonRole role = _ui->buttonBox_local->buttonRole(button); switch(role) { case QDialogButtonBox::ApplyRole: updateBasicParameter();// make that changes without editing finished signal are updated. if(validateForm()) { writeSettings(getTmpIniFilePath()); } break; case QDialogButtonBox::ResetRole: resetSettings(_ui->stackedWidget->currentIndex()); break; default: break; } } void PreferencesDialog::resetSettings(QGroupBox * groupBox) { if(groupBox->objectName() == _ui->groupBox_generalSettingsGui0->objectName()) { _ui->general_checkBox_imagesKept->setChecked(true); _ui->checkBox_beep->setChecked(false); _ui->checkBox_notifyWhenNewGlobalPathIsReceived->setChecked(false); _ui->checkBox_verticalLayoutUsed->setChecked(true); _ui->checkBox_imageRejectedShown->setChecked(true); _ui->checkBox_imageHighestHypShown->setChecked(false); _ui->spinBox_odomQualityWarnThr->setValue(50); _ui->checkBox_posteriorGraphView->setChecked(true); } else if(groupBox->objectName() == _ui->groupBox_cloudRendering1->objectName()) { for(int i=0; i<2; ++i) { _3dRenderingShowClouds[i]->setChecked(true); _3dRenderingVoxelSize[i]->setValue(i==0?0.01:0.0); // voxel of 1 cm for cloud substracting _3dRenderingDecimation[i]->setValue(i==0?4:2); _3dRenderingMaxDepth[i]->setValue(0.0); _3dRenderingShowScans[i]->setChecked(true); _3dRenderingDownsamplingScan[i]->setValue(0); _3dRenderingVoxelSizeScan[i]->setValue(0.0); _3dRenderingOpacity[i]->setValue(i==0?1.0:0.5); _3dRenderingPtSize[i]->setValue(2); _3dRenderingOpacityScan[i]->setValue(i==0?1.0:0.5); _3dRenderingPtSizeScan[i]->setValue(2); } _ui->checkBox_showGraphs->setChecked(true); _ui->checkBox_showLabels->setChecked(true); _ui->checkBox_meshing->setChecked(false); _ui->doubleSpinBox_gp3Radius->setValue(0.04); _ui->doubleSpinBox_gp3Mu->setValue(2.5); _ui->spinBox_normalKSearch->setValue(20); _ui->checkBox_mls->setChecked(false); _ui->doubleSpinBox_mlsRadius->setValue(0.04); _ui->checkBox_nodeFiltering->setChecked(false); _ui->checkBox_subtractFiltering->setChecked(true); _ui->doubleSpinBox_cloudFilterRadius->setValue(0.1); _ui->doubleSpinBox_cloudFilterAngle->setValue(30); _ui->spinBox_substractFilteringMinPts->setValue(1); _ui->checkBox_map_shown->setChecked(false); _ui->doubleSpinBox_map_resolution->setValue(0.05); _ui->checkBox_map_occupancyFrom3DCloud->setChecked(false); _ui->checkBox_map_erode->setChecked(false); _ui->doubleSpinBox_map_opacity->setValue(0.75); } else if(groupBox->objectName() == _ui->groupBox_logging1->objectName()) { _ui->comboBox_loggerLevel->setCurrentIndex(2); _ui->comboBox_loggerEventLevel->setCurrentIndex(3); _ui->comboBox_loggerPauseLevel->setCurrentIndex(3); _ui->checkBox_logger_printTime->setChecked(true); _ui->comboBox_loggerType->setCurrentIndex(1); } else if(groupBox->objectName() == _ui->groupBox_source0->objectName()) { _ui->general_doubleSpinBox_imgRate->setValue(0.0); _ui->source_mirroring->setChecked(false); _ui->lineEdit_calibrationFile->clear(); _ui->comboBox_sourceType->setCurrentIndex(kSrcRGBD); _ui->lineEdit_sourceDevice->setText(""); _ui->lineEdit_sourceLocalTransform->setText("0 0 1 -1 0 0 0 -1 0"); _ui->source_comboBox_image_type->setCurrentIndex(kSrcUsbDevice-kSrcUsbDevice); _ui->source_images_spinBox_startPos->setValue(1); _ui->source_images_refreshDir->setChecked(false); _ui->checkBox_rgbImages_rectify->setChecked(false); _ui->checkBox_rgbVideo_rectify->setChecked(false); _ui->source_checkBox_ignoreOdometry->setChecked(false); _ui->source_checkBox_ignoreGoalDelay->setChecked(true); _ui->source_checkBox_ignoreGoals->setChecked(true); _ui->source_spinBox_databaseStartPos->setValue(0); _ui->source_checkBox_useDbStamps->setChecked(true); #ifdef _WIN32 _ui->comboBox_cameraRGBD->setCurrentIndex(kSrcOpenNI2-kSrcRGBD); // openni2 #else if(CameraFreenect::available()) { _ui->comboBox_cameraRGBD->setCurrentIndex(kSrcFreenect-kSrcRGBD); // freenect } else if(CameraOpenNI2::available()) { _ui->comboBox_cameraRGBD->setCurrentIndex(kSrcOpenNI2-kSrcRGBD); // openni2 } else { _ui->comboBox_cameraRGBD->setCurrentIndex(kSrcOpenNI_PCL-kSrcRGBD); // openni-pcl } #endif if(CameraStereoDC1394::available()) { _ui->comboBox_cameraStereo->setCurrentIndex(kSrcDC1394-kSrcStereo); // dc1394 } else if(CameraStereoFlyCapture2::available()) { _ui->comboBox_cameraStereo->setCurrentIndex(kSrcFlyCapture2-kSrcStereo); // flycapture } else { _ui->comboBox_cameraStereo->setCurrentIndex(kSrcStereoImages-kSrcStereo); // stereo images } _ui->checkbox_rgbd_colorOnly->setChecked(false); _ui->checkbox_stereo_depthGenerated->setChecked(false); _ui->openni2_autoWhiteBalance->setChecked(true); _ui->openni2_autoExposure->setChecked(true); _ui->openni2_exposure->setValue(0); _ui->openni2_gain->setValue(100); _ui->openni2_mirroring->setChecked(false); _ui->openni2_stampsIdsUsed->setChecked(false); _ui->comboBox_freenect2Format->setCurrentIndex(0); _ui->doubleSpinBox_freenect2MinDepth->setValue(0.3); _ui->doubleSpinBox_freenect2MaxDepth->setValue(12.0); _ui->checkBox_freenect2BilateralFiltering->setChecked(true); _ui->checkBox_freenect2EdgeAwareFiltering->setChecked(true); _ui->checkBox_freenect2NoiseFiltering->setChecked(true); _ui->lineEdit_openniOniPath->clear(); _ui->lineEdit_openni2OniPath->clear(); _ui->lineEdit_cameraRGBDImages_path_rgb->setText(""); _ui->lineEdit_cameraRGBDImages_path_depth->setText(""); _ui->checkBox_RGBDImages_timestamps->setChecked(false); _ui->doubleSpinBox_cameraRGBDImages_scale->setValue(1.0); _ui->lineEdit_cameraRGBDImages_timestamps->setText(""); _ui->source_comboBox_image_type->setCurrentIndex(kSrcDC1394-kSrcDC1394); _ui->lineEdit_cameraStereoImages_timestamps->setText(""); _ui->lineEdit_cameraStereoImages_path_left->setText(""); _ui->lineEdit_cameraStereoImages_path_right->setText(""); _ui->lineEdit_cameraStereoImages_path_scans->setText(""); _ui->lineEdit_cameraStereoImages_laser_transform->setText("0 0 0 0 0 0"); _ui->spinBox_cameraStereoImages_max_scan_pts->setValue(0); _ui->checkBox_stereoImages_timestamps->setChecked(false); _ui->checkBox_stereoImages_rectify->setChecked(false); _ui->lineEdit_cameraStereoVideo_path->setText(""); _ui->checkBox_stereoVideo_rectify->setChecked(false); } else if(groupBox->objectName() == _ui->groupBox_rtabmap_basic0->objectName()) { _ui->general_doubleSpinBox_timeThr_2->setValue(Parameters::defaultRtabmapTimeThr()); _ui->general_doubleSpinBox_hardThr_2->setValue(Parameters::defaultRtabmapLoopThr()); _ui->doubleSpinBox_similarityThreshold_2->setValue(Parameters::defaultMemRehearsalSimilarity()); _ui->general_spinBox_imagesBufferSize_2->setValue(Parameters::defaultRtabmapImageBufferSize()); _ui->general_spinBox_maxStMemSize_2->setValue(Parameters::defaultMemSTMSize()); _ui->general_checkBox_publishStats_2->setChecked(Parameters::defaultRtabmapPublishStats()); _ui->general_checkBox_activateRGBD_2->setChecked(Parameters::defaultRGBDEnabled()); _ui->general_checkBox_SLAM_mode_2->setChecked(Parameters::defaultMemIncrementalMemory()); _ui->general_doubleSpinBox_detectionRate_2->setValue(Parameters::defaultRtabmapDetectionRate()); // match the advanced (spin and doubleSpin boxes) _ui->general_doubleSpinBox_timeThr->setValue(Parameters::defaultRtabmapTimeThr()); _ui->general_doubleSpinBox_hardThr->setValue(Parameters::defaultRtabmapLoopThr()); _ui->doubleSpinBox_similarityThreshold->setValue(Parameters::defaultMemRehearsalSimilarity()); _ui->general_spinBox_imagesBufferSize->setValue(Parameters::defaultRtabmapImageBufferSize()); _ui->general_spinBox_maxStMemSize->setValue(Parameters::defaultMemSTMSize()); _ui->general_doubleSpinBox_detectionRate->setValue(Parameters::defaultRtabmapDetectionRate()); } else { QObjectList children = groupBox->children(); rtabmap::ParametersMap defaults = Parameters::getDefaultParameters(); std::string key; for(int i=0; iobjectName().toStdString(); if(uContains(defaults, key)) { this->setParameter(key, defaults.at(key)); if(qobject_cast(children.at(i))) { this->resetSettings((QGroupBox*)children.at(i)); } } else if(qobject_cast(children.at(i))) { this->resetSettings((QGroupBox*)children.at(i)); } else if(qobject_cast(children.at(i))) { QStackedWidget * stackedWidget = (QStackedWidget*)children.at(i); for(int j=0; jcount(); ++j) { const QObjectList & children2 = stackedWidget->widget(j)->children(); for(int k=0; k(children2.at(k))) { this->resetSettings((QGroupBox*)children2.at(k)); } } } } } if(groupBox->findChild(_ui->lineEdit_kp_roi->objectName())) { this->setupKpRoiPanel(); } } } void PreferencesDialog::resetSettings(int panelNumber) { QList boxes = this->getGroupBoxes(); if(panelNumber >= 0 && panelNumber < boxes.size()) { this->resetSettings(boxes.at(panelNumber)); } else if(panelNumber == -1) { for(QList::iterator iter = boxes.begin(); iter!=boxes.end(); ++iter) { this->resetSettings(*iter); } } else { ULOGGER_WARN("panel number and the number of stacked widget doesn't match"); } } QString PreferencesDialog::getWorkingDirectory() const { return _ui->lineEdit_workingDirectory->text(); } QString PreferencesDialog::getIniFilePath() const { QString privatePath = QDir::homePath() + "/.rtabmap"; if(!QDir(privatePath).exists()) { QDir::home().mkdir(".rtabmap"); } return privatePath + "/rtabmap.ini"; } QString PreferencesDialog::getTmpIniFilePath() const { return getIniFilePath()+".tmp"; } void PreferencesDialog::loadConfigFrom() { QString path = QFileDialog::getOpenFileName(this, tr("Load settings..."), this->getWorkingDirectory(), "*.ini"); if(!path.isEmpty()) { this->readSettings(path); } } void PreferencesDialog::readSettings(const QString & filePath) { ULOGGER_DEBUG("%s", filePath.toStdString().c_str()); readGuiSettings(filePath); readCameraSettings(filePath); if(!readCoreSettings(filePath)) { _parameters.clear(); _obsoletePanels = kPanelDummy; // only keep GUI settings QStandardItem * parentItem = _indexModel->invisibleRootItem(); if(parentItem) { for(int i=1; irowCount(); ++i) { parentItem->child(i)->setEnabled(false); } } _ui->radioButton_basic->setEnabled(false); _ui->radioButton_advanced->setEnabled(false); } else { // enable settings QStandardItem * parentItem = _indexModel->invisibleRootItem(); if(parentItem) { for(int i=0; irowCount(); ++i) { parentItem->child(i)->setEnabled(true); } } _ui->radioButton_basic->setEnabled(true); _ui->radioButton_advanced->setEnabled(true); } } void PreferencesDialog::readGuiSettings(const QString & filePath) { QString path = getIniFilePath(); if(!filePath.isEmpty()) { path = filePath; } QSettings settings(path, QSettings::IniFormat); settings.beginGroup("Gui"); settings.beginGroup("General"); _ui->general_checkBox_imagesKept->setChecked(settings.value("imagesKept", _ui->general_checkBox_imagesKept->isChecked()).toBool()); _ui->comboBox_loggerLevel->setCurrentIndex(settings.value("loggerLevel", _ui->comboBox_loggerLevel->currentIndex()).toInt()); _ui->comboBox_loggerEventLevel->setCurrentIndex(settings.value("loggerEventLevel", _ui->comboBox_loggerEventLevel->currentIndex()).toInt()); _ui->comboBox_loggerPauseLevel->setCurrentIndex(settings.value("loggerPauseLevel", _ui->comboBox_loggerPauseLevel->currentIndex()).toInt()); _ui->comboBox_loggerType->setCurrentIndex(settings.value("loggerType", _ui->comboBox_loggerType->currentIndex()).toInt()); _ui->checkBox_logger_printTime->setChecked(settings.value("loggerPrintTime", _ui->checkBox_logger_printTime->isChecked()).toBool()); _ui->checkBox_verticalLayoutUsed->setChecked(settings.value("verticalLayoutUsed", _ui->checkBox_verticalLayoutUsed->isChecked()).toBool()); _ui->checkBox_imageRejectedShown->setChecked(settings.value("imageRejectedShown", _ui->checkBox_imageRejectedShown->isChecked()).toBool()); _ui->checkBox_imageHighestHypShown->setChecked(settings.value("imageHighestHypShown", _ui->checkBox_imageHighestHypShown->isChecked()).toBool()); _ui->checkBox_beep->setChecked(settings.value("beep", _ui->checkBox_beep->isChecked()).toBool()); _ui->checkBox_notifyWhenNewGlobalPathIsReceived->setChecked(settings.value("notifyNewGlobalPath", _ui->checkBox_notifyWhenNewGlobalPathIsReceived->isChecked()).toBool()); _ui->spinBox_odomQualityWarnThr->setValue(settings.value("odomQualityThr", _ui->spinBox_odomQualityWarnThr->value()).toInt()); _ui->checkBox_posteriorGraphView->setChecked(settings.value("posteriorGraphView", _ui->checkBox_posteriorGraphView->isChecked()).toBool()); for(int i=0; i<2; ++i) { _3dRenderingShowClouds[i]->setChecked(settings.value(QString("showClouds%1").arg(i), _3dRenderingShowClouds[i]->isChecked()).toBool()); _3dRenderingVoxelSize[i]->setValue(settings.value(QString("voxelSize%1").arg(i), _3dRenderingVoxelSize[i]->value()).toDouble()); _3dRenderingDecimation[i]->setValue(settings.value(QString("decimation%1").arg(i), _3dRenderingDecimation[i]->value()).toInt()); _3dRenderingMaxDepth[i]->setValue(settings.value(QString("maxDepth%1").arg(i), _3dRenderingMaxDepth[i]->value()).toDouble()); _3dRenderingShowScans[i]->setChecked(settings.value(QString("showScans%1").arg(i), _3dRenderingShowScans[i]->isChecked()).toBool()); _3dRenderingDownsamplingScan[i]->setValue(settings.value(QString("downsamplingScan%1").arg(i), _3dRenderingDownsamplingScan[i]->value()).toInt()); _3dRenderingVoxelSizeScan[i]->setValue(settings.value(QString("voxelSizeScan%1").arg(i), _3dRenderingVoxelSizeScan[i]->value()).toDouble()); _3dRenderingOpacity[i]->setValue(settings.value(QString("opacity%1").arg(i), _3dRenderingOpacity[i]->value()).toDouble()); _3dRenderingPtSize[i]->setValue(settings.value(QString("ptSize%1").arg(i), _3dRenderingPtSize[i]->value()).toInt()); _3dRenderingOpacityScan[i]->setValue(settings.value(QString("opacityScan%1").arg(i), _3dRenderingOpacityScan[i]->value()).toDouble()); _3dRenderingPtSizeScan[i]->setValue(settings.value(QString("ptSizeScan%1").arg(i), _3dRenderingPtSizeScan[i]->value()).toInt()); } _ui->checkBox_showGraphs->setChecked(settings.value("showGraphs", _ui->checkBox_showGraphs->isChecked()).toBool()); _ui->checkBox_showLabels->setChecked(settings.value("showLabels", _ui->checkBox_showLabels->isChecked()).toBool()); _ui->checkBox_meshing->setChecked(settings.value("meshing", _ui->checkBox_meshing->isChecked()).toBool()); _ui->doubleSpinBox_gp3Radius->setValue(settings.value("meshGP3Radius", _ui->doubleSpinBox_gp3Radius->value()).toDouble()); _ui->doubleSpinBox_gp3Mu->setValue(settings.value("meshGP3Mu", _ui->doubleSpinBox_gp3Mu->value()).toDouble()); _ui->spinBox_normalKSearch->setValue(settings.value("meshNormalKSearch", _ui->spinBox_normalKSearch->value()).toInt()); _ui->checkBox_mls->setChecked(settings.value("meshSmoothing", _ui->checkBox_mls->isChecked()).toBool()); _ui->doubleSpinBox_mlsRadius->setValue(settings.value("meshSmoothingRadius", _ui->doubleSpinBox_mlsRadius->value()).toDouble()); _ui->checkBox_nodeFiltering->setChecked(settings.value("cloudFiltering", _ui->checkBox_nodeFiltering->isChecked()).toBool()); _ui->checkBox_subtractFiltering->setChecked(settings.value("subtractFiltering", _ui->checkBox_subtractFiltering->isChecked()).toBool()); _ui->doubleSpinBox_cloudFilterRadius->setValue(settings.value("cloudFilteringRadius", _ui->doubleSpinBox_cloudFilterRadius->value()).toDouble()); _ui->doubleSpinBox_cloudFilterAngle->setValue(settings.value("cloudFilteringAngle", _ui->doubleSpinBox_cloudFilterAngle->value()).toDouble()); _ui->spinBox_substractFilteringMinPts->setValue(settings.value("cloudFilteringAngleMinPts", _ui->spinBox_substractFilteringMinPts->value()).toDouble()); _ui->checkBox_map_shown->setChecked(settings.value("gridMapShown", _ui->checkBox_map_shown->isChecked()).toBool()); _ui->doubleSpinBox_map_resolution->setValue(settings.value("gridMapResolution", _ui->doubleSpinBox_map_resolution->value()).toDouble()); _ui->checkBox_map_occupancyFrom3DCloud->setChecked(settings.value("gridMapOccupancyFrom3DCloud", _ui->checkBox_map_occupancyFrom3DCloud->isChecked()).toBool()); _ui->checkBox_map_erode->setChecked(settings.value("gridMapEroded", _ui->checkBox_map_erode->isChecked()).toBool()); _ui->doubleSpinBox_map_opacity->setValue(settings.value("gridMapOpacity", _ui->doubleSpinBox_map_opacity->value()).toDouble()); settings.endGroup(); // General settings.endGroup(); // rtabmap } void PreferencesDialog::readCameraSettings(const QString & filePath) { QString path = getIniFilePath(); if(!filePath.isEmpty()) { path = filePath; } QSettings settings(path, QSettings::IniFormat); settings.beginGroup("Camera"); _ui->general_doubleSpinBox_imgRate->setValue(settings.value("imgRate", _ui->general_doubleSpinBox_imgRate->value()).toDouble()); _ui->source_mirroring->setChecked(settings.value("mirroring", _ui->source_mirroring->isChecked()).toBool()); _ui->lineEdit_calibrationFile->setText(settings.value("calibrationName", _ui->lineEdit_calibrationFile->text()).toString()); _ui->comboBox_sourceType->setCurrentIndex(settings.value("type", _ui->comboBox_sourceType->currentIndex()).toInt()); _ui->lineEdit_sourceDevice->setText(settings.value("device",_ui->lineEdit_sourceDevice->text()).toString()); _ui->lineEdit_sourceLocalTransform->setText(settings.value("localTransform",_ui->lineEdit_sourceLocalTransform->text()).toString()); settings.beginGroup("rgbd"); _ui->comboBox_cameraRGBD->setCurrentIndex(settings.value("driver", _ui->comboBox_cameraRGBD->currentIndex()).toInt()); _ui->checkbox_rgbd_colorOnly->setChecked(settings.value("rgbdColorOnly", _ui->checkbox_rgbd_colorOnly->isChecked()).toBool()); settings.endGroup(); // rgbd settings.beginGroup("stereo"); _ui->comboBox_cameraStereo->setCurrentIndex(settings.value("driver", _ui->comboBox_cameraStereo->currentIndex()).toInt()); _ui->checkbox_stereo_depthGenerated->setChecked(settings.value("depthGenerated", _ui->checkbox_stereo_depthGenerated->isChecked()).toBool()); settings.endGroup(); // stereo settings.beginGroup("rgb"); _ui->source_comboBox_image_type->setCurrentIndex(settings.value("driver", _ui->source_comboBox_image_type->currentIndex()).toInt()); settings.endGroup(); // rgb settings.beginGroup("Openni"); _ui->lineEdit_openniOniPath->setText(settings.value("oniPath", _ui->lineEdit_openniOniPath->text()).toString()); settings.endGroup(); // Openni settings.beginGroup("Openni2"); _ui->openni2_autoWhiteBalance->setChecked(settings.value("autoWhiteBalance", _ui->openni2_autoWhiteBalance->isChecked()).toBool()); _ui->openni2_autoExposure->setChecked(settings.value("autoExposure", _ui->openni2_autoExposure->isChecked()).toBool()); _ui->openni2_exposure->setValue(settings.value("exposure", _ui->openni2_exposure->value()).toInt()); _ui->openni2_gain->setValue(settings.value("gain", _ui->openni2_gain->value()).toInt()); _ui->openni2_mirroring->setChecked(settings.value("mirroring", _ui->openni2_mirroring->isChecked()).toBool()); _ui->openni2_stampsIdsUsed->setChecked(settings.value("stampsIdsUsed", _ui->openni2_stampsIdsUsed->isChecked()).toBool()); _ui->lineEdit_openni2OniPath->setText(settings.value("oniPath", _ui->lineEdit_openni2OniPath->text()).toString()); settings.endGroup(); // Openni2 settings.beginGroup("Freenect2"); _ui->comboBox_freenect2Format->setCurrentIndex(settings.value("format", _ui->comboBox_freenect2Format->currentIndex()).toInt()); _ui->doubleSpinBox_freenect2MinDepth->setValue(settings.value("minDepth", _ui->doubleSpinBox_freenect2MinDepth->value()).toDouble()); _ui->doubleSpinBox_freenect2MaxDepth->setValue(settings.value("maxDepth", _ui->doubleSpinBox_freenect2MaxDepth->value()).toDouble()); _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()); settings.endGroup(); // Freenect2 settings.beginGroup("RGBDImages"); _ui->lineEdit_cameraRGBDImages_path_rgb->setText(settings.value("path_rgb", _ui->lineEdit_cameraRGBDImages_path_rgb->text()).toString()); _ui->lineEdit_cameraRGBDImages_path_depth->setText(settings.value("path_depth", _ui->lineEdit_cameraRGBDImages_path_depth->text()).toString()); _ui->checkBox_RGBDImages_timestamps->setChecked(settings.value("filenames_as_stamps",_ui->checkBox_RGBDImages_timestamps->isChecked()).toBool()); _ui->lineEdit_cameraRGBDImages_timestamps->setText(settings.value("stamps", _ui->lineEdit_cameraRGBDImages_timestamps->text()).toString()); _ui->doubleSpinBox_cameraRGBDImages_scale->setValue(settings.value("scale", _ui->doubleSpinBox_cameraRGBDImages_scale->value()).toDouble()); settings.endGroup(); // RGBDImages settings.beginGroup("StereoImages"); _ui->lineEdit_cameraStereoImages_timestamps->setText(settings.value("stamps", _ui->lineEdit_cameraStereoImages_timestamps->text()).toString()); _ui->lineEdit_cameraStereoImages_path_left->setText(settings.value("path_left", _ui->lineEdit_cameraStereoImages_path_left->text()).toString()); _ui->lineEdit_cameraStereoImages_path_right->setText(settings.value("path_right", _ui->lineEdit_cameraStereoImages_path_right->text()).toString()); _ui->lineEdit_cameraStereoImages_path_scans->setText(settings.value("path_scans", _ui->lineEdit_cameraStereoImages_path_scans->text()).toString()); _ui->lineEdit_cameraStereoImages_laser_transform->setText(settings.value("scan_transform", _ui->lineEdit_cameraStereoImages_laser_transform->text()).toString()); _ui->spinBox_cameraStereoImages_max_scan_pts->setValue(settings.value("scan_max_pts", _ui->spinBox_cameraStereoImages_max_scan_pts->value()).toInt()); _ui->checkBox_stereoImages_timestamps->setChecked(settings.value("filenames_as_stamps",_ui->checkBox_stereoImages_timestamps->isChecked()).toBool()); _ui->checkBox_stereoImages_rectify->setChecked(settings.value("rectify",_ui->checkBox_stereoImages_rectify->isChecked()).toBool()); settings.endGroup(); // StereoImages settings.beginGroup("StereoVideo"); _ui->lineEdit_cameraStereoVideo_path->setText(settings.value("path", _ui->lineEdit_cameraStereoVideo_path->text()).toString()); _ui->checkBox_stereoVideo_rectify->setChecked(settings.value("rectify",_ui->checkBox_stereoVideo_rectify->isChecked()).toBool()); settings.endGroup(); // StereoVideo settings.beginGroup("Images"); _ui->source_images_lineEdit_path->setText(settings.value("path", _ui->source_images_lineEdit_path->text()).toString()); _ui->source_images_spinBox_startPos->setValue(settings.value("startPos",_ui->source_images_spinBox_startPos->value()).toInt()); _ui->source_images_refreshDir->setChecked(settings.value("refreshDir",_ui->source_images_refreshDir->isChecked()).toBool()); _ui->checkBox_rgbImages_rectify->setChecked(settings.value("rectify",_ui->checkBox_rgbImages_rectify->isChecked()).toBool()); settings.endGroup(); // images settings.beginGroup("Video"); _ui->source_video_lineEdit_path->setText(settings.value("path", _ui->source_video_lineEdit_path->text()).toString()); _ui->checkBox_rgbVideo_rectify->setChecked(settings.value("rectify",_ui->checkBox_rgbVideo_rectify->isChecked()).toBool()); settings.endGroup(); // video settings.beginGroup("Database"); _ui->source_database_lineEdit_path->setText(settings.value("path",_ui->source_database_lineEdit_path->text()).toString()); _ui->source_checkBox_ignoreOdometry->setChecked(settings.value("ignoreOdometry", _ui->source_checkBox_ignoreOdometry->isChecked()).toBool()); _ui->source_checkBox_ignoreGoalDelay->setChecked(settings.value("ignoreGoalDelay", _ui->source_checkBox_ignoreGoalDelay->isChecked()).toBool()); _ui->source_checkBox_ignoreGoals->setChecked(settings.value("ignoreGoals", _ui->source_checkBox_ignoreGoals->isChecked()).toBool()); _ui->source_spinBox_databaseStartPos->setValue(settings.value("startPos", _ui->source_spinBox_databaseStartPos->value()).toInt()); _ui->source_checkBox_useDbStamps->setChecked(settings.value("useDatabaseStamps", _ui->source_checkBox_useDbStamps->isChecked()).toBool()); settings.endGroup(); // Database settings.endGroup(); // Camera _calibrationDialog->loadSettings(settings, "CalibrationDialog"); } bool PreferencesDialog::readCoreSettings(const QString & filePath) { QString path = getIniFilePath(); if(!filePath.isEmpty()) { path = filePath; } UDEBUG("%s", path.toStdString().c_str()); if(!QFile::exists(path)) { QMessageBox::information(this, tr("INI file doesn't exist..."), tr("The configuration file \"%1\" does not exist, it will be created with default parameters.").arg(path)); } QSettings settings(path, QSettings::IniFormat); settings.beginGroup("Core"); // Compare version in ini with the current RTAB-Map version QStringList version = settings.value("Version", "").toString().split('.'); if(version.size() == 3) { if(!RTABMAP_VERSION_COMPARE(version[0].toInt(), version[1].toInt(), version[2].toInt())) { if(path.contains(".rtabmap")) { UWARN("Version in the config file \"%s\" is more recent (\"%s\") than " "current RTAB-Map version used (\"%s\"). The config file will be upgraded " "to new version.", path.toStdString().c_str(), settings.value("Version", "").toString().toStdString().c_str(), RTABMAP_VERSION); } else { UERROR("Version in the config file \"%s\" is more recent (\"%s\") than " "current RTAB-Map version used (\"%s\"). New parameters (if there are some) will " "be ignored.", path.toStdString().c_str(), settings.value("Version", "").toString().toStdString().c_str(), RTABMAP_VERSION); } } } QStringList keys = settings.allKeys(); // Get profile const rtabmap::ParametersMap & parameters = Parameters::getDefaultParameters(); for(rtabmap::ParametersMap::const_iterator iter = parameters.begin(); iter!=parameters.end(); ++iter) { QString key(iter->first.c_str()); QString value = settings.value(key, "").toString(); if(value.isEmpty()) { // look for old parameter name rtabmap::ParametersMap::const_iterator oldIter = Parameters::getBackwardCompatibilityMap().find(iter->first); if(oldIter!=Parameters::getBackwardCompatibilityMap().end()) { value = settings.value(QString(oldIter->second.c_str()), "").toString(); if(!value.isEmpty()) { UWARN("Parameter migration from \"%s\" to \"%s\" (value=%s).", oldIter->second.c_str(), oldIter->first.c_str(), value.toStdString().c_str()); } } } if(!value.isEmpty()) { if(key.toStdString().compare(Parameters::kRtabmapWorkingDirectory()) == 0) { // The directory should exist if not the default one if(!QDir(value).exists() && value.compare(Parameters::defaultRtabmapWorkingDirectory().c_str()) != 0) { if(QDir(this->getWorkingDirectory().toStdString().c_str()).exists()) { UWARN("Reading config: Not existing working directory \"%s\". Keeping old one (\"%s\").", value.toStdString().c_str(), this->getWorkingDirectory().toStdString().c_str()); value = this->getWorkingDirectory(); } else { UWARN("Reading config: Not existing working directory \"%s\". Using default one (\"%s\").", value.toStdString().c_str(), (*iter).second.c_str()); value = (*iter).second.c_str(); } } } this->setParameter(key.toStdString(), value.toStdString()); } else { UDEBUG("key.toStdString()=%s", key.toStdString().c_str()); // Use the default value if the key doesn't exist yet this->setParameter(key.toStdString(), (*iter).second); // Add information about the working directory if not in the config file if(key.toStdString().compare(Parameters::kRtabmapWorkingDirectory()) == 0) { if(!_initialized) { QMessageBox::information(this, tr("Working directory"), tr("RTAB-Map needs a working directory to put the database.\n\n" "By default, the directory \"%1\" is used.\n\n" "The working directory can be changed any time in the " "preferences menu.").arg( Parameters::defaultRtabmapWorkingDirectory().c_str())); } } } } settings.endGroup(); // Core return true; } bool PreferencesDialog::saveConfigTo() { QString path = QFileDialog::getSaveFileName(this, tr("Save settings..."), this->getWorkingDirectory()+QDir::separator()+"config.ini", "*.ini"); if(!path.isEmpty()) { writeGuiSettings(path); writeCameraSettings(path); writeCoreSettings(path); return true; } return false; } void PreferencesDialog::resetConfig() { int button = QMessageBox::warning(this, tr("Reset settings..."), tr("This will reset all settings. Restore all settings to default without saving them first?"), QMessageBox::Cancel | QMessageBox::Yes | QMessageBox::Save, QMessageBox::Cancel); if(button == QMessageBox::Yes || (button == QMessageBox::Save && saveConfigTo())) { this->resetSettings(-1); } } void PreferencesDialog::writeSettings(const QString & filePath) { writeGuiSettings(filePath); writeCameraSettings(filePath); writeCoreSettings(filePath); UDEBUG("_obsoletePanels=%d parameters=%d", (int)_obsoletePanels, (int)_parameters.size()); if(_parameters.size()) { emit settingsChanged(_parameters); } if(_obsoletePanels) { emit settingsChanged(_obsoletePanels); } _parameters.clear(); _obsoletePanels = kPanelDummy; } void PreferencesDialog::writeGuiSettings(const QString & filePath) const { QString path = getIniFilePath(); if(!filePath.isEmpty()) { path = filePath; } QSettings settings(path, QSettings::IniFormat); settings.beginGroup("Gui"); settings.beginGroup("General"); settings.setValue("imagesKept", _ui->general_checkBox_imagesKept->isChecked()); settings.setValue("loggerLevel", _ui->comboBox_loggerLevel->currentIndex()); settings.setValue("loggerEventLevel", _ui->comboBox_loggerEventLevel->currentIndex()); settings.setValue("loggerPauseLevel", _ui->comboBox_loggerPauseLevel->currentIndex()); settings.setValue("loggerType", _ui->comboBox_loggerType->currentIndex()); settings.setValue("loggerPrintTime", _ui->checkBox_logger_printTime->isChecked()); settings.setValue("verticalLayoutUsed", _ui->checkBox_verticalLayoutUsed->isChecked()); settings.setValue("imageRejectedShown", _ui->checkBox_imageRejectedShown->isChecked()); settings.setValue("imageHighestHypShown", _ui->checkBox_imageHighestHypShown->isChecked()); settings.setValue("beep", _ui->checkBox_beep->isChecked()); settings.setValue("notifyNewGlobalPath", _ui->checkBox_notifyWhenNewGlobalPathIsReceived->isChecked()); settings.setValue("odomQualityThr", _ui->spinBox_odomQualityWarnThr->value()); settings.setValue("posteriorGraphView", _ui->checkBox_posteriorGraphView->isChecked()); for(int i=0; i<2; ++i) { settings.setValue(QString("showClouds%1").arg(i), _3dRenderingShowClouds[i]->isChecked()); settings.setValue(QString("voxelSize%1").arg(i), _3dRenderingVoxelSize[i]->value()); settings.setValue(QString("decimation%1").arg(i), _3dRenderingDecimation[i]->value()); settings.setValue(QString("maxDepth%1").arg(i), _3dRenderingMaxDepth[i]->value()); settings.setValue(QString("showScans%1").arg(i), _3dRenderingShowScans[i]->isChecked()); settings.setValue(QString("downsamplingScan%1").arg(i), _3dRenderingDownsamplingScan[i]->value()); settings.setValue(QString("voxelSizeScan%1").arg(i), _3dRenderingVoxelSizeScan[i]->value()); settings.setValue(QString("opacity%1").arg(i), _3dRenderingOpacity[i]->value()); settings.setValue(QString("ptSize%1").arg(i), _3dRenderingPtSize[i]->value()); settings.setValue(QString("opacityScan%1").arg(i), _3dRenderingOpacityScan[i]->value()); settings.setValue(QString("ptSizeScan%1").arg(i), _3dRenderingPtSizeScan[i]->value()); } settings.setValue("showGraphs", _ui->checkBox_showGraphs->isChecked()); settings.setValue("showLabels", _ui->checkBox_showLabels->isChecked()); settings.setValue("meshing", _ui->checkBox_meshing->isChecked()); settings.setValue("meshGP3Radius", _ui->doubleSpinBox_gp3Radius->value()); settings.setValue("meshGP3Mu", _ui->doubleSpinBox_gp3Mu->value()); settings.setValue("meshNormalKSearch", _ui->spinBox_normalKSearch->value()); settings.setValue("meshSmoothing", _ui->checkBox_mls->isChecked()); settings.setValue("meshSmoothingRadius", _ui->doubleSpinBox_mlsRadius->value()); settings.setValue("cloudFiltering", _ui->checkBox_nodeFiltering->isChecked()); settings.setValue("subtractFiltering", _ui->checkBox_subtractFiltering->isChecked()); settings.setValue("cloudFilteringRadius", _ui->doubleSpinBox_cloudFilterRadius->value()); settings.setValue("cloudFilteringAngle", _ui->doubleSpinBox_cloudFilterAngle->value()); settings.setValue("subtractFilteringMinPts", _ui->spinBox_substractFilteringMinPts->value()); settings.setValue("gridMapShown", _ui->checkBox_map_shown->isChecked()); settings.setValue("gridMapResolution", _ui->doubleSpinBox_map_resolution->value()); settings.setValue("gridMapOccupancyFrom3DCloud", _ui->checkBox_map_occupancyFrom3DCloud->isChecked()); settings.setValue("gridMapEroded", _ui->checkBox_map_erode->isChecked()); settings.setValue("gridMapOpacity", _ui->doubleSpinBox_map_opacity->value()); settings.endGroup(); // General settings.endGroup(); // rtabmap } void PreferencesDialog::writeCameraSettings(const QString & filePath) const { QString path = getIniFilePath(); if(!filePath.isEmpty()) { path = filePath; } QSettings settings(path, QSettings::IniFormat); settings.beginGroup("Camera"); settings.setValue("imgRate", _ui->general_doubleSpinBox_imgRate->value()); settings.setValue("mirroring", _ui->source_mirroring->isChecked()); settings.setValue("calibrationName", _ui->lineEdit_calibrationFile->text()); settings.setValue("type", _ui->comboBox_sourceType->currentIndex()); settings.setValue("device", _ui->lineEdit_sourceDevice->text()); settings.setValue("localTransform", _ui->lineEdit_sourceLocalTransform->text()); settings.beginGroup("rgbd"); settings.setValue("driver", _ui->comboBox_cameraRGBD->currentIndex()); settings.setValue("rgbdColorOnly", _ui->checkbox_rgbd_colorOnly->isChecked()); settings.endGroup(); // rgbd settings.beginGroup("stereo"); settings.setValue("driver", _ui->comboBox_cameraStereo->currentIndex()); settings.setValue("depthGenerated", _ui->checkbox_stereo_depthGenerated->isChecked()); settings.endGroup(); // stereo settings.beginGroup("rgb"); settings.setValue("driver", _ui->source_comboBox_image_type->currentIndex()); settings.endGroup(); // rgb settings.beginGroup("Openni"); settings.setValue("oniPath", _ui->lineEdit_openniOniPath->text()); settings.endGroup(); // Openni settings.beginGroup("Openni2"); settings.setValue("autoWhiteBalance", _ui->openni2_autoWhiteBalance->isChecked()); settings.setValue("autoExposure", _ui->openni2_autoExposure->isChecked()); settings.setValue("exposure", _ui->openni2_exposure->value()); settings.setValue("gain", _ui->openni2_gain->value()); settings.setValue("mirroring", _ui->openni2_mirroring->isChecked()); settings.setValue("stampsIdsUsed", _ui->openni2_stampsIdsUsed->isChecked()); settings.setValue("oniPath", _ui->lineEdit_openni2OniPath->text()); settings.endGroup(); // Openni2 settings.beginGroup("Freenect2"); settings.setValue("format", _ui->comboBox_freenect2Format->currentIndex()); settings.setValue("minDepth", _ui->doubleSpinBox_freenect2MinDepth->value()); settings.setValue("maxDepth", _ui->doubleSpinBox_freenect2MaxDepth->value()); settings.setValue("bilateralFiltering", _ui->checkBox_freenect2BilateralFiltering->isChecked()); settings.setValue("edgeAwareFiltering", _ui->checkBox_freenect2EdgeAwareFiltering->isChecked()); settings.setValue("noiseFiltering", _ui->checkBox_freenect2NoiseFiltering->isChecked()); settings.endGroup(); // Freenect2 settings.beginGroup("RGBDImages"); settings.setValue("path_rgb", _ui->lineEdit_cameraRGBDImages_path_rgb->text()); settings.setValue("path_depth", _ui->lineEdit_cameraRGBDImages_path_depth->text()); settings.setValue("filenames_as_stamps", _ui->checkBox_RGBDImages_timestamps->isChecked()); settings.setValue("stamps", _ui->lineEdit_cameraRGBDImages_timestamps->text()); settings.setValue("scale", _ui->doubleSpinBox_cameraRGBDImages_scale->value()); settings.endGroup(); // RGBDImages settings.beginGroup("StereoImages"); settings.setValue("stamps", _ui->lineEdit_cameraStereoImages_timestamps->text()); settings.setValue("path_left", _ui->lineEdit_cameraStereoImages_path_left->text()); settings.setValue("path_right", _ui->lineEdit_cameraStereoImages_path_right->text()); settings.setValue("path_scans", _ui->lineEdit_cameraStereoImages_path_scans->text()); settings.setValue("scan_transform", _ui->lineEdit_cameraStereoImages_laser_transform->text()); settings.setValue("scan_max_pts", _ui->spinBox_cameraStereoImages_max_scan_pts->value()); settings.setValue("filenames_as_stamps", _ui->checkBox_stereoImages_timestamps->isChecked()); settings.setValue("rectify", _ui->checkBox_stereoImages_rectify->isChecked()); settings.endGroup(); // StereoImages settings.beginGroup("StereoVideo"); settings.setValue("path", _ui->lineEdit_cameraStereoVideo_path->text()); settings.setValue("rectify", _ui->checkBox_stereoVideo_rectify->isChecked()); settings.endGroup(); // StereoVideo settings.beginGroup("Images"); settings.setValue("path", _ui->source_images_lineEdit_path->text()); settings.setValue("startPos", _ui->source_images_spinBox_startPos->value()); settings.setValue("refreshDir", _ui->source_images_refreshDir->isChecked()); settings.setValue("rectify", _ui->checkBox_rgbImages_rectify->isChecked()); settings.endGroup(); // images settings.beginGroup("Video"); settings.setValue("path", _ui->source_video_lineEdit_path->text()); settings.setValue("rectify", _ui->checkBox_rgbVideo_rectify->isChecked()); settings.endGroup(); // video settings.beginGroup("Database"); settings.setValue("path", _ui->source_database_lineEdit_path->text()); settings.setValue("ignoreOdometry", _ui->source_checkBox_ignoreOdometry->isChecked()); settings.setValue("ignoreGoalDelay", _ui->source_checkBox_ignoreGoalDelay->isChecked()); settings.setValue("ignoreGoals", _ui->source_checkBox_ignoreGoals->isChecked()); settings.setValue("startPos", _ui->source_spinBox_databaseStartPos->value()); settings.setValue("useDatabaseStamps", _ui->source_checkBox_useDbStamps->isChecked()); settings.endGroup(); // Database settings.endGroup(); // Camera _calibrationDialog->saveSettings(settings, "CalibrationDialog"); } void PreferencesDialog::writeCoreSettings(const QString & filePath) const { QString path = getIniFilePath(); if(!filePath.isEmpty()) { path = filePath; } QSettings settings(path, QSettings::IniFormat); settings.beginGroup("Core"); // save current RTAB-Map version settings.setValue("Version", QString(RTABMAP_VERSION)); const rtabmap::ParametersMap & parameters = Parameters::getDefaultParameters(); for(rtabmap::ParametersMap::const_iterator iter=parameters.begin(); iter!=parameters.end(); ++iter) { QObject * obj = _ui->stackedWidget->findChild((*iter).first.c_str()); if(obj) { QSpinBox * spin = qobject_cast(obj); QDoubleSpinBox * doubleSpin = qobject_cast(obj); QComboBox * combo = qobject_cast(obj); QCheckBox * check = qobject_cast(obj); QRadioButton * radio = qobject_cast(obj); QLineEdit * lineEdit = qobject_cast(obj); QGroupBox * groupBox = qobject_cast(obj); if(spin) { settings.setValue(obj->objectName(), spin->value()); } else if(doubleSpin) { settings.setValue(obj->objectName(), doubleSpin->value()); } else if(combo) { settings.setValue(obj->objectName(), combo->currentIndex()); } else if(check) { settings.setValue(obj->objectName(), uBool2Str(check->isChecked()).c_str()); } else if(radio) { settings.setValue(obj->objectName(), uBool2Str(radio->isChecked()).c_str()); } else if(lineEdit) { settings.setValue(obj->objectName(), lineEdit->text()); } else if(groupBox) { settings.setValue(obj->objectName(), uBool2Str(groupBox->isChecked()).c_str()); } else { ULOGGER_WARN("QObject called %s can't be cast to a supported widget", (*iter).first.c_str()); } } else { ULOGGER_WARN("Can't find the related QObject for parameter %s", (*iter).first.c_str()); } } settings.endGroup(); // Core } bool PreferencesDialog::validateForm() { if(RTABMAP_NONFREE == 0) { // verify that SURF/SIFT cannot be selected if not built with OpenCV nonfree module // BOW dictionary type if(_ui->comboBox_detector_strategy->currentIndex() <= 1) { QMessageBox::warning(this, tr("Parameter warning"), tr("Selected feature type (SURF/SIFT) is not available. RTAB-Map is not built " "with the nonfree module from OpenCV. ORB is set instead for the bag-of-words dictionary.")); _ui->comboBox_detector_strategy->setCurrentIndex(Feature2D::kFeatureOrb); } // BOW Reextract features type if(_ui->reextract_type->currentIndex() <= 1) { QMessageBox::warning(this, tr("Parameter warning"), tr("Selected feature type (SURF/SIFT) is not available. RTAB-Map is not built " "with the nonfree module from OpenCV. Fast/Brief is set instead for the re-extraction " "of features on loop closure.")); _ui->reextract_type->setCurrentIndex(Feature2D::kFeatureFastBrief); } } // optimization strategy if(!Optimizer::isAvailable(Optimizer::kTypeG2O)) { if(_ui->graphOptimization_type->currentIndex() == 1) { QMessageBox::warning(this, tr("Parameter warning"), tr("Selected graph optimization strategy (g2o) is not available. RTAB-Map is not built " "with g2o. TORO is set instead for graph optimization strategy.")); _ui->graphOptimization_type->setCurrentIndex(Optimizer::kTypeTORO); } } if(!Optimizer::isAvailable(Optimizer::kTypeGTSAM)) { if(_ui->graphOptimization_type->currentIndex() == 2) { QMessageBox::warning(this, tr("Parameter warning"), tr("Selected graph optimization strategy (GTSAM) is not available. RTAB-Map is not built " "with GTSAM. TORO is set instead for graph optimization strategy.")); _ui->graphOptimization_type->setCurrentIndex(Optimizer::kTypeTORO); } } //verify binary features and nearest neighbor // BOW dictionary type if(_ui->comboBox_dictionary_strategy->currentIndex() == VWDictionary::kNNFlannLSH && _ui->comboBox_detector_strategy->currentIndex() <= 1) { QMessageBox::warning(this, tr("Parameter warning"), tr("With the selected feature type (SURF or SIFT), parameter \"Visual word->Nearest Neighbor\" " "cannot be LSH (used for binary descriptor). KD-tree is set instead for the bag-of-words dictionary.")); _ui->comboBox_dictionary_strategy->setCurrentIndex(VWDictionary::kNNFlannKdTree); } else if(_ui->comboBox_dictionary_strategy->currentIndex() == VWDictionary::kNNFlannKdTree && _ui->comboBox_detector_strategy->currentIndex() >1) { QMessageBox::warning(this, tr("Parameter warning"), tr("With the selected feature type (ORB, FAST, FREAK or BRIEF), parameter \"Visual word->Nearest Neighbor\" " "cannot be KD-Tree (used for float descriptor). BruteForce matching is set instead for the bag-of-words dictionary.")); _ui->comboBox_dictionary_strategy->setCurrentIndex(VWDictionary::kNNBruteForce); } // BOW Reextract features type if(_ui->reextract_nn->currentIndex() == VWDictionary::kNNFlannLSH && _ui->reextract_type->currentIndex() <= 1) { QMessageBox::warning(this, tr("Parameter warning"), tr("With the selected feature type (SURF or SIFT), parameter \"Visual word->Nearest Neighbor\" " "cannot be LSH (used for binary descriptor). KD-tree is set instead for the re-extraction " "of features on loop closure.")); _ui->reextract_nn->setCurrentIndex(VWDictionary::kNNFlannKdTree); } else if(_ui->reextract_nn->currentIndex() == VWDictionary::kNNFlannKdTree && _ui->reextract_type->currentIndex() >1) { QMessageBox::warning(this, tr("Parameter warning"), tr("With the selected feature type (ORB, FAST, FREAK or BRIEF), parameter \"Visual word->Nearest Neighbor\" " "cannot be KD-Tree (used for float descriptor). BruteForce matching is set instead for the re-extraction " "of features on loop closure.")); _ui->reextract_nn->setCurrentIndex(VWDictionary::kNNBruteForce); } if(_ui->doubleSpinBox_freenect2MinDepth->value() >= _ui->doubleSpinBox_freenect2MaxDepth->value()) { QMessageBox::warning(this, tr("Parameter warning"), tr("Freenect2 minimum depth (%1 m) should be lower than maximum depth (%2 m). Setting maximum depth to %3 m.") .arg(_ui->doubleSpinBox_freenect2MinDepth->value()) .arg(_ui->doubleSpinBox_freenect2MaxDepth->value()) .arg(_ui->doubleSpinBox_freenect2MaxDepth->value()+1)); _ui->doubleSpinBox_freenect2MaxDepth->setValue(_ui->doubleSpinBox_freenect2MaxDepth->value()+1); } if(_ui->surf_doubleSpinBox_maxDepth->value() > 0.0 && _ui->surf_doubleSpinBox_minDepth->value() >= _ui->surf_doubleSpinBox_maxDepth->value()) { QMessageBox::warning(this, tr("Parameter warning"), tr("Visual word minimum depth (%1 m) should be lower than maximum depth (%2 m). Setting maximum depth to %3 m.") .arg(_ui->surf_doubleSpinBox_minDepth->value()) .arg(_ui->surf_doubleSpinBox_maxDepth->value()) .arg(_ui->surf_doubleSpinBox_maxDepth->value()+1)); _ui->doubleSpinBox_freenect2MinDepth->setValue(0); } if(_ui->loopClosure_bowMaxDepth->value() > 0.0 && _ui->loopClosure_bowMinDepth->value() >= _ui->loopClosure_bowMaxDepth->value()) { QMessageBox::warning(this, tr("Parameter warning"), tr("Visual registration word minimum depth (%1 m) should be lower than maximum depth (%2 m). Setting maximum depth to %3 m.") .arg(_ui->loopClosure_bowMinDepth->value()) .arg(_ui->loopClosure_bowMaxDepth->value()) .arg(_ui->loopClosure_bowMaxDepth->value()+1)); _ui->loopClosure_bowMinDepth->setValue(0); } if(_ui->fastThresholdMax->value() < _ui->fastThresholdMin->value()) { QMessageBox::warning(this, tr("Parameter warning"), tr("FAST minimum threshold cannot be lower than maximum threshold. Setting minimum to 1.")); _ui->fastThresholdMin->setValue(1); } if(_ui->fastThreshold->value() > _ui->fastThresholdMax->value()) { QMessageBox::warning(this, tr("Parameter warning"), tr("FAST threshold cannot be higher than maximum threshold. Maximum value set to current threshold.")); _ui->fastThresholdMax->setValue(_ui->fastThreshold->value()); } if(_ui->fastThreshold->value() < _ui->fastThresholdMin->value()) { QMessageBox::warning(this, tr("Parameter warning"), tr("FAST threshold cannot be lower than minimum threshold. Minimum value set to current threshold.")); _ui->fastThresholdMin->setValue(_ui->fastThreshold->value()); } return true; } QString PreferencesDialog::getParamMessage() { return tr("Reading parameters from the configuration file..."); } void PreferencesDialog::showEvent ( QShowEvent * event ) { if(_monitoringState) { // In monitoring state, you cannot change remote paths _ui->lineEdit_workingDirectory->setEnabled(false); _ui->toolButton_workingDirectory->setEnabled(false); _ui->label_workingDirectory->setEnabled(false); _ui->lineEdit_dictionaryPath->setEnabled(false); _ui->toolButton_dictionaryPath->setEnabled(false); _ui->label_dictionaryPath->setEnabled(false); _ui->groupBox_source0->setEnabled(false); _ui->groupBox_odometry2->setEnabled(false); this->setWindowTitle(tr("Preferences [Monitoring mode]")); } else { _ui->lineEdit_workingDirectory->setEnabled(true); _ui->toolButton_workingDirectory->setEnabled(true); _ui->label_workingDirectory->setEnabled(true); _ui->lineEdit_dictionaryPath->setEnabled(true); _ui->toolButton_dictionaryPath->setEnabled(true); _ui->label_dictionaryPath->setEnabled(true); _ui->groupBox_source0->setEnabled(true); _ui->groupBox_odometry2->setEnabled(true); this->setWindowTitle(tr("Preferences")); } this->readSettingsBegin(); } void PreferencesDialog::readSettingsBegin() { _progressDialog->setLabelText(this->getParamMessage()); _progressDialog->show(); // this will let the MainThread to display the progress dialog before reading the parameters... QTimer::singleShot(10, this, SLOT(readSettingsEnd())); } void PreferencesDialog::readSettingsEnd() { QApplication::processEvents(); this->readSettings(getTmpIniFilePath()); _progressDialog->setValue(1); if(this->isVisible()) { _progressDialog->setLabelText(tr("Setup dialog...")); this->updatePredictionPlot(); this->setupKpRoiPanel(); } _progressDialog->setValue(2); // this will make closing... } void PreferencesDialog::saveWindowGeometry(const QWidget * window) { if(!window->objectName().isNull() && !window->isMaximized()) { QSettings settings(getIniFilePath(), QSettings::IniFormat); settings.beginGroup("Gui"); settings.beginGroup(window->objectName()); settings.setValue("geometry", window->saveGeometry()); settings.endGroup(); // "windowName" settings.endGroup(); // rtabmap } } void PreferencesDialog::loadWindowGeometry(QWidget * window) { if(!window->objectName().isNull()) { QByteArray bytes; QSettings settings(getIniFilePath(), QSettings::IniFormat); settings.beginGroup("Gui"); settings.beginGroup(window->objectName()); bytes = settings.value("geometry", QByteArray()).toByteArray(); if(!bytes.isEmpty()) { window->restoreGeometry(bytes); } settings.endGroup(); // "windowName" settings.endGroup(); // rtabmap } } void PreferencesDialog::saveMainWindowState(const QMainWindow * mainWindow) { if(!mainWindow->objectName().isNull()) { saveWindowGeometry(mainWindow); QSettings settings(getIniFilePath(), QSettings::IniFormat); settings.beginGroup("Gui"); settings.beginGroup(mainWindow->objectName()); settings.setValue("state", mainWindow->saveState()); settings.setValue("maximized", mainWindow->isMaximized()); settings.setValue("status_bar", mainWindow->statusBar()->isVisible()); settings.endGroup(); // "MainWindow" settings.endGroup(); // rtabmap } } void PreferencesDialog::loadMainWindowState(QMainWindow * mainWindow, bool & maximized, bool & statusBarShown) { if(!mainWindow->objectName().isNull()) { loadWindowGeometry(mainWindow); QByteArray bytes; QSettings settings(getIniFilePath(), QSettings::IniFormat); settings.beginGroup("Gui"); settings.beginGroup(mainWindow->objectName()); bytes = settings.value("state", QByteArray()).toByteArray(); if(!bytes.isEmpty()) { mainWindow->restoreState(bytes); } maximized = settings.value("maximized", false).toBool(); statusBarShown = settings.value("status_bar", false).toBool(); mainWindow->statusBar()->setVisible(statusBarShown); settings.endGroup(); // "MainWindow" settings.endGroup(); // rtabmap } } void PreferencesDialog::saveWidgetState(const QWidget * widget) { if(!widget->objectName().isNull()) { QSettings settings(getIniFilePath(), QSettings::IniFormat); settings.beginGroup("Gui"); settings.beginGroup(widget->objectName()); const CloudViewer * cloudViewer = qobject_cast(widget); const ImageView * imageView = qobject_cast(widget); const ExportCloudsDialog * exportCloudsDialog = qobject_cast(widget); const PostProcessingDialog * postProcessingDialog = qobject_cast(widget); const GraphViewer * graphViewer = qobject_cast(widget); const CalibrationDialog * calibrationDialog = qobject_cast(widget); if(cloudViewer) { cloudViewer->saveSettings(settings); } else if(imageView) { imageView->saveSettings(settings); } else if(exportCloudsDialog) { exportCloudsDialog->saveSettings(settings); } else if(postProcessingDialog) { postProcessingDialog->saveSettings(settings); } else if(graphViewer) { graphViewer->saveSettings(settings); } else if(calibrationDialog) { calibrationDialog->saveSettings(settings); } else { UERROR("Widget \"%s\" cannot be exported in config file.", widget->objectName().toStdString().c_str()); } settings.endGroup(); // "name" settings.endGroup(); // Gui } } void PreferencesDialog::loadWidgetState(QWidget * widget) { if(!widget->objectName().isNull()) { QByteArray bytes; QSettings settings(getIniFilePath(), QSettings::IniFormat); settings.beginGroup("Gui"); settings.beginGroup(widget->objectName()); CloudViewer * cloudViewer = qobject_cast(widget); ImageView * imageView = qobject_cast(widget); ExportCloudsDialog * exportCloudsDialog = qobject_cast(widget); PostProcessingDialog * postProcessingDialog = qobject_cast(widget); GraphViewer * graphViewer = qobject_cast(widget); CalibrationDialog * calibrationDialog = qobject_cast(widget); if(cloudViewer) { cloudViewer->loadSettings(settings); } else if(imageView) { imageView->loadSettings(settings); } else if(exportCloudsDialog) { exportCloudsDialog->loadSettings(settings); } else if(postProcessingDialog) { postProcessingDialog->loadSettings(settings); } else if(graphViewer) { graphViewer->loadSettings(settings); } else if(calibrationDialog) { calibrationDialog->loadSettings(settings); } else { UERROR("Widget \"%s\" cannot be loaded from config file.", widget->objectName().toStdString().c_str()); } settings.endGroup(); //"name" settings.endGroup(); // Gui } } void PreferencesDialog::saveCustomConfig(const QString & section, const QString & key, const QString & value) { QSettings settings(getIniFilePath(), QSettings::IniFormat); settings.beginGroup("Gui"); settings.beginGroup(section); settings.setValue(key, value); settings.endGroup(); // "section" settings.endGroup(); // rtabmap } QString PreferencesDialog::loadCustomConfig(const QString & section, const QString & key) { QString value; QSettings settings(getIniFilePath(), QSettings::IniFormat); settings.beginGroup("Gui"); settings.beginGroup(section); value = settings.value(key, QString()).toString(); settings.endGroup(); // "section" settings.endGroup(); // rtabmap return value; } void PreferencesDialog::selectSourceDriver(Src src) { if(src >= kSrcRGBD && srccomboBox_sourceType->setCurrentIndex(0); _ui->comboBox_cameraRGBD->setCurrentIndex(src - kSrcRGBD); if(src == kSrcOpenNI_PCL) { _ui->lineEdit_openniOniPath->clear(); } else if(src == kSrcOpenNI2) { _ui->lineEdit_openni2OniPath->clear(); } } else if(src >= kSrcStereo && srccomboBox_sourceType->setCurrentIndex(1); _ui->comboBox_cameraRGBD->setCurrentIndex(src - kSrcStereo); } else if(src >= kSrcRGB && srccomboBox_sourceType->setCurrentIndex(2); _ui->comboBox_cameraRGBD->setCurrentIndex(src - kSrcRGB); } else if(src >= kSrcDatabase) { _ui->comboBox_sourceType->setCurrentIndex(3); _ui->comboBox_cameraRGBD->setCurrentIndex(src - kSrcDatabase); } if(validateForm()) { // Even if there is no change, MainWindow should be notified makeObsoleteSourcePanel(); this->writeSettings(getTmpIniFilePath()); } else { this->readSettingsBegin(); } } void PreferencesDialog::selectSourceDatabase() { QString dir = _ui->source_database_lineEdit_path->text(); if(dir.isEmpty()) { dir = getWorkingDirectory(); } QStringList paths = QFileDialog::getOpenFileNames(this, tr("Select file"), dir, tr("RTAB-Map database files (*.db)")); if(paths.size()) { int r = QMessageBox::question(this, tr("Odometry in database..."), tr("Use odometry saved in database (if some saved)?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); _ui->source_checkBox_ignoreOdometry->setChecked(r != QMessageBox::Yes); _ui->source_database_lineEdit_path->setText(paths.size()==1?paths.front():paths.join(";")); _ui->source_spinBox_databaseStartPos->setValue(0); _ui->source_checkBox_useDbStamps->setChecked(true); } } void PreferencesDialog::openDatabaseViewer() { DatabaseViewer * viewer = new DatabaseViewer(this); viewer->setWindowModality(Qt::WindowModal); viewer->setAttribute(Qt::WA_DeleteOnClose, true); viewer->showCloseButton(); if(viewer->openDatabase(_ui->source_database_lineEdit_path->text())) { viewer->show(); } else { delete viewer; } } void PreferencesDialog::selectCalibrationPath() { QString dir = _ui->lineEdit_calibrationFile->text(); if(dir.isEmpty()) { dir = getWorkingDirectory()+"/camera_info"; } QString path = QFileDialog::getOpenFileName(this, tr("Select file"), dir, tr("Calibration file (*.yaml)")); if(path.size()) { _ui->lineEdit_calibrationFile->setText(path); } } void PreferencesDialog::selectSourceRGBDImagesStamps() { QString dir = _ui->lineEdit_cameraRGBDImages_timestamps->text(); if(dir.isEmpty()) { dir = getWorkingDirectory(); } QString path = QFileDialog::getOpenFileName(this, tr("Select file"), dir, tr("Timestamps file (*.txt)")); if(path.size()) { _ui->lineEdit_cameraRGBDImages_timestamps->setText(path); } } void PreferencesDialog::selectSourceRGBDImagesPathRGB() { QString dir = _ui->lineEdit_cameraRGBDImages_path_rgb->text(); if(dir.isEmpty()) { dir = getWorkingDirectory(); } QString path = QFileDialog::getExistingDirectory(this, tr("Select RGB images directory"), dir); if(path.size()) { _ui->lineEdit_cameraRGBDImages_path_rgb->setText(path); } } void PreferencesDialog::selectSourceRGBDImagesPathDepth() { QString dir = _ui->lineEdit_cameraRGBDImages_path_depth->text(); if(dir.isEmpty()) { dir = getWorkingDirectory(); } QString path = QFileDialog::getExistingDirectory(this, tr("Select depth images directory"), dir); if(path.size()) { _ui->lineEdit_cameraRGBDImages_path_depth->setText(path); } } void PreferencesDialog::selectSourceStereoImagesStamps() { QString dir = _ui->lineEdit_cameraStereoImages_timestamps->text(); if(dir.isEmpty()) { dir = getWorkingDirectory(); } QString path = QFileDialog::getOpenFileName(this, tr("Select file"), dir, tr("Timestamps file (*.txt)")); if(path.size()) { _ui->lineEdit_cameraStereoImages_timestamps->setText(path); } } void PreferencesDialog::selectSourceStereoImagesPathLeft() { QString dir = _ui->lineEdit_cameraStereoImages_path_left->text(); if(dir.isEmpty()) { dir = getWorkingDirectory(); } QString path = QFileDialog::getExistingDirectory(this, tr("Select left images directory"), dir); if(path.size()) { _ui->lineEdit_cameraStereoImages_path_left->setText(path); } } void PreferencesDialog::selectSourceStereoImagesPathRight() { QString dir = _ui->lineEdit_cameraStereoImages_path_right->text(); if(dir.isEmpty()) { dir = getWorkingDirectory(); } QString path = QFileDialog::getExistingDirectory(this, tr("Select right images directory"), dir); if(path.size()) { _ui->lineEdit_cameraStereoImages_path_right->setText(path); } } void PreferencesDialog::selectSourceStereoImagesPathScans() { QString dir = _ui->lineEdit_cameraStereoImages_path_scans->text(); if(dir.isEmpty()) { dir = getWorkingDirectory(); } QString path = QFileDialog::getExistingDirectory(this, tr("Select scans directory"), dir); if(path.size()) { _ui->lineEdit_cameraStereoImages_path_scans->setText(path); } } void PreferencesDialog::selectSourceImagesPath() { QString dir = _ui->source_images_lineEdit_path->text(); if(dir.isEmpty()) { dir = getWorkingDirectory(); } QString path = QFileDialog::getExistingDirectory(this, tr("Select images directory"), _ui->source_images_lineEdit_path->text()); if(!path.isEmpty()) { _ui->source_images_lineEdit_path->setText(path); _ui->source_images_spinBox_startPos->setValue(1); } } void PreferencesDialog::selectSourceVideoPath() { QString dir = _ui->source_video_lineEdit_path->text(); if(dir.isEmpty()) { dir = getWorkingDirectory(); } QString path = QFileDialog::getOpenFileName(this, tr("Select file"), _ui->source_video_lineEdit_path->text(), tr("Videos (*.avi *.mpg *.mp4)")); if(!path.isEmpty()) { _ui->source_video_lineEdit_path->setText(path); } } void PreferencesDialog::selectSourceStereoVideoPath() { QString dir = _ui->lineEdit_cameraStereoVideo_path->text(); if(dir.isEmpty()) { dir = getWorkingDirectory(); } QString path = QFileDialog::getOpenFileName(this, tr("Select file"), _ui->lineEdit_cameraStereoVideo_path->text(), tr("Videos (*.avi *.mpg *.mp4)")); if(!path.isEmpty()) { _ui->lineEdit_cameraStereoVideo_path->setText(path); } } void PreferencesDialog::selectSourceOniPath() { QString dir = _ui->lineEdit_openniOniPath->text(); if(dir.isEmpty()) { dir = getWorkingDirectory(); } QString path = QFileDialog::getOpenFileName(this, tr("Select file"), _ui->lineEdit_openniOniPath->text(), tr("OpenNI (*.oni)")); if(!path.isEmpty()) { _ui->lineEdit_openniOniPath->setText(path); } } void PreferencesDialog::selectSourceOni2Path() { QString dir = _ui->lineEdit_openni2OniPath->text(); if(dir.isEmpty()) { dir = getWorkingDirectory(); } QString path = QFileDialog::getOpenFileName(this, tr("Select file"), _ui->lineEdit_openni2OniPath->text(), tr("OpenNI (*.oni)")); if(!path.isEmpty()) { _ui->lineEdit_openni2OniPath->setText(path); } } void PreferencesDialog::setParameter(const std::string & key, const std::string & value) { UDEBUG("%s=%s", key.c_str(), value.c_str()); QWidget * obj = _ui->stackedWidget->findChild(key.c_str()); if(obj) { QSpinBox * spin = qobject_cast(obj); QDoubleSpinBox * doubleSpin = qobject_cast(obj); QComboBox * combo = qobject_cast(obj); QCheckBox * check = qobject_cast(obj); QRadioButton * radio = qobject_cast(obj); QLineEdit * lineEdit = qobject_cast(obj); QGroupBox * groupBox = qobject_cast(obj); bool ok; if(spin) { spin->setValue(QString(value.c_str()).toInt(&ok)); if(!ok) { UERROR("Conversion failed from \"%s\" for parameter %s", value.c_str(), key.c_str()); } } else if(doubleSpin) { doubleSpin->setValue(QString(value.c_str()).toDouble(&ok)); if(!ok) { UERROR("Conversion failed from \"%s\" for parameter %s", value.c_str(), key.c_str()); } } else if(combo) { int valueInt = QString(value.c_str()).toInt(&ok); if(!ok) { UERROR("Conversion failed from \"%s\" for parameter %s", value.c_str(), key.c_str()); } else { if(RTABMAP_NONFREE == 0) { if(valueInt <= 1 && (combo->objectName().toStdString().compare(Parameters::kKpDetectorStrategy()) == 0 || combo->objectName().toStdString().compare(Parameters::kVisFeatureType()) == 0)) { UWARN("Trying to set \"%s\" to SIFT/SURF but RTAB-Map isn't built " "with the nonfree module from OpenCV. Keeping default combo value: %s.", combo->objectName().toStdString().c_str(), combo->currentText().toStdString().c_str()); ok = false; } else if(valueInt==1 && (combo->objectName().toStdString().compare(Parameters::kKpNNStrategy()) == 0 || combo->objectName().toStdString().compare(Parameters::kVisNNType()) == 0)) { UWARN("Trying to set \"%s\" to KdTree but RTAB-Map isn't built " "with the nonfree module from OpenCV and kdTree cannot be used " "with binary descriptors. Keeping default combo value: %s.", combo->objectName().toStdString().c_str(), combo->currentText().toStdString().c_str()); ok = false; } } if(!Optimizer::isAvailable(Optimizer::kTypeG2O)) { if(valueInt==1 && combo->objectName().toStdString().compare(Parameters::kOptimizerStrategy()) == 0) { UWARN("Trying to set \"%s\" to g2o but RTAB-Map isn't built " "with g2o. Keeping default combo value: %s.", combo->objectName().toStdString().c_str(), combo->currentText().toStdString().c_str()); ok = false; } } if(!Optimizer::isAvailable(Optimizer::kTypeGTSAM)) { if(valueInt==2 && combo->objectName().toStdString().compare(Parameters::kOptimizerStrategy()) == 0) { UWARN("Trying to set \"%s\" to GTSAM but RTAB-Map isn't built " "with GTSAM. Keeping default combo value: %s.", combo->objectName().toStdString().c_str(), combo->currentText().toStdString().c_str()); ok = false; } } if(ok) { combo->setCurrentIndex(valueInt); } } } else if(check) { check->setChecked(uStr2Bool(value.c_str())); } else if(radio) { radio->setChecked(uStr2Bool(value.c_str())); } else if(lineEdit) { lineEdit->setText(value.c_str()); } else if(groupBox) { groupBox->setChecked(uStr2Bool(value.c_str())); } else { ULOGGER_WARN("QObject called %s can't be cast to a supported widget", key.c_str()); } } else { ULOGGER_WARN("Can't find the related QObject for parameter %s", key.c_str()); } } void PreferencesDialog::addParameter(int value) { if(sender()) { this->addParameter(sender(), value); } else { ULOGGER_ERROR("This slot must be triggered by a signal, not a direct call..."); } } void PreferencesDialog::addParameter(bool value) { if(sender()) { this->addParameter(sender(), value); } else { ULOGGER_ERROR("This slot must be triggered by a signal, not a direct call..."); } } void PreferencesDialog::addParameter(double value) { if(sender()) { this->addParameter(sender(), value); } else { ULOGGER_ERROR("This slot must be triggered by a signal, not a direct call..."); } } void PreferencesDialog::addParameter(const QString & value) { if(sender()) { this->addParameter(sender(), value); } else { ULOGGER_ERROR("This slot must be triggered by a signal, not a direct call..."); } } void PreferencesDialog::addParameter(const QObject * object, int value) { if(object) { // Make sure the value is inserted, check if the same key already exists rtabmap::ParametersMap::iterator iter = _parameters.find(object->objectName().toStdString()); if(iter != _parameters.end()) { _parameters.erase(iter); } const QComboBox * comboBox = qobject_cast(object); const QSpinBox * spinbox = qobject_cast(object); if(comboBox || spinbox) { if(comboBox) { // Add related panels to parameters if(comboBox == _ui->comboBox_vh_strategy) { if(value == 0) // 0 none { // No panel related... } else if(value == 1) // 2 epipolar { this->addParameters(_ui->groupBox_vh_epipolar2); } } else if(comboBox == _ui->comboBox_detector_strategy || comboBox == _ui->reextract_type) { if(value == 0) // surf { this->addParameters(_ui->groupBox_detector_surf2); } else if(value == 1) // sift { this->addParameters(_ui->groupBox_detector_sift2); } else if(value == 2) // orb { this->addParameters(_ui->groupBox_detector_orb2); } else if(value == 3) // fast+freak { this->addParameters(_ui->groupBox_detector_fast2); this->addParameters(_ui->groupBox_detector_freak2); } else if(value == 4) // fast+brief { this->addParameters(_ui->groupBox_detector_fast2); this->addParameters(_ui->groupBox_detector_brief2); } else if(value == 5) // gftt+freak { this->addParameters(_ui->groupBox_detector_gftt2); this->addParameters(_ui->groupBox_detector_freak2); } else if(value == 6) // gftt+brief { this->addParameters(_ui->groupBox_detector_gftt2); this->addParameters(_ui->groupBox_detector_brief2); } else if(value == 7) // brisk { this->addParameters(_ui->groupBox_detector_brisk2); } } else if(comboBox == _ui->loopClosure_estimationType) { this->addParameters(_ui->stackedWidget_loopClosureEstimation, _ui->loopClosure_estimationType->currentIndex()); } else if(comboBox == _ui->graphOptimization_type) { this->addParameter(_ui->graphOptimization_iterations, _ui->graphOptimization_iterations->value()); this->addParameter(_ui->graphOptimization_covarianceIgnored, _ui->graphOptimization_covarianceIgnored->isChecked()); this->addParameter(_ui->graphOptimization_slam2d, _ui->graphOptimization_slam2d->isChecked()); this->addParameter(_ui->graphOptimization_stopEpsilon, _ui->graphOptimization_stopEpsilon->value()); this->addParameter(_ui->graphOptimization_robust, _ui->graphOptimization_robust->isChecked()); } } // Add parameter _parameters.insert(rtabmap::ParametersPair(object->objectName().toStdString(), QString::number(value).toStdString())); } else { UWARN("Undefined object \"%s\"", object->objectName().toStdString().c_str()); } } else { ULOGGER_ERROR("Object is null"); } } void PreferencesDialog::addParameter(const QObject * object, bool value) { if(object) { // Make sure the value is inserted, check if the same key already exists rtabmap::ParametersMap::iterator iter = _parameters.find(object->objectName().toStdString()); if(iter != _parameters.end()) { _parameters.erase(iter); } const QCheckBox * checkbox = qobject_cast(object); const QRadioButton * radio = qobject_cast(object); const QGroupBox * groupBox = qobject_cast(object); if(checkbox || radio || groupBox) { // Add parameter _parameters.insert(rtabmap::ParametersPair(object->objectName().toStdString(), uBool2Str(value))); // RGBD panel if(value && checkbox == _ui->general_checkBox_activateRGBD) { // add all RGBD parameters! this->addParameters(_ui->groupBox_slam_update); this->addParameters(_ui->groupBox_graphOptimization); this->addParameters(_ui->groupBox_localDetection_time); this->addParameters(_ui->groupBox_localDetection_space); this->addParameters(_ui->groupBox_visualTransform2); this->addParameters(_ui->groupBox_icp2); } else if(value && checkbox == _ui->loopClosure_icp) { this->addParameters(_ui->groupBox_icp2); } if(groupBox) { // RGBD panel if(value && groupBox == _ui->groupBox_localDetection_time) { this->addParameters(_ui->groupBox_visualTransform2); } if(value && groupBox == _ui->groupBox_localDetection_space) { this->addParameters(_ui->groupBox_icp2); } this->addParameters(groupBox); } } else { UWARN("Undefined object \"%s\"", object->objectName().toStdString().c_str()); } } else { ULOGGER_ERROR("Object is null"); } } void PreferencesDialog::addParameter(const QObject * object, double value) { if(object) { // Make sure the value is inserted, check if the same key already exists rtabmap::ParametersMap::iterator iter = _parameters.find(object->objectName().toStdString()); if(iter != _parameters.end()) { _parameters.erase(iter); } _parameters.insert(rtabmap::ParametersPair(object->objectName().toStdString(), QString::number(value).toStdString())); //ULOGGER_DEBUG("PreferencesDialog::addParameter(object, double) Added [\"%s\",\"%s\"]", object->objectName().toStdString().c_str(), QString::number(value).toStdString().c_str()); } else { ULOGGER_ERROR("Object is null"); } } void PreferencesDialog::addParameter(const QObject * object, const QString & value) { if(object) { // Make sure the value is inserted, check if the same key already exists rtabmap::ParametersMap::iterator iter = _parameters.find(object->objectName().toStdString()); if(iter != _parameters.end()) { _parameters.erase(iter); } _parameters.insert(rtabmap::ParametersPair(object->objectName().toStdString(), value.toStdString())); //ULOGGER_DEBUG("PreferencesDialog::addParameter(object, QString) Added [\"%s\",\"%s\"]", object->objectName().toStdString().c_str(), QString::number(value).toStdString().c_str()); } else { ULOGGER_ERROR("Object is null"); } } void PreferencesDialog::addParameters(const QObjectList & children) { //ULOGGER_DEBUG("PreferencesDialog::addParameters(QGroupBox) box %s has %d children", box->objectName().toStdString().c_str(), children.size()); for(int i=0; i(children[i]); const QDoubleSpinBox * doubleSpin = qobject_cast(children[i]); const QComboBox * combo = qobject_cast(children[i]); const QCheckBox * check = qobject_cast(children[i]); const QRadioButton * radio = qobject_cast(children[i]); const QLineEdit * lineEdit = qobject_cast(children[i]); const QGroupBox * groupBox = qobject_cast(children[i]); const QStackedWidget * stackedWidget = qobject_cast(children[i]); if(spin) { this->addParameter(spin, spin->value()); } else if(doubleSpin) { this->addParameter(doubleSpin, doubleSpin->value()); } else if(combo) { this->addParameter(combo, combo->currentIndex()); } else if(check) { this->addParameter(check, check->isChecked()); } else if(radio) { this->addParameter(radio, radio->isChecked()); } else if(lineEdit) { this->addParameter(lineEdit, lineEdit->text()); } else if(groupBox) { if(groupBox->isCheckable()) { this->addParameter(groupBox, groupBox->isChecked()); } else { this->addParameters(groupBox); } } else if(stackedWidget) { this->addParameters(stackedWidget); } } } void PreferencesDialog::addParameters(const QStackedWidget * stackedWidget, int panel) { if(stackedWidget) { if(panel == -1) { for(int i=0; icount(); ++i) { const QObjectList & children = stackedWidget->widget(i)->children(); addParameters(children); } } else { UASSERT(panelcount()); const QObjectList & children = stackedWidget->widget(panel)->children(); addParameters(children); } } } void PreferencesDialog::addParameters(const QGroupBox * box) { if(box) { const QObjectList & children = box->children(); addParameters(children); } } void PreferencesDialog::updateBasicParameter() { // This method is used to update basic/advanced referred parameters, see above editingFinished() // basic to advanced (advanced to basic must be done by connecting signal valueChanged()) if(sender() == _ui->general_doubleSpinBox_timeThr_2) { _ui->general_doubleSpinBox_timeThr->setValue(_ui->general_doubleSpinBox_timeThr_2->value()); } else if(sender() == _ui->general_doubleSpinBox_hardThr_2) { _ui->general_doubleSpinBox_hardThr->setValue(_ui->general_doubleSpinBox_hardThr_2->value()); } else if(sender() == _ui->general_doubleSpinBox_detectionRate_2) { _ui->general_doubleSpinBox_detectionRate->setValue(_ui->general_doubleSpinBox_detectionRate_2->value()); } else if(sender() == _ui->general_spinBox_imagesBufferSize_2) { _ui->general_spinBox_imagesBufferSize->setValue(_ui->general_spinBox_imagesBufferSize_2->value()); } else if(sender() == _ui->general_spinBox_maxStMemSize_2) { _ui->general_spinBox_maxStMemSize->setValue(_ui->general_spinBox_maxStMemSize_2->value()); } else if(sender() == _ui->groupBox_publishing) { _ui->general_checkBox_publishStats_2->setChecked(_ui->groupBox_publishing->isChecked()); } else if(sender() == _ui->general_checkBox_publishStats_2) { _ui->groupBox_publishing->setChecked(_ui->general_checkBox_publishStats_2->isChecked()); } else if(sender() == _ui->doubleSpinBox_similarityThreshold_2) { _ui->doubleSpinBox_similarityThreshold->setValue(_ui->doubleSpinBox_similarityThreshold_2->value()); } else if(sender() == _ui->general_checkBox_activateRGBD) { _ui->general_checkBox_activateRGBD_2->setChecked(_ui->general_checkBox_activateRGBD->isChecked()); } else if(sender() == _ui->general_checkBox_activateRGBD_2) { _ui->general_checkBox_activateRGBD->setChecked(_ui->general_checkBox_activateRGBD_2->isChecked()); } else if(sender() == _ui->general_checkBox_SLAM_mode) { _ui->general_checkBox_SLAM_mode_2->setChecked(_ui->general_checkBox_SLAM_mode->isChecked()); } else if(sender() == _ui->general_checkBox_SLAM_mode_2) { _ui->general_checkBox_SLAM_mode->setChecked(_ui->general_checkBox_SLAM_mode_2->isChecked()); } else { //update all values (only those using editingFinished signal) _ui->general_doubleSpinBox_timeThr->setValue(_ui->general_doubleSpinBox_timeThr_2->value()); _ui->general_doubleSpinBox_hardThr->setValue(_ui->general_doubleSpinBox_hardThr_2->value()); _ui->general_doubleSpinBox_detectionRate->setValue(_ui->general_doubleSpinBox_detectionRate_2->value()); _ui->general_spinBox_imagesBufferSize->setValue(_ui->general_spinBox_imagesBufferSize_2->value()); _ui->general_spinBox_maxStMemSize->setValue(_ui->general_spinBox_maxStMemSize_2->value()); _ui->doubleSpinBox_similarityThreshold->setValue(_ui->doubleSpinBox_similarityThreshold_2->value()); } } void PreferencesDialog::makeObsoleteGeneralPanel() { ULOGGER_DEBUG(""); _obsoletePanels = _obsoletePanels | kPanelGeneral; } void PreferencesDialog::makeObsoleteCloudRenderingPanel() { ULOGGER_DEBUG(""); _obsoletePanels = _obsoletePanels | kPanelCloudRendering; } void PreferencesDialog::makeObsoleteLoggingPanel() { ULOGGER_DEBUG(""); _obsoletePanels = _obsoletePanels | kPanelLogging; } void PreferencesDialog::makeObsoleteSourcePanel() { _obsoletePanels = _obsoletePanels | kPanelSource; } rtabmap::ParametersMap PreferencesDialog::getAllParameters() { rtabmap::ParametersMap result; rtabmap::ParametersMap tmpParameters = _parameters; _parameters.clear(); QList boxes = this->getGroupBoxes(); for(int i=0; iaddParameters(boxes.at(i)); } result = _parameters; _parameters = tmpParameters; return result; } QList PreferencesDialog::getGroupBoxes() { QList boxes; for(int i=0; i<_ui->stackedWidget->count(); ++i) { QGroupBox * gb = 0; const QObjectList & children = _ui->stackedWidget->widget(i)->children(); for(int j=0; j(children.at(j)))) { //ULOGGER_DEBUG("PreferencesDialog::setupTreeView() index(%d) Added %s, box name=%s", i, gb->title().toStdString().c_str(), gb->objectName().toStdString().c_str()); break; } } if(gb) { boxes.append(gb); } else { ULOGGER_ERROR("A QGroupBox must be included in the first level of children in stacked widget, index=%d", i); } } return boxes; } void PreferencesDialog::updatePredictionPlot() { QStringList values = _ui->lineEdit_bayes_predictionLC->text().simplified().split(' '); if(values.size() < 2) { UERROR("Error parsing prediction (must have at least 2 items) : %s", _ui->lineEdit_bayes_predictionLC->text().toStdString().c_str()); return; } QVector dataX((values.size()-2)*2 + 1); QVector dataY((values.size()-2)*2 + 1); double value; double sum = 0; int lvl = 1; bool ok = false; bool error = false; int loopClosureIndex = (dataX.size()-1)/2; for(int i=0; ilabel_prediction_sum->setNum(sum); if(error) { _ui->label_prediction_sum->setText(QString("") + _ui->label_prediction_sum->text() + ""); } else if(sum == 1.0) { _ui->label_prediction_sum->setText(QString("") + _ui->label_prediction_sum->text() + ""); } else if(sum > 1.0) { _ui->label_prediction_sum->setText(QString("") + _ui->label_prediction_sum->text() + ""); } else { _ui->label_prediction_sum->setText(QString("") + _ui->label_prediction_sum->text() + ""); } _ui->predictionPlot->removeCurves(); _ui->predictionPlot->addCurve(new UPlotCurve("Prediction", dataX, dataY, _ui->predictionPlot)); } void PreferencesDialog::setupKpRoiPanel() { QStringList strings = _ui->lineEdit_kp_roi->text().split(' '); if(strings.size()!=4) { UERROR("ROI must have 4 values (%s)", _ui->lineEdit_kp_roi->text().toStdString().c_str()); return; } _ui->doubleSpinBox_kp_roi0->setValue(strings[0].toDouble()*100.0); _ui->doubleSpinBox_kp_roi1->setValue(strings[1].toDouble()*100.0); _ui->doubleSpinBox_kp_roi2->setValue(strings[2].toDouble()*100.0); _ui->doubleSpinBox_kp_roi3->setValue(strings[3].toDouble()*100.0); } void PreferencesDialog::updateKpROI() { QStringList strings; strings.append(QString::number(_ui->doubleSpinBox_kp_roi0->value()/100.0)); strings.append(QString::number(_ui->doubleSpinBox_kp_roi1->value()/100.0)); strings.append(QString::number(_ui->doubleSpinBox_kp_roi2->value()/100.0)); strings.append(QString::number(_ui->doubleSpinBox_kp_roi3->value()/100.0)); _ui->lineEdit_kp_roi->setText(strings.join(" ")); } void PreferencesDialog::changeWorkingDirectory() { QString directory = QFileDialog::getExistingDirectory(this, tr("Working directory"), _ui->lineEdit_workingDirectory->text()); if(!directory.isEmpty()) { ULOGGER_DEBUG("New working directory = %s", directory.toStdString().c_str()); _ui->lineEdit_workingDirectory->setText(directory); } } void PreferencesDialog::changeDictionaryPath() { QString path; if(_ui->lineEdit_dictionaryPath->text().isEmpty()) { path = QFileDialog::getOpenFileName(this, tr("Dictionary"), this->getWorkingDirectory()); } else { path = QFileDialog::getOpenFileName(this, tr("Dictionary"), _ui->lineEdit_dictionaryPath->text()); } if(!path.isEmpty()) { _ui->lineEdit_dictionaryPath->setText(path); } } void PreferencesDialog::changeOdomBowFixedLocalMapPath() { QString path; if(_ui->odom_fixedLocalMapPath->text().isEmpty()) { path = QFileDialog::getOpenFileName(this, tr("Database"), this->getWorkingDirectory(), tr("RTAB-Map database files (*.db)")); } else { path = QFileDialog::getOpenFileName(this, tr("Database"), _ui->odom_fixedLocalMapPath->text(), tr("RTAB-Map database files (*.db)")); } if(!path.isEmpty()) { _ui->odom_fixedLocalMapPath->setText(path); } } void PreferencesDialog::updateSourceGrpVisibility() { _ui->groupBox_sourceRGBD->setVisible(_ui->comboBox_sourceType->currentIndex() == 0); _ui->groupBox_sourceStereo->setVisible(_ui->comboBox_sourceType->currentIndex() == 1); _ui->groupBox_sourceRGB->setVisible(_ui->comboBox_sourceType->currentIndex() == 2); _ui->groupBox_sourceDatabase->setVisible(_ui->comboBox_sourceType->currentIndex() == 3); } void PreferencesDialog::updateRGBDCameraGroupBoxVisibility() { _ui->groupBox_openni2->setVisible(_ui->comboBox_cameraRGBD->currentIndex() == kSrcOpenNI2-kSrcOpenNI_PCL); _ui->groupBox_freenect2->setVisible(_ui->comboBox_cameraRGBD->currentIndex() == kSrcFreenect2-kSrcOpenNI_PCL); } void PreferencesDialog::updateRGBCameraGroupBoxVisibility() { _ui->source_groupBox_images->setVisible(_ui->source_comboBox_image_type->currentIndex() == kSrcImages-kSrcUsbDevice); _ui->source_groupBox_video->setVisible(_ui->source_comboBox_image_type->currentIndex() == kSrcVideo-kSrcUsbDevice); } void PreferencesDialog::updateStereoCameraGroupBoxVisibility() { _ui->groupBox_cameraStereoImages->setVisible(_ui->comboBox_cameraStereo->currentIndex() == kSrcStereoImages-kSrcDC1394); } /*** GETTERS ***/ //General int PreferencesDialog::getGeneralLoggerLevel() const { return _ui->comboBox_loggerLevel->currentIndex(); } int PreferencesDialog::getGeneralLoggerEventLevel() const { return _ui->comboBox_loggerEventLevel->currentIndex(); } int PreferencesDialog::getGeneralLoggerPauseLevel() const { return _ui->comboBox_loggerPauseLevel->currentIndex(); } int PreferencesDialog::getGeneralLoggerType() const { return _ui->comboBox_loggerType->currentIndex(); } bool PreferencesDialog::getGeneralLoggerPrintTime() const { return _ui->checkBox_logger_printTime->isChecked(); } bool PreferencesDialog::isVerticalLayoutUsed() const { return _ui->checkBox_verticalLayoutUsed->isChecked(); } bool PreferencesDialog::imageRejectedShown() const { return _ui->checkBox_imageRejectedShown->isChecked(); } bool PreferencesDialog::imageHighestHypShown() const { return _ui->checkBox_imageHighestHypShown->isChecked(); } bool PreferencesDialog::beepOnPause() const { return _ui->checkBox_beep->isChecked(); } bool PreferencesDialog::notifyWhenNewGlobalPathIsReceived() const { return _ui->checkBox_notifyWhenNewGlobalPathIsReceived->isChecked(); } int PreferencesDialog::getOdomQualityWarnThr() const { return _ui->spinBox_odomQualityWarnThr->value(); } bool PreferencesDialog::isPosteriorGraphView() const { return _ui->checkBox_posteriorGraphView->isChecked(); } bool PreferencesDialog::isCloudsShown(int index) const { UASSERT(index >= 0 && index <= 1); return _3dRenderingShowClouds[index]->isChecked(); } bool PreferencesDialog::isGraphsShown() const { return _ui->checkBox_showGraphs->isChecked(); } bool PreferencesDialog::isLabelsShown() const { return _ui->checkBox_showLabels->isChecked(); } bool PreferencesDialog::isCloudMeshing() const { return _ui->checkBox_meshing->isChecked(); } double PreferencesDialog::getCloudVoxelSize(int index) const { UASSERT(index >= 0 && index <= 1); return _3dRenderingVoxelSize[index]->value(); } int PreferencesDialog::getCloudDecimation(int index) const { UASSERT(index >= 0 && index <= 1); return _3dRenderingDecimation[index]->value(); } double PreferencesDialog::getCloudMaxDepth(int index) const { UASSERT(index >= 0 && index <= 1); return _3dRenderingMaxDepth[index]->value(); } double PreferencesDialog::getCloudOpacity(int index) const { UASSERT(index >= 0 && index <= 1); return _3dRenderingOpacity[index]->value(); } int PreferencesDialog::getCloudPointSize(int index) const { UASSERT(index >= 0 && index <= 1); return _3dRenderingPtSize[index]->value(); } bool PreferencesDialog::isScansShown(int index) const { UASSERT(index >= 0 && index <= 1); return _3dRenderingShowScans[index]->isChecked(); } int PreferencesDialog::getDownsamplingStepScan(int index) const { UASSERT(index >= 0 && index <= 1); return _3dRenderingDownsamplingScan[index]->value(); } double PreferencesDialog::getCloudVoxelSizeScan(int index) const { UASSERT(index >= 0 && index <= 1); return _3dRenderingVoxelSizeScan[index]->value(); } double PreferencesDialog::getScanOpacity(int index) const { UASSERT(index >= 0 && index <= 1); return _3dRenderingOpacityScan[index]->value(); } int PreferencesDialog::getScanPointSize(int index) const { UASSERT(index >= 0 && index <= 1); return _3dRenderingPtSizeScan[index]->value(); } int PreferencesDialog::getMeshNormalKSearch() const { return _ui->spinBox_normalKSearch->value(); } double PreferencesDialog::getMeshGP3Radius() const { return _ui->doubleSpinBox_gp3Radius->value(); } double PreferencesDialog::getMeshGP3Mu() const { return _ui->doubleSpinBox_gp3Mu->value(); } bool PreferencesDialog::getMeshSmoothing() const { return _ui->checkBox_mls->isChecked(); } double PreferencesDialog::getMeshSmoothingRadius() const { return _ui->doubleSpinBox_mlsRadius->value(); } bool PreferencesDialog::isCloudFiltering() const { return _ui->checkBox_nodeFiltering->isChecked(); } bool PreferencesDialog::isSubtractFiltering() const { return _ui->checkBox_subtractFiltering->isChecked(); } double PreferencesDialog::getCloudFilteringRadius() const { return _ui->doubleSpinBox_cloudFilterRadius->value(); } double PreferencesDialog::getCloudFilteringAngle() const { return _ui->doubleSpinBox_cloudFilterAngle->value(); } int PreferencesDialog::getSubstractFilteringMinPts() const { return _ui->spinBox_substractFilteringMinPts->value(); } bool PreferencesDialog::getGridMapShown() const { return _ui->checkBox_map_shown->isChecked(); } double PreferencesDialog::getGridMapResolution() const { return _ui->doubleSpinBox_map_resolution->value(); } bool PreferencesDialog::isGridMapFrom3DCloud() const { return _ui->checkBox_map_occupancyFrom3DCloud->isChecked(); } bool PreferencesDialog::isGridMapEroded() const { return _ui->checkBox_map_erode->isChecked(); } double PreferencesDialog::getGridMapOpacity() const { return _ui->doubleSpinBox_map_opacity->value(); } // Source double PreferencesDialog::getGeneralInputRate() const { return _ui->general_doubleSpinBox_imgRate->value(); } bool PreferencesDialog::isSourceMirroring() const { return _ui->source_mirroring->isChecked(); } PreferencesDialog::Src PreferencesDialog::getSourceType() const { int index = _ui->comboBox_sourceType->currentIndex(); if(index == 0) { return kSrcRGBD; } else if(index == 1) { return kSrcStereo; } else if(index == 2) { return kSrcRGB; } else if(index == 3) { return kSrcDatabase; } return kSrcUndef; } PreferencesDialog::Src PreferencesDialog::getSourceDriver() const { PreferencesDialog::Src type = getSourceType(); if(type==kSrcRGBD) { return (PreferencesDialog::Src)(_ui->comboBox_cameraRGBD->currentIndex()+kSrcRGBD); } else if(type==kSrcStereo) { return (PreferencesDialog::Src)(_ui->comboBox_cameraStereo->currentIndex()+kSrcStereo); } else if(type==kSrcRGB) { return (PreferencesDialog::Src)(_ui->source_comboBox_image_type->currentIndex()+kSrcRGB); } else if(type==kSrcDatabase) { return kSrcDatabase; } return kSrcUndef; } QString PreferencesDialog::getSourceDriverStr() const { PreferencesDialog::Src type = getSourceType(); if(type==kSrcRGBD) { return _ui->comboBox_cameraRGBD->currentText(); } else if(type==kSrcStereo) { return _ui->comboBox_cameraStereo->currentText(); } else if(type==kSrcRGB) { return _ui->source_comboBox_image_type->currentText(); } else if(type==kSrcDatabase) { return "Database"; } return ""; } QString PreferencesDialog::getSourceDevice() const { return _ui->lineEdit_sourceDevice->text(); } Transform PreferencesDialog::getSourceLocalTransform() const { Transform t = Transform::fromString(_ui->lineEdit_sourceLocalTransform->text().replace("PI_2", QString::number(3.141592/2.0)).toStdString()); if(t.isNull()) { return Transform::getIdentity(); } return t; } Transform PreferencesDialog::getStereoLaserLocalTransform() const { Transform t = Transform::fromString(_ui->lineEdit_cameraStereoImages_laser_transform->text().replace("PI_2", QString::number(3.141592/2.0)).toStdString()); if(t.isNull()) { return Transform::getIdentity(); } return t; } QString PreferencesDialog::getSourceDatabasePath() const { return _ui->source_database_lineEdit_path->text(); } bool PreferencesDialog::getSourceDatabaseOdometryIgnored() const { return _ui->source_checkBox_ignoreOdometry->isChecked(); } bool PreferencesDialog::getSourceDatabaseGoalDelayIgnored() const { return _ui->source_checkBox_ignoreGoalDelay->isChecked(); } bool PreferencesDialog::getSourceDatabaseGoalsIgnored() const { return _ui->source_checkBox_ignoreGoals->isChecked(); } int PreferencesDialog::getSourceDatabaseStartPos() const { return _ui->source_spinBox_databaseStartPos->value(); } bool PreferencesDialog::getSourceDatabaseStampsUsed() const { return _ui->source_checkBox_useDbStamps->isChecked(); } bool PreferencesDialog::isSourceRGBDColorOnly() const { return _ui->checkbox_rgbd_colorOnly->isChecked(); } bool PreferencesDialog::isSourceStereoDepthGenerated() const { return _ui->checkbox_stereo_depthGenerated->isChecked(); } Camera * PreferencesDialog::createCamera(bool useRawImages) { Src driver = this->getSourceDriver(); Camera * camera = 0; if(driver == PreferencesDialog::kSrcOpenNI_PCL) { if(useRawImages) { QMessageBox::warning(this, tr("Calibration"), tr("Using raw images for \"OpenNI\" driver is not yet supported. " "Factory calibration loaded from OpenNI is used."), QMessageBox::Ok); return 0; } else { camera = new CameraOpenni( _ui->lineEdit_openniOniPath->text().isEmpty()?this->getSourceDevice().toStdString():_ui->lineEdit_openniOniPath->text().toStdString(), this->getGeneralInputRate(), this->getSourceLocalTransform()); } } else if(driver == PreferencesDialog::kSrcOpenNI2) { if(useRawImages) { QMessageBox::warning(this, tr("Calibration"), tr("Using raw images for \"OpenNI2\" driver is not yet supported. " "Factory calibration loaded from OpenNI2 is used."), QMessageBox::Ok); return 0; } else { camera = new CameraOpenNI2( _ui->lineEdit_openni2OniPath->text().isEmpty()?this->getSourceDevice().toStdString():_ui->lineEdit_openni2OniPath->text().toStdString(), this->getGeneralInputRate(), this->getSourceLocalTransform()); } } else if(driver == PreferencesDialog::kSrcFreenect) { if(useRawImages) { QMessageBox::warning(this, tr("Calibration"), tr("Using raw images for \"Freenect\" driver is not yet supported. " "Factory calibration loaded from Freenect is used."), QMessageBox::Ok); return 0; } else { camera = new CameraFreenect( this->getSourceDevice().isEmpty()?0:atoi(this->getSourceDevice().toStdString().c_str()), this->getGeneralInputRate(), this->getSourceLocalTransform()); } } else if(driver == PreferencesDialog::kSrcOpenNI_CV || driver == PreferencesDialog::kSrcOpenNI_CV_ASUS) { if(useRawImages) { QMessageBox::warning(this, tr("Calibration"), tr("Using raw images for \"OpenNI\" driver is not yet supported. " "Factory calibration loaded from OpenNI is used."), QMessageBox::Ok); return 0; } else { camera = new CameraOpenNICV( driver == PreferencesDialog::kSrcOpenNI_CV_ASUS, this->getGeneralInputRate(), this->getSourceLocalTransform()); } } else if(driver == kSrcFreenect2) { camera = new CameraFreenect2( this->getSourceDevice().isEmpty()?0:atoi(this->getSourceDevice().toStdString().c_str()), useRawImages?CameraFreenect2::kTypeColorIR:(CameraFreenect2::Type)_ui->comboBox_freenect2Format->currentIndex(), this->getGeneralInputRate(), this->getSourceLocalTransform(), _ui->doubleSpinBox_freenect2MinDepth->value(), _ui->doubleSpinBox_freenect2MaxDepth->value(), _ui->checkBox_freenect2BilateralFiltering->isChecked(), _ui->checkBox_freenect2EdgeAwareFiltering->isChecked(), _ui->checkBox_freenect2NoiseFiltering->isChecked()); } else if(driver == kSrcRGBDImages) { camera = new CameraRGBDImages( _ui->lineEdit_cameraRGBDImages_path_rgb->text().append(QDir::separator()).toStdString(), _ui->lineEdit_cameraRGBDImages_path_depth->text().append(QDir::separator()).toStdString(), _ui->doubleSpinBox_cameraRGBDImages_scale->value(), _ui->checkBox_RGBDImages_timestamps->isChecked(), _ui->lineEdit_cameraRGBDImages_timestamps->text().toStdString(), this->getGeneralInputRate(), this->getSourceLocalTransform()); } else if(driver == kSrcDC1394) { camera = new CameraStereoDC1394( this->getGeneralInputRate(), this->getSourceLocalTransform()); } else if(driver == kSrcFlyCapture2) { if(useRawImages) { QMessageBox::warning(this, tr("Calibration"), tr("Using raw images for \"FlyCapture2\" driver is not yet supported. " "Factory calibration loaded from FlyCapture2 is used."), QMessageBox::Ok); return 0; } else { camera = new CameraStereoFlyCapture2( this->getGeneralInputRate(), this->getSourceLocalTransform()); } } else if(driver == kSrcStereoImages) { camera = new CameraStereoImages( _ui->lineEdit_cameraStereoImages_path_scans->text().isEmpty()?"":_ui->lineEdit_cameraStereoImages_path_scans->text().append(QDir::separator()).toStdString(), this->getStereoLaserLocalTransform(), _ui->spinBox_cameraStereoImages_max_scan_pts->value(), _ui->lineEdit_cameraStereoImages_path_left->text().append(QDir::separator()).toStdString(), _ui->lineEdit_cameraStereoImages_path_right->text().append(QDir::separator()).toStdString(), _ui->checkBox_stereoImages_timestamps->isChecked(), _ui->lineEdit_cameraStereoImages_timestamps->text().toStdString(), _ui->checkBox_stereoImages_rectify->isChecked(), this->getGeneralInputRate(), this->getSourceLocalTransform()); } else if(driver == kSrcStereoVideo) { camera = new CameraStereoVideo( _ui->lineEdit_cameraStereoVideo_path->text().toStdString(), _ui->checkBox_stereoVideo_rectify->isChecked(), this->getGeneralInputRate(), this->getSourceLocalTransform()); } else if(driver == kSrcUsbDevice) { camera = new CameraVideo( this->getSourceDevice().isEmpty()?0:atoi(this->getSourceDevice().toStdString().c_str()), this->getGeneralInputRate(), this->getSourceLocalTransform()); } else if(driver == kSrcVideo) { camera = new CameraVideo( _ui->source_video_lineEdit_path->text().toStdString(), _ui->checkBox_rgbVideo_rectify->isChecked(), this->getGeneralInputRate(), this->getSourceLocalTransform()); } else if(driver == kSrcImages) { camera = new CameraImages( _ui->source_images_lineEdit_path->text().toStdString(), _ui->source_images_spinBox_startPos->value(), _ui->source_images_refreshDir->isChecked(), _ui->checkBox_rgbImages_rectify->isChecked(), false, this->getGeneralInputRate(), this->getSourceLocalTransform()); } else if(driver == kSrcDatabase) { UERROR("Call directly DBReader for kSrcDatabase."); return 0; } else { UFATAL("Source driver undefined (%d)!", driver); } if(camera) { // don't set calibration folder if we want raw images QString dir = this->getCameraInfoDir(); QString name = QFileInfo(_ui->lineEdit_calibrationFile->text() .remove("_left.yaml") .remove("_right.yaml") .remove("_pose.yaml") .remove(".yaml")).baseName(); if(!_ui->lineEdit_calibrationFile->text().isEmpty()) { QDir d = QFileInfo(_ui->lineEdit_calibrationFile->text()).dir(); if(!_ui->lineEdit_calibrationFile->text().remove(QFileInfo(_ui->lineEdit_calibrationFile->text()).baseName()).isEmpty()) { dir = d.absolutePath(); } } if(!camera->init(useRawImages?"":dir.toStdString(), name.toStdString())) { UWARN("init camera failed... "); QMessageBox::warning(this, tr("RTAB-Map"), tr("Camera initialization failed...")); delete camera; camera = 0; } else { //should be after initialization if(driver == kSrcOpenNI2) { ((CameraOpenNI2*)camera)->setAutoWhiteBalance(_ui->openni2_autoWhiteBalance->isChecked()); ((CameraOpenNI2*)camera)->setAutoExposure(_ui->openni2_autoExposure->isChecked()); ((CameraOpenNI2*)camera)->setMirroring(_ui->openni2_mirroring->isChecked()); ((CameraOpenNI2*)camera)->setOpenNI2StampsAndIDsUsed(_ui->openni2_stampsIdsUsed->isChecked()); if(CameraOpenNI2::exposureGainAvailable()) { ((CameraOpenNI2*)camera)->setExposure(_ui->openni2_exposure->value()); ((CameraOpenNI2*)camera)->setGain(_ui->openni2_gain->value()); } } } } return camera; } bool PreferencesDialog::isStatisticsPublished() const { return _ui->groupBox_publishing->isChecked(); } double PreferencesDialog::getLoopThr() const { return _ui->general_doubleSpinBox_hardThr->value(); } double PreferencesDialog::getVpThr() const { return _ui->general_doubleSpinBox_vp->value(); } double PreferencesDialog::getSimThr() const { return _ui->doubleSpinBox_similarityThreshold->value(); } int PreferencesDialog::getOdomStrategy() const { return _ui->odom_strategy->currentIndex(); } int PreferencesDialog::getOdomBufferSize() const { return _ui->odom_dataBufferSize->value(); } bool PreferencesDialog::getRegVarianceFromInliersCount() const { return _ui->loopClosure_bowVarianceFromInliersCount->isChecked(); } QString PreferencesDialog::getCameraInfoDir() const { return (this->getWorkingDirectory().isEmpty()?".":this->getWorkingDirectory())+"/camera_info"; } bool PreferencesDialog::isImagesKept() const { return _ui->general_checkBox_imagesKept->isChecked(); } float PreferencesDialog::getTimeLimit() const { return _ui->general_doubleSpinBox_timeThr->value(); } float PreferencesDialog::getDetectionRate() const { return _ui->general_doubleSpinBox_detectionRate->value(); } bool PreferencesDialog::isSLAMMode() const { return _ui->general_checkBox_SLAM_mode->isChecked(); } /*** SETTERS ***/ void PreferencesDialog::setInputRate(double value) { ULOGGER_DEBUG("imgRate=%2.2f", value); if(_ui->general_doubleSpinBox_imgRate->value() != value) { _ui->general_doubleSpinBox_imgRate->setValue(value); if(validateForm()) { this->writeSettings(getTmpIniFilePath()); } else { this->readSettingsBegin(); } } } void PreferencesDialog::setDetectionRate(double value) { ULOGGER_DEBUG("detectionRate=%2.2f", value); if(_ui->general_doubleSpinBox_detectionRate->value() != value) { _ui->general_doubleSpinBox_detectionRate->setValue(value); if(validateForm()) { this->writeSettings(getTmpIniFilePath()); } else { this->readSettingsBegin(); } } } void PreferencesDialog::setTimeLimit(float value) { ULOGGER_DEBUG("timeLimit=%fs", value); if(_ui->general_doubleSpinBox_timeThr->value() != value) { _ui->general_doubleSpinBox_timeThr->setValue(value); if(validateForm()) { this->writeSettings(getTmpIniFilePath()); } else { this->readSettingsBegin(); } } } void PreferencesDialog::setSLAMMode(bool enabled) { ULOGGER_DEBUG("slam mode=%s", enabled?"true":"false"); if(_ui->general_checkBox_SLAM_mode->isChecked() != enabled) { _ui->general_checkBox_SLAM_mode->setChecked(enabled); if(validateForm()) { this->writeSettings(getTmpIniFilePath()); } else { this->readSettingsBegin(); } } } void PreferencesDialog::testOdometry() { DBReader dbReader(_ui->source_database_lineEdit_path->text().toStdString(), _ui->source_checkBox_useDbStamps->isChecked()?-1:this->getGeneralInputRate(), true, true); Camera * camera = 0; if(this->getSourceType() == kSrcDatabase) { if(!dbReader.init()) { QMessageBox::warning(this, tr("Camera viewer"), tr("Failed to initialize the database reader!")); return; } } else { camera = this->createCamera(); if(!camera) { return; } } ParametersMap parameters = this->getAllParameters(); Odometry * odometry; if(this->getOdomStrategy() == 1) { odometry = new OdometryOpticalFlow(parameters); } else if(this->getOdomStrategy() == 2) { odometry = new OdometryMono(parameters); } else { odometry = new OdometryBOW(parameters); } OdometryThread odomThread( odometry, // take ownership of odometry _ui->odom_dataBufferSize->value()); odomThread.registerToEventsManager(); OdometryViewer * odomViewer = new OdometryViewer(10, _ui->spinBox_decimation_odom->value(), _ui->doubleSpinBox_voxelSize_odom->value(), _ui->doubleSpinBox_maxDepth_odom->value(), this->getOdomQualityWarnThr(), this); odomViewer->setWindowTitle(tr("Odometry viewer")); odomViewer->resize(1280, 480+QPushButton().minimumHeight()); odomViewer->registerToEventsManager(); if(camera) { CameraThread cameraThread(camera); // take ownership of camera cameraThread.setMirroringEnabled(isSourceMirroring()); cameraThread.setColorOnly(_ui->checkbox_rgbd_colorOnly->isChecked()); cameraThread.setStereoToDepth(_ui->checkbox_stereo_depthGenerated->isChecked()); UEventsManager::createPipe(&cameraThread, &odomThread, "CameraEvent"); UEventsManager::createPipe(&odomThread, odomViewer, "OdometryEvent"); UEventsManager::createPipe(odomViewer, &odomThread, "OdometryResetEvent"); odomThread.start(); cameraThread.start(); odomViewer->exec(); delete odomViewer; cameraThread.join(true); odomThread.join(true); } else { UEventsManager::createPipe(&dbReader, &odomThread, "CameraEvent"); UEventsManager::createPipe(&odomThread, odomViewer, "OdometryEvent"); UEventsManager::createPipe(odomViewer, &odomThread, "OdometryResetEvent"); odomThread.start(); dbReader.start(); odomViewer->exec(); delete odomViewer; dbReader.join(true); odomThread.join(true); } } void PreferencesDialog::testCamera() { CameraViewer * window = new CameraViewer(this); window->setWindowTitle(tr("Camera viewer")); window->resize(1280, 480+QPushButton().minimumHeight()); window->registerToEventsManager(); if(this->getSourceType() == kSrcDatabase) { DBReader dbReader(_ui->source_database_lineEdit_path->text().toStdString(), _ui->source_checkBox_useDbStamps->isChecked()?-1:this->getGeneralInputRate(), true, true); if(!dbReader.init()) { QMessageBox::warning(this, tr("Camera viewer"), tr("Failed to initialize the database reader!")); delete window; } else { UEventsManager::createPipe(&dbReader, window, "CameraEvent"); dbReader.start(); window->exec(); delete window; dbReader.join(true); } } else { Camera * camera = this->createCamera(); if(camera) { CameraThread cameraThread(camera); cameraThread.setMirroringEnabled(isSourceMirroring()); cameraThread.setColorOnly(_ui->checkbox_rgbd_colorOnly->isChecked()); cameraThread.setStereoToDepth(_ui->checkbox_stereo_depthGenerated->isChecked()); UEventsManager::createPipe(&cameraThread, window, "CameraEvent"); cameraThread.start(); window->exec(); delete window; cameraThread.join(true); } else { delete window; } } } void PreferencesDialog::calibrate() { if(this->getSourceType() == kSrcDatabase) { QMessageBox::warning(this, tr("Calibration"), tr("Cannot calibrate database source!")); return; } Camera * camera = this->createCamera(true); if(!camera) { return; } if(!this->getCameraInfoDir().isEmpty()) { QDir dir(this->getCameraInfoDir()); if (!dir.exists()) { UINFO("Creating camera_info directory: \"%s\"", this->getCameraInfoDir().toStdString().c_str()); if(!dir.mkpath(this->getCameraInfoDir())) { UWARN("Could create camera_info directory: \"%s\"", this->getCameraInfoDir().toStdString().c_str()); } } } _calibrationDialog->setStereoMode(this->getSourceType() != kSrcRGB); // RGB+Depth or left+right _calibrationDialog->setSwitchedImages(dynamic_cast(camera) != 0); _calibrationDialog->setSavingDirectory(this->getCameraInfoDir()); _calibrationDialog->registerToEventsManager(); CameraThread cameraThread(camera); UEventsManager::createPipe(&cameraThread, _calibrationDialog, "CameraEvent"); cameraThread.start(); _calibrationDialog->exec(); _calibrationDialog->unregisterFromEventsManager(); cameraThread.join(true); } void PreferencesDialog::calibrateSimple() { CreateSimpleCalibrationDialog dialog(this->getCameraInfoDir(), "", this); dialog.exec(); } }