Added StereoVideo source input (side-by-side video)

This commit is contained in:
matlabbe
2015-07-16 14:44:25 -04:00
parent 6872b16550
commit 8754da7420
8 changed files with 485 additions and 58 deletions
@@ -80,6 +80,7 @@ public:
const cv::Mat & R() const {return R_;} //rectification matrix const cv::Mat & R() const {return R_;} //rectification matrix
const cv::Mat & P() const {return P_;} //projection matrix const cv::Mat & P() const {return P_;} //projection matrix
void setLocalTransform(const Transform & transform) {localTransform_ = transform;}
const Transform & localTransform() const {return localTransform_;} const Transform & localTransform() const {return localTransform_;}
const cv::Size & imageSize() const {return imageSize_;} const cv::Size & imageSize() const {return imageSize_;}
@@ -157,6 +158,8 @@ public:
void scale(double scale); void scale(double scale);
void setLocalTransform(const Transform & transform) {left_.setLocalTransform(transform);}
const Transform & localTransform() const {return left_.localTransform();}
Transform stereoTransform() const; Transform stereoTransform() const;
const CameraModel & left() const {return left_;} const CameraModel & left() const {return left_;}
+7
View File
@@ -52,6 +52,7 @@ public:
CameraImages(const std::string & path, CameraImages(const std::string & path,
int startAt = 1, int startAt = 1,
bool refreshDir = false, bool refreshDir = false,
bool rectifyImages = false,
float imageRate = 0, float imageRate = 0,
const Transform & localTransform = Transform::getIdentity()); const Transform & localTransform = Transform::getIdentity());
virtual ~CameraImages(); virtual ~CameraImages();
@@ -71,9 +72,13 @@ private:
// If the list of files in the directory is refreshed // If the list of files in the directory is refreshed
// on each call of takeImage() // on each call of takeImage()
bool _refreshDir; bool _refreshDir;
bool _rectifyImages;
int _count; int _count;
UDirectory * _dir; UDirectory * _dir;
std::string _lastFileName; std::string _lastFileName;
std::string _cameraName;
CameraModel _model;
}; };
@@ -93,6 +98,7 @@ public:
float imageRate = 0, float imageRate = 0,
const Transform & localTransform = Transform::getIdentity()); const Transform & localTransform = Transform::getIdentity());
CameraVideo(const std::string & filePath, CameraVideo(const std::string & filePath,
bool rectifyImages = false,
float imageRate = 0, float imageRate = 0,
const Transform & localTransform = Transform::getIdentity()); const Transform & localTransform = Transform::getIdentity());
virtual ~CameraVideo(); virtual ~CameraVideo();
@@ -109,6 +115,7 @@ protected:
private: private:
// File type // File type
std::string _filePath; std::string _filePath;
bool _rectifyImages;
cv::VideoCapture _capture; cv::VideoCapture _capture;
Source _src; Source _src;
@@ -107,6 +107,7 @@ public:
CameraStereoImages( CameraStereoImages(
const std::string & path, const std::string & path,
const std::string & timestampsPath = "", // "times.txt" const std::string & timestampsPath = "", // "times.txt"
bool rectifyImages = false,
float imageRate=0.0f, float imageRate=0.0f,
const Transform & localTransform = Transform::getIdentity()); const Transform & localTransform = Transform::getIdentity());
virtual ~CameraStereoImages(); virtual ~CameraStereoImages();
@@ -122,9 +123,44 @@ private:
CameraImages * camera_; CameraImages * camera_;
CameraImages * camera2_; CameraImages * camera2_;
std::string timestampsPath_; std::string timestampsPath_;
bool rectifyImages_;
std::list<double> stamps_; std::list<double> stamps_;
StereoCameraModel stereoModel_; StereoCameraModel stereoModel_;
std::string cameraName_; 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 } // namespace rtabmap
+59 -13
View File
@@ -50,12 +50,14 @@ namespace rtabmap
CameraImages::CameraImages(const std::string & path, CameraImages::CameraImages(const std::string & path,
int startAt, int startAt,
bool refreshDir, bool refreshDir,
bool rectifyImages,
float imageRate, float imageRate,
const Transform & localTransform) : const Transform & localTransform) :
Camera(imageRate, localTransform), Camera(imageRate, localTransform),
_path(path), _path(path),
_startAt(startAt), _startAt(startAt),
_refreshDir(refreshDir), _refreshDir(refreshDir),
_rectifyImages(rectifyImages),
_count(0), _count(0),
_dir(0) _dir(0)
{ {
@@ -72,6 +74,8 @@ CameraImages::~CameraImages(void)
bool CameraImages::init(const std::string & calibrationFolder, const std::string & cameraName) bool CameraImages::init(const std::string & calibrationFolder, const std::string & cameraName)
{ {
_cameraName = cameraName;
UDEBUG(""); UDEBUG("");
if(_dir) 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()); 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(); return _dir->isValid();
} }
bool CameraImages::isCalibrated() const bool CameraImages::isCalibrated() const
{ {
return false; return _model.isValid();
} }
std::string CameraImages::getSerial() const std::string CameraImages::getSerial() const
{ {
return ""; return _cameraName;
} }
unsigned int CameraImages::imagesCount() const unsigned int CameraImages::imagesCount() const
@@ -189,13 +219,18 @@ SensorData CameraImages::captureImage()
} }
} }
} }
if(!img.empty() && _model.isValid() && _rectifyImages)
{
img = _model.rectifyImage(img);
}
} }
else else
{ {
UWARN("Directory is not set, camera must be initialized."); 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::CameraVideo(int usbDevice, CameraVideo::CameraVideo(
float imageRate, int usbDevice,
const Transform & localTransform) : float imageRate,
const Transform & localTransform) :
Camera(imageRate, localTransform), Camera(imageRate, localTransform),
_rectifyImages(false),
_src(kUsbDevice), _src(kUsbDevice),
_usbDevice(usbDevice) _usbDevice(usbDevice)
{ {
} }
CameraVideo::CameraVideo(const std::string & filePath, CameraVideo::CameraVideo(
float imageRate, const std::string & filePath,
const Transform & localTransform) : bool rectifyImages,
float imageRate,
const Transform & localTransform) :
Camera(imageRate, localTransform), Camera(imageRate, localTransform),
_filePath(filePath), _filePath(filePath),
_rectifyImages(rectifyImages),
_src(kVideoFile), _src(kVideoFile),
_usbDevice(0) _usbDevice(0)
{ {
@@ -274,13 +314,19 @@ bool CameraVideo::init(const std::string & calibrationFolder, const std::string
} }
else 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.fx(),
_model.fy(),
_model.cx(), _model.cx(),
_model.cy(),
_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; return true;
} }
@@ -302,7 +348,7 @@ SensorData CameraVideo::captureImage()
{ {
if(_capture.read(img)) if(_capture.read(img))
{ {
if(_model.isValid()) if(_model.isValid() && (_src != kVideoFile || _rectifyImages))
{ {
img = _model.rectifyImage(img); img = _model.rectifyImage(img);
} }
@@ -322,7 +368,7 @@ SensorData CameraVideo::captureImage()
ULOGGER_WARN("The camera must be initialized before requesting an image."); ULOGGER_WARN("The camera must be initialized before requesting an image.");
} }
return SensorData(img); return SensorData(img, _model, this->getNextSeqID(), UTimer::now());
} }
} // namespace rtabmap } // namespace rtabmap
+149 -13
View File
@@ -733,12 +733,14 @@ bool CameraStereoImages::available()
CameraStereoImages::CameraStereoImages( CameraStereoImages::CameraStereoImages(
const std::string & path, const std::string & path,
const std::string & timestampsPath, const std::string & timestampsPath,
bool rectifyImages,
float imageRate, float imageRate,
const Transform & localTransform) : const Transform & localTransform) :
Camera(imageRate, localTransform), Camera(imageRate, localTransform),
camera_(0), camera_(0),
camera2_(0), camera2_(0),
timestampsPath_(timestampsPath) timestampsPath_(timestampsPath),
rectifyImages_(rectifyImages)
{ {
std::vector<std::string> paths = uListToVector(uSplit(path, uStrContains(path, ":")?':':';')); std::vector<std::string> paths = uListToVector(uSplit(path, uStrContains(path, ":")?':':';'));
if(paths.size() >= 1) if(paths.size() >= 1)
@@ -771,10 +773,9 @@ CameraStereoImages::~CameraStereoImages()
bool CameraStereoImages::init(const std::string & calibrationFolder, const std::string & cameraName) bool CameraStereoImages::init(const std::string & calibrationFolder, const std::string & cameraName)
{ {
// look for calibration files // look for calibration files
cameraName_.clear(); cameraName_ = cameraName;
if(!calibrationFolder.empty() && !cameraName.empty()) if(!calibrationFolder.empty() && !cameraName.empty())
{ {
cameraName_ = cameraName;
if(!stereoModel_.load(calibrationFolder, cameraName)) if(!stereoModel_.load(calibrationFolder, cameraName))
{ {
UWARN("Missing calibration files for camera \"%s\" in \"%s\" folder, you should calibrate the camera!", 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_.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; bool success = false;
if(camera_ == 0) if(camera_ == 0)
{ {
@@ -893,20 +901,148 @@ SensorData CameraStereoImages::captureImage()
if(!right.imageRaw().empty()) if(!right.imageRaw().empty())
{ {
// Rectification // Rectification
//left = stereoModel_.left().rectifyImage(left); cv::Mat leftImage = left.imageRaw();
//right = stereoModel_.right().rectifyImage(right); cv::Mat rightImage = right.imageRaw();
StereoCameraModel model( if(rightImage.type() != CV_8UC1)
stereoModel_.left().fx(), //fx {
stereoModel_.left().fy(), //fy cv::Mat tmp;
stereoModel_.left().cx(), //cx cv::cvtColor(rightImage, tmp, CV_BGR2GRAY);
stereoModel_.left().cy(), //cy rightImage = tmp;
stereoModel_.baseline(), }
this->getLocalTransform()); if(rectifyImages_ && stereoModel_.left().isValid() && stereoModel_.right().isValid())
data = SensorData(left.imageRaw(), right.imageRaw(), model, this->getNextSeqID(), stamp); {
leftImage = stereoModel_.left().rectifyImage(leftImage);
rightImage = stereoModel_.right().rectifyImage(rightImage);
}
data = SensorData(leftImage, rightImage, stereoModel_, this->getNextSeqID(), stamp);
} }
} }
} }
return data; 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 } // namespace rtabmap
@@ -93,6 +93,7 @@ public:
kSrcDC1394 = 100, kSrcDC1394 = 100,
kSrcFlyCapture2 = 101, kSrcFlyCapture2 = 101,
kSrcStereoImages = 102, kSrcStereoImages = 102,
kSrcStereoVideo = 103,
kSrcRGB = 200, kSrcRGB = 200,
kSrcUsbDevice = 200, kSrcUsbDevice = 200,
@@ -184,7 +185,9 @@ public:
int getSourceImagesSuffixIndex() const; //Images group int getSourceImagesSuffixIndex() const; //Images group
int getSourceImagesStartPos() const; //Images group int getSourceImagesStartPos() const; //Images group
bool getSourceImagesRefreshDir() const; //Images group bool getSourceImagesRefreshDir() const; //Images group
bool getSourceImagesRectify() const; //Images group
QString getSourceVideoPath() const; //Video group QString getSourceVideoPath() const; //Video group
bool getSourceVideoRectify() const; //Video group
QString getSourceDatabasePath() const; //Database group QString getSourceDatabasePath() const; //Database group
bool getSourceDatabaseOdometryIgnored() const; //Database group bool getSourceDatabaseOdometryIgnored() const; //Database group
bool getSourceDatabaseGoalDelayIgnored() const; //Database group bool getSourceDatabaseGoalDelayIgnored() const; //Database group
@@ -196,6 +199,8 @@ public:
int getSourceOpenni2Gain() const; //Openni group int getSourceOpenni2Gain() const; //Openni group
bool getSourceOpenni2Mirroring() const; //Openni group bool getSourceOpenni2Mirroring() const; //Openni group
int getSourceFreenect2Format() const; //Openni group int getSourceFreenect2Format() const; //Openni group
bool getSourceStereoImagesRectify() const;
bool getSourceStereoVideoRectify() const;
bool isSourceRGBDColorOnly() const; bool isSourceRGBDColorOnly() const;
Transform getSourceLocalTransform() const; //Openni group Transform getSourceLocalTransform() const; //Openni group
Camera * createCamera(bool useRawImages = false); // return camera should be deleted if not null Camera * createCamera(bool useRawImages = false); // return camera should be deleted if not null
@@ -261,6 +266,7 @@ private slots:
void selectSourceStereoImagesPath(); void selectSourceStereoImagesPath();
void selectSourceImagesPath(); void selectSourceImagesPath();
void selectSourceVideoPath(); void selectSourceVideoPath();
void selectSourceStereoVideoPath();
void selectSourceOniPath(); void selectSourceOniPath();
void selectSourceOni2Path(); void selectSourceOni2Path();
void updateSourceGrpVisibility(); void updateSourceGrpVisibility();
+68
View File
@@ -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_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_spinBox_startPos, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->source_images_refreshDir, SIGNAL(stateChanged(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 //video group
connect(_ui->source_video_toolButton_selectSource, SIGNAL(clicked()), this, SLOT(selectSourceVideoPath())); 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->source_video_lineEdit_path, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->checkBox_rgbVideo_rectify, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
//database group //database group
connect(_ui->source_database_toolButton_selectSource, SIGNAL(clicked()), this, SLOT(selectSourceDatabase())); connect(_ui->source_database_toolButton_selectSource, SIGNAL(clicked()), this, SLOT(selectSourceDatabase()));
connect(_ui->toolButton_dbViewer, SIGNAL(clicked()), this, SLOT(openDatabaseViewer())); 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->lineEdit_cameraStereoImages_timestamps, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->toolButton_cameraStereoImages_path, SIGNAL(clicked()), this, SLOT(selectSourceStereoImagesPath())); connect(_ui->toolButton_cameraStereoImages_path, SIGNAL(clicked()), this, SLOT(selectSourceStereoImagesPath()));
connect(_ui->lineEdit_cameraStereoImages_path, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); 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->checkbox_rgbd_colorOnly, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->pushButton_calibrate, SIGNAL(clicked()), this, SLOT(calibrate())); connect(_ui->pushButton_calibrate, SIGNAL(clicked()), this, SLOT(calibrate()));
connect(_ui->toolButton_openniOniPath, SIGNAL(clicked()), this, SLOT(selectSourceOniPath())); 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_comboBox_image_type->setCurrentIndex(kSrcUsbDevice-kSrcUsbDevice);
_ui->source_images_spinBox_startPos->setValue(1); _ui->source_images_spinBox_startPos->setValue(1);
_ui->source_images_refreshDir->setChecked(false); _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_ignoreOdometry->setChecked(false);
_ui->source_checkBox_ignoreGoalDelay->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->source_comboBox_image_type->setCurrentIndex(kSrcDC1394-kSrcDC1394);
_ui->lineEdit_cameraStereoImages_timestamps->setText(""); _ui->lineEdit_cameraStereoImages_timestamps->setText("");
_ui->lineEdit_cameraStereoImages_path->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()) else if(groupBox->objectName() == _ui->groupBox_rtabmap_basic0->objectName())
{ {
@@ -1348,16 +1359,24 @@ void PreferencesDialog::readCameraSettings(const QString & filePath)
settings.beginGroup("StereoImages"); settings.beginGroup("StereoImages");
_ui->lineEdit_cameraStereoImages_timestamps->setText(settings.value("stamps", _ui->lineEdit_cameraStereoImages_timestamps->text()).toString()); _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->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.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"); settings.beginGroup("Images");
_ui->source_images_lineEdit_path->setText(settings.value("path", _ui->source_images_lineEdit_path->text()).toString()); _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_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->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.endGroup(); // images
settings.beginGroup("Video"); settings.beginGroup("Video");
_ui->source_video_lineEdit_path->setText(settings.value("path", _ui->source_video_lineEdit_path->text()).toString()); _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.endGroup(); // video
settings.beginGroup("Database"); settings.beginGroup("Database");
@@ -1639,16 +1658,24 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath) const
settings.beginGroup("StereoImages"); settings.beginGroup("StereoImages");
settings.setValue("stamps", _ui->lineEdit_cameraStereoImages_timestamps->text()); settings.setValue("stamps", _ui->lineEdit_cameraStereoImages_timestamps->text());
settings.setValue("path", _ui->lineEdit_cameraStereoImages_path->text()); settings.setValue("path", _ui->lineEdit_cameraStereoImages_path->text());
settings.setValue("rectify", _ui->checkBox_stereoImages_rectify->isChecked());
settings.endGroup(); // StereoImages 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.beginGroup("Images");
settings.setValue("path", _ui->source_images_lineEdit_path->text()); settings.setValue("path", _ui->source_images_lineEdit_path->text());
settings.setValue("startPos", _ui->source_images_spinBox_startPos->value()); settings.setValue("startPos", _ui->source_images_spinBox_startPos->value());
settings.setValue("refreshDir", _ui->source_images_refreshDir->isChecked()); settings.setValue("refreshDir", _ui->source_images_refreshDir->isChecked());
settings.setValue("rectify", _ui->checkBox_rgbImages_rectify->isChecked());
settings.endGroup(); // images settings.endGroup(); // images
settings.beginGroup("Video"); settings.beginGroup("Video");
settings.setValue("path", _ui->source_video_lineEdit_path->text()); settings.setValue("path", _ui->source_video_lineEdit_path->text());
settings.setValue("rectify", _ui->checkBox_rgbVideo_rectify->isChecked());
settings.endGroup(); // video settings.endGroup(); // video
settings.beginGroup("Database"); 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() void PreferencesDialog::selectSourceOniPath()
{ {
QString dir = _ui->lineEdit_openniOniPath->text(); QString dir = _ui->lineEdit_openniOniPath->text();
@@ -3274,10 +3315,18 @@ bool PreferencesDialog::getSourceImagesRefreshDir() const
{ {
return _ui->source_images_refreshDir->isChecked(); return _ui->source_images_refreshDir->isChecked();
} }
bool PreferencesDialog::getSourceImagesRectify() const
{
return _ui->checkBox_rgbImages_rectify->isChecked();
}
QString PreferencesDialog::getSourceVideoPath() const QString PreferencesDialog::getSourceVideoPath() const
{ {
return _ui->source_video_lineEdit_path->text(); return _ui->source_video_lineEdit_path->text();
} }
bool PreferencesDialog::getSourceVideoRectify() const
{
return _ui->checkBox_rgbVideo_rectify->isChecked();
}
QString PreferencesDialog::getSourceDatabasePath() const QString PreferencesDialog::getSourceDatabasePath() const
{ {
return _ui->source_database_lineEdit_path->text(); return _ui->source_database_lineEdit_path->text();
@@ -3323,6 +3372,14 @@ int PreferencesDialog::getSourceFreenect2Format() const
{ {
return _ui->comboBox_freenect2Format->currentIndex(); 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 bool PreferencesDialog::isSourceRGBDColorOnly() const
{ {
@@ -3438,6 +3495,15 @@ Camera * PreferencesDialog::createCamera(bool useRawImages)
camera = new CameraStereoImages( camera = new CameraStereoImages(
_ui->lineEdit_cameraStereoImages_path->text().append(QDir::separator()).toStdString(), _ui->lineEdit_cameraStereoImages_path->text().append(QDir::separator()).toStdString(),
_ui->lineEdit_cameraStereoImages_timestamps->text().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->getGeneralInputRate(),
this->getSourceLocalTransform()); this->getSourceLocalTransform());
} }
@@ -3452,6 +3518,7 @@ Camera * PreferencesDialog::createCamera(bool useRawImages)
{ {
camera = new CameraVideo( camera = new CameraVideo(
this->getSourceVideoPath().toStdString(), this->getSourceVideoPath().toStdString(),
this->getSourceVideoRectify(),
this->getGeneralInputRate(), this->getGeneralInputRate(),
this->getSourceLocalTransform()); this->getSourceLocalTransform());
} }
@@ -3461,6 +3528,7 @@ Camera * PreferencesDialog::createCamera(bool useRawImages)
this->getSourceImagesPath().toStdString(), this->getSourceImagesPath().toStdString(),
this->getSourceImagesStartPos(), this->getSourceImagesStartPos(),
this->getSourceImagesRefreshDir(), this->getSourceImagesRefreshDir(),
this->getSourceVideoRectify(),
this->getGeneralInputRate(), this->getGeneralInputRate(),
this->getSourceLocalTransform()); this->getSourceLocalTransform());
} }
+157 -32
View File
@@ -63,9 +63,9 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>-290</y>
<width>760</width> <width>755</width>
<height>1570</height> <height>1591</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_16"> <layout class="QVBoxLayout" name="verticalLayout_16">
@@ -1538,7 +1538,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
<item> <item>
<widget class="QStackedWidget" name="stackedWidget_src"> <widget class="QStackedWidget" name="stackedWidget_src">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="page_41"> <widget class="QWidget" name="page_41">
<layout class="QVBoxLayout" name="verticalLayout_64"> <layout class="QVBoxLayout" name="verticalLayout_64">
@@ -1948,7 +1948,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QGridLayout" name="gridLayout_58" columnstretch="0,0,0"> <layout class="QGridLayout" name="gridLayout_58" columnstretch="0,0,1">
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="comboBox_cameraStereo"> <widget class="QComboBox" name="comboBox_cameraStereo">
<property name="sizeAdjustPolicy"> <property name="sizeAdjustPolicy">
@@ -1969,6 +1969,11 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
<string>Images</string> <string>Images</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Video (Side-by-Side)</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
@@ -1986,9 +1991,9 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
<item> <item>
<widget class="QStackedWidget" name="stackedWidget_stereo"> <widget class="QStackedWidget" name="stackedWidget_stereo">
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>3</number>
</property> </property>
<widget class="QWidget" name="page_47"/> <widget class="QWidget" name="page_49"/>
<widget class="QWidget" name="page_48"/> <widget class="QWidget" name="page_48"/>
<widget class="QWidget" name="page_53"> <widget class="QWidget" name="page_53">
<layout class="QVBoxLayout" name="verticalLayout_70"> <layout class="QVBoxLayout" name="verticalLayout_70">
@@ -2001,7 +2006,7 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</sizepolicy> </sizepolicy>
</property> </property>
<property name="title"> <property name="title">
<string>CameraStereoImages</string> <string>Stereo Images</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_61" columnstretch="0,0,1"> <layout class="QGridLayout" name="gridLayout_61" columnstretch="0,0,1">
<item row="1" column="1"> <item row="1" column="1">
@@ -2018,6 +2023,33 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_cameraStereoImages_path">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QToolButton" name="toolButton_cameraStereoImages_path">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer_38">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2"> <item row="1" column="2">
<widget class="QLabel" name="label_248"> <widget class="QLabel" name="label_248">
<property name="text"> <property name="text">
@@ -2028,13 +2060,6 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_cameraStereoImages_path">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QLabel" name="label_249"> <widget class="QLabel" name="label_249">
<property name="text"> <property name="text">
@@ -2045,15 +2070,44 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item row="2" column="2">
<widget class="QToolButton" name="toolButton_cameraStereoImages_path"> <widget class="QLabel" name="label_250">
<property name="text"> <property name="text">
<string>...</string> <string>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.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1">
<widget class="QCheckBox" name="checkBox_stereoImages_rectify">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_50">
<layout class="QVBoxLayout" name="verticalLayout_78">
<item>
<widget class="QGroupBox" name="groupBox_cameraStereoImages_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Ignored">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Stereo side-by-side video (*.avi)</string>
</property>
<layout class="QGridLayout" name="gridLayout_66" columnstretch="0,0">
<item row="2" column="0"> <item row="2" column="0">
<spacer name="verticalSpacer_38"> <spacer name="verticalSpacer_39">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
@@ -2065,6 +2119,37 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="0">
<widget class="QToolButton" name="toolButton_cameraStereoVideo_path">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_cameraStereoVideo_path">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_stereoVideo_rectify">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_234">
<property name="text">
<string>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.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@@ -2157,6 +2242,33 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
<string>Images dataset</string> <string>Images dataset</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_7" columnstretch="0,1"> <layout class="QGridLayout" name="gridLayout_7" columnstretch="0,1">
<item row="0" column="1">
<widget class="QLineEdit" name="source_images_lineEdit_path">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_34">
<property name="text">
<string>Refresh the directory files list after each image loaded.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Start position (default 1, 0=start from the last).</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QCheckBox" name="source_images_refreshDir"> <widget class="QCheckBox" name="source_images_refreshDir">
<property name="text"> <property name="text">
@@ -2174,13 +2286,6 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QLineEdit" name="source_images_lineEdit_path">
<property name="readOnly">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QToolButton" name="source_images_toolButton_selectSource"> <widget class="QToolButton" name="source_images_toolButton_selectSource">
<property name="text"> <property name="text">
@@ -2188,17 +2293,20 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="3" column="1">
<widget class="QLabel" name="label_34"> <widget class="QLabel" name="label_242">
<property name="text"> <property name="text">
<string>Refresh the directory files list after each image loaded.</string> <string>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.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="3" column="0">
<widget class="QLabel" name="label_21"> <widget class="QCheckBox" name="checkBox_rgbImages_rectify">
<property name="text"> <property name="text">
<string>Start position (default 1, 0=start from the last).</string> <string/>
</property> </property>
</widget> </widget>
</item> </item>
@@ -2242,6 +2350,23 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QLabel" name="label_241">
<property name="text">
<string>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.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_rgbVideo_rectify">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>