From 8754da742014bc733c4c9a1436ce29d32e984cc1 Mon Sep 17 00:00:00 2001 From: matlabbe Date: Thu, 16 Jul 2015 14:44:25 -0400 Subject: [PATCH] Added StereoVideo source input (side-by-side video) --- corelib/include/rtabmap/core/CameraModel.h | 3 + corelib/include/rtabmap/core/CameraRGB.h | 7 + corelib/include/rtabmap/core/CameraStereo.h | 36 ++++ corelib/src/CameraRGB.cpp | 72 +++++-- corelib/src/CameraStereo.cpp | 162 +++++++++++++-- .../include/rtabmap/gui/PreferencesDialog.h | 6 + guilib/src/PreferencesDialog.cpp | 68 +++++++ guilib/src/ui/preferencesDialog.ui | 189 +++++++++++++++--- 8 files changed, 485 insertions(+), 58 deletions(-) diff --git a/corelib/include/rtabmap/core/CameraModel.h b/corelib/include/rtabmap/core/CameraModel.h index 1f1c8da1..8837fc57 100644 --- a/corelib/include/rtabmap/core/CameraModel.h +++ b/corelib/include/rtabmap/core/CameraModel.h @@ -80,6 +80,7 @@ public: const cv::Mat & R() const {return R_;} //rectification matrix const cv::Mat & P() const {return P_;} //projection matrix + void setLocalTransform(const Transform & transform) {localTransform_ = transform;} const Transform & localTransform() const {return localTransform_;} const cv::Size & imageSize() const {return imageSize_;} @@ -157,6 +158,8 @@ public: void scale(double scale); + void setLocalTransform(const Transform & transform) {left_.setLocalTransform(transform);} + const Transform & localTransform() const {return left_.localTransform();} Transform stereoTransform() const; const CameraModel & left() const {return left_;} diff --git a/corelib/include/rtabmap/core/CameraRGB.h b/corelib/include/rtabmap/core/CameraRGB.h index e1bb899a..889feb30 100644 --- a/corelib/include/rtabmap/core/CameraRGB.h +++ b/corelib/include/rtabmap/core/CameraRGB.h @@ -52,6 +52,7 @@ public: CameraImages(const std::string & path, int startAt = 1, bool refreshDir = false, + bool rectifyImages = false, float imageRate = 0, const Transform & localTransform = Transform::getIdentity()); virtual ~CameraImages(); @@ -71,9 +72,13 @@ private: // If the list of files in the directory is refreshed // on each call of takeImage() bool _refreshDir; + bool _rectifyImages; int _count; UDirectory * _dir; std::string _lastFileName; + + std::string _cameraName; + CameraModel _model; }; @@ -93,6 +98,7 @@ public: float imageRate = 0, const Transform & localTransform = Transform::getIdentity()); CameraVideo(const std::string & filePath, + bool rectifyImages = false, float imageRate = 0, const Transform & localTransform = Transform::getIdentity()); virtual ~CameraVideo(); @@ -109,6 +115,7 @@ protected: private: // File type std::string _filePath; + bool _rectifyImages; cv::VideoCapture _capture; Source _src; diff --git a/corelib/include/rtabmap/core/CameraStereo.h b/corelib/include/rtabmap/core/CameraStereo.h index ef897f98..3136aeb5 100644 --- a/corelib/include/rtabmap/core/CameraStereo.h +++ b/corelib/include/rtabmap/core/CameraStereo.h @@ -107,6 +107,7 @@ public: CameraStereoImages( const std::string & path, const std::string & timestampsPath = "", // "times.txt" + bool rectifyImages = false, float imageRate=0.0f, const Transform & localTransform = Transform::getIdentity()); virtual ~CameraStereoImages(); @@ -122,9 +123,44 @@ private: CameraImages * camera_; CameraImages * camera2_; std::string timestampsPath_; + bool rectifyImages_; std::list stamps_; StereoCameraModel stereoModel_; std::string cameraName_; }; + +///////////////////////// +// CameraStereoVideo +///////////////////////// +class CameraImages; +class RTABMAP_EXP CameraStereoVideo : + public Camera +{ +public: + static bool available(); + +public: + CameraStereoVideo( + const std::string & path, + bool rectifyImages = false, + float imageRate=0.0f, + const Transform & localTransform = Transform::getIdentity()); + virtual ~CameraStereoVideo(); + + virtual bool init(const std::string & calibrationFolder = ".", const std::string & cameraName = ""); + virtual bool isCalibrated() const; + virtual std::string getSerial() const; + +protected: + virtual SensorData captureImage(); + +private: + cv::VideoCapture capture_; + std::string path_; + bool rectifyImages_; + StereoCameraModel stereoModel_; + std::string cameraName_; +}; + } // namespace rtabmap diff --git a/corelib/src/CameraRGB.cpp b/corelib/src/CameraRGB.cpp index 55bdd762..be306ea2 100644 --- a/corelib/src/CameraRGB.cpp +++ b/corelib/src/CameraRGB.cpp @@ -50,12 +50,14 @@ namespace rtabmap CameraImages::CameraImages(const std::string & path, int startAt, bool refreshDir, + bool rectifyImages, float imageRate, const Transform & localTransform) : Camera(imageRate, localTransform), _path(path), _startAt(startAt), _refreshDir(refreshDir), + _rectifyImages(rectifyImages), _count(0), _dir(0) { @@ -72,6 +74,8 @@ CameraImages::~CameraImages(void) bool CameraImages::init(const std::string & calibrationFolder, const std::string & cameraName) { + _cameraName = cameraName; + UDEBUG(""); if(_dir) { @@ -98,17 +102,43 @@ bool CameraImages::init(const std::string & calibrationFolder, const std::string { UINFO("path=%s images=%d", _path.c_str(), (int)this->imagesCount()); } + + // look for calibration files + if(!calibrationFolder.empty() && !cameraName.empty()) + { + if(!_model.load(calibrationFolder + "/" + cameraName + ".yaml")) + { + UWARN("Missing calibration files for camera \"%s\" in \"%s\" folder, you should calibrate the camera!", + cameraName.c_str(), calibrationFolder.c_str()); + } + else + { + UINFO("Camera parameters: fx=%f fy=%f cx=%f cy=%f", + _model.fx(), + _model.fy(), + _model.cx(), + _model.cy()); + } + } + + _model.setLocalTransform(this->getLocalTransform()); + if(_rectifyImages && !_model.isValid()) + { + UERROR("Parameter \"rectifyImages\" is set, but no camera model is loaded or valid."); + return false; + } + return _dir->isValid(); } bool CameraImages::isCalibrated() const { - return false; + return _model.isValid(); } std::string CameraImages::getSerial() const { - return ""; + return _cameraName; } unsigned int CameraImages::imagesCount() const @@ -189,13 +219,18 @@ SensorData CameraImages::captureImage() } } } + + if(!img.empty() && _model.isValid() && _rectifyImages) + { + img = _model.rectifyImage(img); + } } else { UWARN("Directory is not set, camera must be initialized."); } - return SensorData(img); + return SensorData(img, _model, this->getNextSeqID(), UTimer::now()); } @@ -203,21 +238,26 @@ SensorData CameraImages::captureImage() ///////////////////////// // CameraVideo ///////////////////////// -CameraVideo::CameraVideo(int usbDevice, - float imageRate, - const Transform & localTransform) : +CameraVideo::CameraVideo( + int usbDevice, + float imageRate, + const Transform & localTransform) : Camera(imageRate, localTransform), + _rectifyImages(false), _src(kUsbDevice), _usbDevice(usbDevice) { } -CameraVideo::CameraVideo(const std::string & filePath, - float imageRate, - const Transform & localTransform) : +CameraVideo::CameraVideo( + const std::string & filePath, + bool rectifyImages, + float imageRate, + const Transform & localTransform) : Camera(imageRate, localTransform), _filePath(filePath), + _rectifyImages(rectifyImages), _src(kVideoFile), _usbDevice(0) { @@ -274,13 +314,19 @@ bool CameraVideo::init(const std::string & calibrationFolder, const std::string } else { - UINFO("Camera parameters: fx=%f cx=%f cy=%f cy=%f", + UINFO("Camera parameters: fx=%f fy=%f cx=%f cy=%f", _model.fx(), + _model.fy(), _model.cx(), - _model.cy(), _model.cy()); } } + _model.setLocalTransform(this->getLocalTransform()); + if(_rectifyImages && !_model.isValid()) + { + UERROR("Parameter \"rectifyImages\" is set, but no camera model is loaded or valid."); + return false; + } } return true; } @@ -302,7 +348,7 @@ SensorData CameraVideo::captureImage() { if(_capture.read(img)) { - if(_model.isValid()) + if(_model.isValid() && (_src != kVideoFile || _rectifyImages)) { img = _model.rectifyImage(img); } @@ -322,7 +368,7 @@ SensorData CameraVideo::captureImage() ULOGGER_WARN("The camera must be initialized before requesting an image."); } - return SensorData(img); + return SensorData(img, _model, this->getNextSeqID(), UTimer::now()); } } // namespace rtabmap diff --git a/corelib/src/CameraStereo.cpp b/corelib/src/CameraStereo.cpp index ef208066..bbffbc1e 100644 --- a/corelib/src/CameraStereo.cpp +++ b/corelib/src/CameraStereo.cpp @@ -733,12 +733,14 @@ bool CameraStereoImages::available() CameraStereoImages::CameraStereoImages( const std::string & path, const std::string & timestampsPath, + bool rectifyImages, float imageRate, const Transform & localTransform) : Camera(imageRate, localTransform), camera_(0), camera2_(0), - timestampsPath_(timestampsPath) + timestampsPath_(timestampsPath), + rectifyImages_(rectifyImages) { std::vector paths = uListToVector(uSplit(path, uStrContains(path, ":")?':':';')); if(paths.size() >= 1) @@ -771,10 +773,9 @@ CameraStereoImages::~CameraStereoImages() bool CameraStereoImages::init(const std::string & calibrationFolder, const std::string & cameraName) { // look for calibration files - cameraName_.clear(); + cameraName_ = cameraName; if(!calibrationFolder.empty() && !cameraName.empty()) { - cameraName_ = cameraName; if(!stereoModel_.load(calibrationFolder, cameraName)) { UWARN("Missing calibration files for camera \"%s\" in \"%s\" folder, you should calibrate the camera!", @@ -789,6 +790,13 @@ bool CameraStereoImages::init(const std::string & calibrationFolder, const std:: stereoModel_.baseline()); } } + stereoModel_.setLocalTransform(this->getLocalTransform()); + if(rectifyImages_ && !stereoModel_.isValid()) + { + UERROR("Parameter \"rectifyImages\" is set, but no stereo model is loaded or valid."); + return false; + } + bool success = false; if(camera_ == 0) { @@ -893,20 +901,148 @@ SensorData CameraStereoImages::captureImage() if(!right.imageRaw().empty()) { // Rectification - //left = stereoModel_.left().rectifyImage(left); - //right = stereoModel_.right().rectifyImage(right); - StereoCameraModel model( - stereoModel_.left().fx(), //fx - stereoModel_.left().fy(), //fy - stereoModel_.left().cx(), //cx - stereoModel_.left().cy(), //cy - stereoModel_.baseline(), - this->getLocalTransform()); - data = SensorData(left.imageRaw(), right.imageRaw(), model, this->getNextSeqID(), stamp); + cv::Mat leftImage = left.imageRaw(); + cv::Mat rightImage = right.imageRaw(); + if(rightImage.type() != CV_8UC1) + { + cv::Mat tmp; + cv::cvtColor(rightImage, tmp, CV_BGR2GRAY); + rightImage = tmp; + } + if(rectifyImages_ && stereoModel_.left().isValid() && stereoModel_.right().isValid()) + { + leftImage = stereoModel_.left().rectifyImage(leftImage); + rightImage = stereoModel_.right().rectifyImage(rightImage); + } + data = SensorData(leftImage, rightImage, stereoModel_, this->getNextSeqID(), stamp); } } } return data; } +// +// CameraStereoVideo +// +bool CameraStereoVideo::available() +{ + return true; +} + +CameraStereoVideo::CameraStereoVideo( + const std::string & path, + bool rectifyImages, + float imageRate, + const Transform & localTransform) : + Camera(imageRate, localTransform), + path_(path), + rectifyImages_(rectifyImages) +{ +} + +CameraStereoVideo::~CameraStereoVideo() +{ + capture_.release(); +} + +bool CameraStereoVideo::init(const std::string & calibrationFolder, const std::string & cameraName) +{ + if(capture_.isOpened()) + { + capture_.release(); + } + ULOGGER_DEBUG("Camera: filename=\"%s\"", path_.c_str()); + capture_.open(path_.c_str()); + + if(!capture_.isOpened()) + { + ULOGGER_ERROR("Camera: Failed to create a capture object!"); + capture_.release(); + return false; + } + else + { + // look for calibration files + cameraName_ = cameraName; + if(!calibrationFolder.empty() && !cameraName.empty()) + { + if(!stereoModel_.load(calibrationFolder, cameraName)) + { + UWARN("Missing calibration files for camera \"%s\" in \"%s\" folder, you should calibrate the camera!", + cameraName.c_str(), calibrationFolder.c_str()); + } + else + { + UINFO("Stereo parameters: fx=%f cx=%f cy=%f baseline=%f", + stereoModel_.left().fx(), + stereoModel_.left().cx(), + stereoModel_.left().cy(), + stereoModel_.baseline()); + } + } + stereoModel_.setLocalTransform(this->getLocalTransform()); + if(rectifyImages_ && !stereoModel_.isValid()) + { + UERROR("Parameter \"rectifyImages\" is set, but no stereo model is loaded or valid."); + return false; + } + } + return true; +} + +bool CameraStereoVideo::isCalibrated() const +{ + return stereoModel_.isValid(); +} + +std::string CameraStereoVideo::getSerial() const +{ + return cameraName_; +} + +SensorData CameraStereoVideo::captureImage() +{ + SensorData data; + + cv::Mat img; + if(capture_.isOpened()) + { + if(capture_.read(img)) + { + // Rectification + cv::Mat leftImage(img, cv::Rect( 0, 0, img.size().width/2, img.size().height )); + cv::Mat rightImage(img, cv::Rect( img.size().width/2, 0, img.size().width/2, img.size().height )); + bool rightCvt = false; + if(rightImage.type() != CV_8UC1) + { + cv::Mat tmp; + cv::cvtColor(rightImage, tmp, CV_BGR2GRAY); + rightImage = tmp; + rightCvt = true; + } + if(rectifyImages_ && stereoModel_.left().isValid() && stereoModel_.right().isValid()) + { + leftImage = stereoModel_.left().rectifyImage(leftImage); + rightImage = stereoModel_.right().rectifyImage(rightImage); + } + else + { + leftImage = leftImage.clone(); + if(!rightCvt) + { + rightImage = rightImage.clone(); + } + } + data = SensorData(leftImage, rightImage, stereoModel_, this->getNextSeqID(), UTimer::now()); + } + } + else + { + ULOGGER_WARN("The camera must be initialized before requesting an image."); + } + + return data; +} + + } // namespace rtabmap diff --git a/guilib/include/rtabmap/gui/PreferencesDialog.h b/guilib/include/rtabmap/gui/PreferencesDialog.h index 70f29a88..c3148394 100644 --- a/guilib/include/rtabmap/gui/PreferencesDialog.h +++ b/guilib/include/rtabmap/gui/PreferencesDialog.h @@ -93,6 +93,7 @@ public: kSrcDC1394 = 100, kSrcFlyCapture2 = 101, kSrcStereoImages = 102, + kSrcStereoVideo = 103, kSrcRGB = 200, kSrcUsbDevice = 200, @@ -184,7 +185,9 @@ public: int getSourceImagesSuffixIndex() const; //Images group int getSourceImagesStartPos() const; //Images group bool getSourceImagesRefreshDir() const; //Images group + bool getSourceImagesRectify() const; //Images group QString getSourceVideoPath() const; //Video group + bool getSourceVideoRectify() const; //Video group QString getSourceDatabasePath() const; //Database group bool getSourceDatabaseOdometryIgnored() const; //Database group bool getSourceDatabaseGoalDelayIgnored() const; //Database group @@ -196,6 +199,8 @@ public: int getSourceOpenni2Gain() const; //Openni group bool getSourceOpenni2Mirroring() const; //Openni group int getSourceFreenect2Format() const; //Openni group + bool getSourceStereoImagesRectify() const; + bool getSourceStereoVideoRectify() const; bool isSourceRGBDColorOnly() const; Transform getSourceLocalTransform() const; //Openni group Camera * createCamera(bool useRawImages = false); // return camera should be deleted if not null @@ -261,6 +266,7 @@ private slots: void selectSourceStereoImagesPath(); void selectSourceImagesPath(); void selectSourceVideoPath(); + void selectSourceStereoVideoPath(); void selectSourceOniPath(); void selectSourceOni2Path(); void updateSourceGrpVisibility(); diff --git a/guilib/src/PreferencesDialog.cpp b/guilib/src/PreferencesDialog.cpp index 839032f2..f162e667 100644 --- a/guilib/src/PreferencesDialog.cpp +++ b/guilib/src/PreferencesDialog.cpp @@ -333,9 +333,11 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) : 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())); @@ -363,6 +365,10 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) : connect(_ui->lineEdit_cameraStereoImages_timestamps, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->toolButton_cameraStereoImages_path, SIGNAL(clicked()), this, SLOT(selectSourceStereoImagesPath())); connect(_ui->lineEdit_cameraStereoImages_path, SIGNAL(textChanged(const QString &)), 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->pushButton_calibrate, SIGNAL(clicked()), this, SLOT(calibrate())); connect(_ui->toolButton_openniOniPath, SIGNAL(clicked()), this, SLOT(selectSourceOniPath())); @@ -1036,6 +1042,8 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox) _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(false); @@ -1084,6 +1092,9 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox) _ui->source_comboBox_image_type->setCurrentIndex(kSrcDC1394-kSrcDC1394); _ui->lineEdit_cameraStereoImages_timestamps->setText(""); _ui->lineEdit_cameraStereoImages_path->setText(""); + _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()) { @@ -1348,16 +1359,24 @@ void PreferencesDialog::readCameraSettings(const QString & filePath) settings.beginGroup("StereoImages"); _ui->lineEdit_cameraStereoImages_timestamps->setText(settings.value("stamps", _ui->lineEdit_cameraStereoImages_timestamps->text()).toString()); _ui->lineEdit_cameraStereoImages_path->setText(settings.value("path", _ui->lineEdit_cameraStereoImages_path->text()).toString()); + _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"); @@ -1639,16 +1658,24 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath) const settings.beginGroup("StereoImages"); settings.setValue("stamps", _ui->lineEdit_cameraStereoImages_timestamps->text()); settings.setValue("path", _ui->lineEdit_cameraStereoImages_path->text()); + 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"); @@ -2224,6 +2251,20 @@ void PreferencesDialog::selectSourceVideoPath() } } +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(); @@ -3274,10 +3315,18 @@ bool PreferencesDialog::getSourceImagesRefreshDir() const { return _ui->source_images_refreshDir->isChecked(); } +bool PreferencesDialog::getSourceImagesRectify() const +{ + return _ui->checkBox_rgbImages_rectify->isChecked(); +} QString PreferencesDialog::getSourceVideoPath() const { return _ui->source_video_lineEdit_path->text(); } +bool PreferencesDialog::getSourceVideoRectify() const +{ + return _ui->checkBox_rgbVideo_rectify->isChecked(); +} QString PreferencesDialog::getSourceDatabasePath() const { return _ui->source_database_lineEdit_path->text(); @@ -3323,6 +3372,14 @@ int PreferencesDialog::getSourceFreenect2Format() const { return _ui->comboBox_freenect2Format->currentIndex(); } +bool PreferencesDialog::getSourceStereoImagesRectify() const +{ + return _ui->checkBox_stereoImages_rectify->isChecked(); +} +bool PreferencesDialog::getSourceStereoVideoRectify() const +{ + return _ui->checkBox_stereoVideo_rectify->isChecked(); +} bool PreferencesDialog::isSourceRGBDColorOnly() const { @@ -3438,6 +3495,15 @@ Camera * PreferencesDialog::createCamera(bool useRawImages) camera = new CameraStereoImages( _ui->lineEdit_cameraStereoImages_path->text().append(QDir::separator()).toStdString(), _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()); } @@ -3452,6 +3518,7 @@ Camera * PreferencesDialog::createCamera(bool useRawImages) { camera = new CameraVideo( this->getSourceVideoPath().toStdString(), + this->getSourceVideoRectify(), this->getGeneralInputRate(), this->getSourceLocalTransform()); } @@ -3461,6 +3528,7 @@ Camera * PreferencesDialog::createCamera(bool useRawImages) this->getSourceImagesPath().toStdString(), this->getSourceImagesStartPos(), this->getSourceImagesRefreshDir(), + this->getSourceVideoRectify(), this->getGeneralInputRate(), this->getSourceLocalTransform()); } diff --git a/guilib/src/ui/preferencesDialog.ui b/guilib/src/ui/preferencesDialog.ui index d3106a96..e27acfa6 100644 --- a/guilib/src/ui/preferencesDialog.ui +++ b/guilib/src/ui/preferencesDialog.ui @@ -63,9 +63,9 @@ 0 - 0 - 760 - 1570 + -290 + 755 + 1591 @@ -1538,7 +1538,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki - 0 + 2 @@ -1948,7 +1948,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki - + @@ -1969,6 +1969,11 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki Images + + + Video (Side-by-Side) + + @@ -1986,9 +1991,9 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki - 2 + 3 - + @@ -2001,7 +2006,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki - CameraStereoImages + Stereo Images @@ -2018,6 +2023,33 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki + + + + + + + + + + + ... + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + @@ -2028,13 +2060,6 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki - - - - - - - @@ -2045,15 +2070,44 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki - - + + - ... + Rectify images. If checked, the images will be rectified using the calibration file (if its name is set above). If not checked, we assume that images are already rectified. + + + true + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + Stereo side-by-side video (*.avi) + + - + Qt::Vertical @@ -2065,6 +2119,37 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki + + + + ... + + + + + + + + + + + + + + + + + + + + + Rectify images. If checked, the images will be rectified using the calibration file (if its name is set above). If not checked, we assume that images are already rectified. + + + true + + + @@ -2157,6 +2242,33 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki Images dataset + + + + false + + + + + + + Refresh the directory files list after each image loaded. + + + true + + + + + + + Start position (default 1, 0=start from the last). + + + true + + + @@ -2174,13 +2286,6 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki - - - - false - - - @@ -2188,17 +2293,20 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki - - + + - Refresh the directory files list after each image loaded. + Rectify images. If checked, the images will be rectified using the calibration file (if its name is set above). If not checked, we assume that images are already rectified. + + + true - - + + - Start position (default 1, 0=start from the last). + @@ -2242,6 +2350,23 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki + + + + Rectify images. If checked, the images will be rectified using the calibration file (if its name is set above). If not checked, we assume that images are already rectified. + + + true + + + + + + + + + +