GUI: Added new Freenect2 and StereoDC1394 source options.

This commit is contained in:
Mathieu Labbe
2015-04-06 00:28:04 -04:00
parent fee32c4e25
commit 04b35b2adf
22 changed files with 765 additions and 758 deletions

View File

@@ -80,26 +80,19 @@ class RTABMAP_EXP CameraRGBD
public: public:
virtual ~CameraRGBD(); virtual ~CameraRGBD();
void takeImage(cv::Mat & rgb, cv::Mat & depth, float & fx, float & fy, float & cx, float & cy); void takeImage(cv::Mat & rgb, cv::Mat & depth, float & fx, float & fy, float & cx, float & cy);
virtual bool init() = 0; virtual bool init(const std::string & calibrationFolder = ".") = 0;
virtual bool isCalibrated() const = 0;
virtual std::string getSerial() const = 0; virtual std::string getSerial() const = 0;
//getters //getters
float getImageRate() const {return _imageRate;} float getImageRate() const {return _imageRate;}
const Transform & getLocalTransform() const {return _localTransform;} const Transform & getLocalTransform() const {return _localTransform;}
bool isMirroringEnabled() const {return _mirroring;} bool isMirroringEnabled() const {return _mirroring;}
float getFx() const {return _fx;}
float getFy() const {return _fy;}
float getCx() const {return _cx;}
float getCy() const {return _cy;}
//setters //setters
void setImageRate(float imageRate) {_imageRate = imageRate;} void setImageRate(float imageRate) {_imageRate = imageRate;}
void setLocalTransform(const Transform & localTransform) {_localTransform= localTransform;} void setLocalTransform(const Transform & localTransform) {_localTransform= localTransform;}
void setMirroringEnabled(bool mirroring) {_mirroring = mirroring;} void setMirroringEnabled(bool mirroring) {_mirroring = mirroring;}
void setFx(float fx) {_fx = fx;}
void setFy(float fy) {_fy = fy;}
void setCx(float cx) {_cx = cx;}
void setCy(float cy) {_cy = cy;}
protected: protected:
/** /**
@@ -108,11 +101,7 @@ protected:
* @param imageRate : image/second , 0 for fast as the camera can * @param imageRate : image/second , 0 for fast as the camera can
*/ */
CameraRGBD(float imageRate = 0, CameraRGBD(float imageRate = 0,
const Transform & localTransform = Transform::getIdentity(), const Transform & localTransform = Transform::getIdentity());
float fx = 0.0f,
float fy = 0.0f,
float cx = 0.0f,
float cy = 0.0f);
/** /**
* returned rgb and depth images should be already rectified * returned rgb and depth images should be already rectified
@@ -124,10 +113,6 @@ private:
Transform _localTransform; Transform _localTransform;
bool _mirroring; bool _mirroring;
UTimer * _frameRateTimer; UTimer * _frameRateTimer;
float _fx;
float _fy;
float _cx;
float _cy;
}; };
///////////////////////// /////////////////////////
@@ -143,11 +128,7 @@ public:
// default local transform z in, x right, y down)); // default local transform z in, x right, y down));
CameraOpenni(const std::string & deviceId="", CameraOpenni(const std::string & deviceId="",
float imageRate = 0, float imageRate = 0,
const Transform & localTransform = Transform::getIdentity(), const Transform & localTransform = Transform::getIdentity());
float fx = 0.0f,
float fy = 0.0f,
float cx = 0.0f,
float cy = 0.0f);
virtual ~CameraOpenni(); virtual ~CameraOpenni();
void image_cb ( void image_cb (
@@ -155,7 +136,8 @@ public:
const boost::shared_ptr<openni_wrapper::DepthImage>& depth, const boost::shared_ptr<openni_wrapper::DepthImage>& depth,
float constant); float constant);
virtual bool init(); virtual bool init(const std::string & calibrationFolder = ".");
virtual bool isCalibrated() const;
virtual std::string getSerial() const; virtual std::string getSerial() const;
protected: protected:
@@ -185,14 +167,11 @@ public:
public: public:
CameraOpenNICV(bool asus = false, CameraOpenNICV(bool asus = false,
float imageRate = 0, float imageRate = 0,
const Transform & localTransform = Transform::getIdentity(), const Transform & localTransform = Transform::getIdentity());
float fx = 0.0f,
float fy = 0.0f,
float cx = 0.0f,
float cy = 0.0f);
virtual ~CameraOpenNICV(); virtual ~CameraOpenNICV();
virtual bool init(); virtual bool init(const std::string & calibrationFolder = ".");
virtual bool isCalibrated() const;
virtual std::string getSerial() const {return "";} // unknown with OpenCV virtual std::string getSerial() const {return "";} // unknown with OpenCV
protected: protected:
@@ -218,14 +197,11 @@ public:
public: public:
CameraOpenNI2(const std::string & deviceId = "", CameraOpenNI2(const std::string & deviceId = "",
float imageRate = 0, float imageRate = 0,
const Transform & localTransform = Transform::getIdentity(), const Transform & localTransform = Transform::getIdentity());
float fx = 0.0f,
float fy = 0.0f,
float cx = 0.0f,
float cy = 0.0f);
virtual ~CameraOpenNI2(); virtual ~CameraOpenNI2();
virtual bool init(); virtual bool init(const std::string & calibrationFolder = ".");
virtual bool isCalibrated() const;
virtual std::string getSerial() const; virtual std::string getSerial() const;
bool setAutoWhiteBalance(bool enabled); bool setAutoWhiteBalance(bool enabled);
@@ -262,14 +238,11 @@ public:
// default local transform z in, x right, y down)); // default local transform z in, x right, y down));
CameraFreenect(int deviceId= 0, CameraFreenect(int deviceId= 0,
float imageRate=0.0f, float imageRate=0.0f,
const Transform & localTransform = Transform::getIdentity(), const Transform & localTransform = Transform::getIdentity());
float fx = 0.0f,
float fy = 0.0f,
float cx = 0.0f,
float cy = 0.0f);
virtual ~CameraFreenect(); virtual ~CameraFreenect();
bool init(); bool init(const std::string & calibrationFolder = ".");
virtual bool isCalibrated() const;
virtual std::string getSerial() const; virtual std::string getSerial() const;
protected: protected:
@@ -295,14 +268,11 @@ public:
// default local transform z in, x right, y down)); // default local transform z in, x right, y down));
CameraFreenect2(int deviceId= 0, CameraFreenect2(int deviceId= 0,
float imageRate=0.0f, float imageRate=0.0f,
const Transform & localTransform = Transform::getIdentity(), const Transform & localTransform = Transform::getIdentity());
float fx = 0.0f,
float fy = 0.0f,
float cx = 0.0f,
float cy = 0.0f);
virtual ~CameraFreenect2(); virtual ~CameraFreenect2();
bool init(); bool init(const std::string & calibrationFolder = ".");
virtual bool isCalibrated() const;
virtual std::string getSerial() const; virtual std::string getSerial() const;
protected: protected:
@@ -320,39 +290,24 @@ private:
///////////////////////// /////////////////////////
class DC1394Device; class DC1394Device;
class RTABMAP_EXP CameraDC1394 : class RTABMAP_EXP CameraStereoDC1394 :
public CameraRGBD public CameraRGBD
{ {
public: public:
static bool available(); static bool available();
public: public:
// The first constructor will not check for calibration files, so CameraStereoDC1394( float imageRate=0.0f, const Transform & localTransform = Transform::getIdentity());
// the images returned won't be rectified virtual ~CameraStereoDC1394();
CameraDC1394( float imageRate=0.0f,
const Transform & localTransform = Transform::getIdentity(),
float fx = 0.0f,
float fy = 0.0f,
float cx = 0.0f,
float cy = 0.0f);
CameraDC1394(const std::string & calibrationFolder,
float imageRate=0.0f,
const Transform & localTransform = Transform::getIdentity(),
float fx = 0.0f,
float fy = 0.0f,
float cx = 0.0f,
float cy = 0.0f);
virtual ~CameraDC1394();
bool init(); bool init(const std::string & calibrationFolder = ".");
virtual bool isCalibrated() const;
virtual std::string getSerial() const; virtual std::string getSerial() const;
protected: protected:
virtual void captureImage(cv::Mat & left, cv::Mat & right, float & fx, float & baseline, float & cx, float & cy); virtual void captureImage(cv::Mat & left, cv::Mat & right, float & fx, float & baseline, float & cx, float & cy);
private: private:
bool lookForCalibration_;
std::string calibrationFolder_;
DC1394Device *device_; DC1394Device *device_;
StereoCameraModel stereoModel_; StereoCameraModel stereoModel_;
}; };

View File

@@ -66,15 +66,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace rtabmap namespace rtabmap
{ {
CameraRGBD::CameraRGBD(float imageRate, const Transform & localTransform, float fx, float fy, float cx, float cy) : CameraRGBD::CameraRGBD(float imageRate, const Transform & localTransform) :
_imageRate(imageRate), _imageRate(imageRate),
_localTransform(localTransform), _localTransform(localTransform),
_mirroring(false), _mirroring(false),
_frameRateTimer(new UTimer()), _frameRateTimer(new UTimer())
_fx(fx),
_fy(fy),
_cx(cx),
_cy(cy)
{ {
} }
@@ -110,22 +106,6 @@ void CameraRGBD::takeImage(cv::Mat & rgb, cv::Mat & depth, float & fx, float & f
UTimer timer; UTimer timer;
this->captureImage(rgb, depth, fx, fy, cx, cy); this->captureImage(rgb, depth, fx, fy, cx, cy);
if(_fx)
{
fx = _fx; // override if set
}
if(_fy)
{
fy = _fy; // override if set
}
if(_cx)
{
cx = _cx; // override if set
}
if(_cy)
{
cy = _cy; // override if set
}
if(!rgb.empty() && !depth.empty() && _mirroring) if(!rgb.empty() && !depth.empty() && _mirroring)
{ {
cv::flip(rgb,rgb,1); cv::flip(rgb,rgb,1);
@@ -141,8 +121,8 @@ void CameraRGBD::takeImage(cv::Mat & rgb, cv::Mat & depth, float & fx, float & f
///////////////////////// /////////////////////////
// CameraOpenNIPCL // CameraOpenNIPCL
///////////////////////// /////////////////////////
CameraOpenni::CameraOpenni(const std::string & deviceId, float imageRate, const Transform & localTransform, float fx, float fy, float cx, float cy) : CameraOpenni::CameraOpenni(const std::string & deviceId, float imageRate, const Transform & localTransform) :
CameraRGBD(imageRate, localTransform, fx, fy, cx, cy), CameraRGBD(imageRate, localTransform),
interface_(0), interface_(0),
deviceId_(deviceId), deviceId_(deviceId),
depthConstant_(0.0f) depthConstant_(0.0f)
@@ -190,7 +170,7 @@ void CameraOpenni::image_cb (
} }
} }
bool CameraOpenni::init() bool CameraOpenni::init(const std::string & calibrationFolder)
{ {
if(interface_) if(interface_)
{ {
@@ -225,6 +205,11 @@ bool CameraOpenni::init()
return true; return true;
} }
bool CameraOpenni::isCalibrated() const
{
return depthConstant_ > 0.0f;
}
std::string CameraOpenni::getSerial() const std::string CameraOpenni::getSerial() const
{ {
if(interface_) if(interface_)
@@ -266,8 +251,8 @@ bool CameraOpenNICV::available()
return cv::getBuildInformation().find("OpenNI: YES") != std::string::npos; return cv::getBuildInformation().find("OpenNI: YES") != std::string::npos;
} }
CameraOpenNICV::CameraOpenNICV(bool asus, float imageRate, const rtabmap::Transform & localTransform, float fx, float fy, float cx, float cy) : CameraOpenNICV::CameraOpenNICV(bool asus, float imageRate, const rtabmap::Transform & localTransform) :
CameraRGBD(imageRate, localTransform, fx, fy, cx, cy), CameraRGBD(imageRate, localTransform),
_asus(asus), _asus(asus),
_depthFocal(0.0f) _depthFocal(0.0f)
{ {
@@ -279,7 +264,7 @@ CameraOpenNICV::~CameraOpenNICV()
_capture.release(); _capture.release();
} }
bool CameraOpenNICV::init() bool CameraOpenNICV::init(const std::string & calibrationFolder)
{ {
if(_capture.isOpened()) if(_capture.isOpened())
{ {
@@ -328,6 +313,11 @@ bool CameraOpenNICV::init()
return true; return true;
} }
bool CameraOpenNICV::isCalibrated() const
{
return _depthFocal > 0.0f;
}
void CameraOpenNICV::captureImage(cv::Mat & rgb, cv::Mat & depth, float & fx, float & fy, float & cx, float & cy) void CameraOpenNICV::captureImage(cv::Mat & rgb, cv::Mat & depth, float & fx, float & fy, float & cx, float & cy)
{ {
if(_capture.isOpened()) if(_capture.isOpened())
@@ -375,12 +365,8 @@ bool CameraOpenNI2::exposureGainAvailable()
CameraOpenNI2::CameraOpenNI2( CameraOpenNI2::CameraOpenNI2(
const std::string & deviceId, const std::string & deviceId,
float imageRate, float imageRate,
const rtabmap::Transform & localTransform, const rtabmap::Transform & localTransform) :
float fx, CameraRGBD(imageRate, localTransform),
float fy,
float cx,
float cy) :
CameraRGBD(imageRate, localTransform, fx, fy, cx, cy),
#ifdef WITH_OPENNI2 #ifdef WITH_OPENNI2
_device(new openni::Device()), _device(new openni::Device()),
_color(new openni::VideoStream()), _color(new openni::VideoStream()),
@@ -484,7 +470,7 @@ bool CameraOpenNI2::setMirroring(bool enabled)
return false; return false;
} }
bool CameraOpenNI2::init() bool CameraOpenNI2::init(const std::string & calibrationFolder)
{ {
#ifdef WITH_OPENNI2 #ifdef WITH_OPENNI2
openni::OpenNI::initialize(); openni::OpenNI::initialize();
@@ -646,6 +632,11 @@ bool CameraOpenNI2::init()
#endif #endif
} }
bool CameraOpenNI2::isCalibrated() const
{
return _depthFx > 0.0f && _depthFy > 0.0f;
}
std::string CameraOpenNI2::getSerial() const std::string CameraOpenNI2::getSerial() const
{ {
if(_device) if(_device)
@@ -904,8 +895,8 @@ bool CameraFreenect::available()
#endif #endif
} }
CameraFreenect::CameraFreenect(int deviceId, float imageRate, const Transform & localTransform, float fx, float fy, float cx, float cy) : CameraFreenect::CameraFreenect(int deviceId, float imageRate, const Transform & localTransform) :
CameraRGBD(imageRate, localTransform, fx, fy, cx, cy), CameraRGBD(imageRate, localTransform),
deviceId_(deviceId), deviceId_(deviceId),
ctx_(0), ctx_(0),
freenectDevice_(0) freenectDevice_(0)
@@ -933,7 +924,7 @@ CameraFreenect::~CameraFreenect()
#endif #endif
} }
bool CameraFreenect::init() bool CameraFreenect::init(const std::string & calibrationFolder)
{ {
#ifdef WITH_FREENECT #ifdef WITH_FREENECT
if(freenectDevice_) if(freenectDevice_)
@@ -969,6 +960,11 @@ bool CameraFreenect::init()
return false; return false;
} }
bool CameraFreenect::isCalibrated() const
{
return freenectDevice_ != 0 && freenectDevice_->getDepthFocal() > 0.0f;
}
std::string CameraFreenect::getSerial() const std::string CameraFreenect::getSerial() const
{ {
#ifdef WITH_FREENECT #ifdef WITH_FREENECT
@@ -1032,8 +1028,8 @@ bool CameraFreenect2::available()
#endif #endif
} }
CameraFreenect2::CameraFreenect2(int deviceId, float imageRate, const Transform & localTransform, float fx, float fy, float cx, float cy) : CameraFreenect2::CameraFreenect2(int deviceId, float imageRate, const Transform & localTransform) :
CameraRGBD(imageRate, localTransform, fx, fy, cx, cy), CameraRGBD(imageRate, localTransform),
deviceId_(deviceId), deviceId_(deviceId),
freenect2_(0), freenect2_(0),
dev_(0) dev_(0)
@@ -1065,7 +1061,7 @@ CameraFreenect2::~CameraFreenect2()
#endif #endif
} }
bool CameraFreenect2::init() bool CameraFreenect2::init(const std::string & calibrationFolder)
{ {
#ifdef WITH_FREENECT2 #ifdef WITH_FREENECT2
if(dev_) if(dev_)
@@ -1103,6 +1099,12 @@ bool CameraFreenect2::init()
return false; return false;
} }
bool CameraFreenect2::isCalibrated() const
{
UWARN("Freenect2 calibration not yet implemented!");
return false;
}
std::string CameraFreenect2::getSerial() const std::string CameraFreenect2::getSerial() const
{ {
#ifdef WITH_FREENECT2 #ifdef WITH_FREENECT2
@@ -1440,7 +1442,7 @@ private:
}; };
#endif #endif
bool CameraDC1394::available() bool CameraStereoDC1394::available()
{ {
#ifdef WITH_DC1394 #ifdef WITH_DC1394
return true; return true;
@@ -1449,9 +1451,8 @@ bool CameraDC1394::available()
#endif #endif
} }
CameraDC1394::CameraDC1394(float imageRate, const Transform & localTransform, float fx, float fy, float cx, float cy) : CameraStereoDC1394::CameraStereoDC1394(float imageRate, const Transform & localTransform) :
CameraRGBD(imageRate, localTransform, fx, fy, cx, cy), CameraRGBD(imageRate, localTransform),
lookForCalibration_(false),
device_(0) device_(0)
{ {
#ifdef WITH_DC1394 #ifdef WITH_DC1394
@@ -1459,18 +1460,7 @@ CameraDC1394::CameraDC1394(float imageRate, const Transform & localTransform, fl
#endif #endif
} }
CameraDC1394::CameraDC1394(const std::string & calibrationFolder, float imageRate, const Transform & localTransform, float fx, float fy, float cx, float cy) : CameraStereoDC1394::~CameraStereoDC1394()
CameraRGBD(imageRate, localTransform, fx, fy, cx, cy),
lookForCalibration_(true),
calibrationFolder_(calibrationFolder),
device_(0)
{
#ifdef WITH_DC1394
device_ = new DC1394Device();
#endif
}
CameraDC1394::~CameraDC1394()
{ {
#ifdef WITH_DC1394 #ifdef WITH_DC1394
if(device_) if(device_)
@@ -1480,7 +1470,7 @@ CameraDC1394::~CameraDC1394()
#endif #endif
} }
bool CameraDC1394::init() bool CameraStereoDC1394::init(const std::string & calibrationFolder)
{ {
#ifdef WITH_DC1394 #ifdef WITH_DC1394
if(device_) if(device_)
@@ -1489,11 +1479,12 @@ bool CameraDC1394::init()
if(ok) if(ok)
{ {
// look for calibration files // look for calibration files
if(lookForCalibration_) if(!calibrationFolder.empty())
{ {
if(!stereoModel_.load(calibrationFolder_, device_->guid())) if(!stereoModel_.load(calibrationFolder, device_->guid()))
{ {
UWARN("Missing calibration files for camera \"%s\" in \"%s\" folder, you should calibrate the camera!", device_->guid().c_str(), calibrationFolder_.c_str()); UWARN("Missing calibration files for camera \"%s\" in \"%s\" folder, you should calibrate the camera!",
device_->guid().c_str(), calibrationFolder.c_str());
} }
} }
} }
@@ -1505,7 +1496,12 @@ bool CameraDC1394::init()
return false; return false;
} }
std::string CameraDC1394::getSerial() const bool CameraStereoDC1394::isCalibrated() const
{
return stereoModel_.isValid();
}
std::string CameraStereoDC1394::getSerial() const
{ {
#ifdef WITH_DC1394 #ifdef WITH_DC1394
if(device_) if(device_)
@@ -1516,7 +1512,7 @@ std::string CameraDC1394::getSerial() const
return ""; return "";
} }
void CameraDC1394::captureImage(cv::Mat & left, cv::Mat & right, float & fx, float & baseline, float & cx, float & cy) void CameraStereoDC1394::captureImage(cv::Mat & left, cv::Mat & right, float & fx, float & baseline, float & cx, float & cy)
{ {
#ifdef WITH_DC1394 #ifdef WITH_DC1394
left = cv::Mat(); left = cv::Mat();

View File

@@ -867,10 +867,22 @@ bool Rtabmap::process(const SensorData & data)
// Memory Update : Location creation + Add to STM + Weight Update (Rehearsal) // Memory Update : Location creation + Add to STM + Weight Update (Rehearsal)
//============================================================ //============================================================
ULOGGER_INFO("Updating memory..."); ULOGGER_INFO("Updating memory...");
if(!_memory->update(data, &statistics_)) if(_rgbdSlamMode)
{ {
return false; if(!_memory->update(data, &statistics_))
{
return false;
}
} }
else
{
SensorData dataImageOnly(data.image(), data.id(), data.stamp(), data.userData());
if(!_memory->update(dataImageOnly, &statistics_))
{
return false;
}
}
signature = _memory->getLastWorkingSignature(); signature = _memory->getLastWorkingSignature();
if(!signature) if(!signature)

View File

@@ -31,6 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "rtabmap/gui/RtabmapGuiExp.h" // DLL export/import defines #include "rtabmap/gui/RtabmapGuiExp.h" // DLL export/import defines
#include <QDialog> #include <QDialog>
#include <QSettings>
#include <opencv2/opencv.hpp> #include <opencv2/opencv.hpp>
#include <rtabmap/core/CameraModel.h> #include <rtabmap/core/CameraModel.h>
@@ -46,16 +47,18 @@ class RTABMAPGUI_EXP CalibrationDialog : public QDialog, public UEventsHandler
Q_OBJECT; Q_OBJECT;
public: public:
CalibrationDialog(bool stereo = false, QWidget * parent = 0); CalibrationDialog(bool stereo = false, const QString & savingDirectory = ".", QWidget * parent = 0);
virtual ~CalibrationDialog(); virtual ~CalibrationDialog();
bool isCalibrated() const {return calibrated_;} bool isCalibrated() const {return calibrated_;}
const cv::Mat & cameraMatrix() const {return model_.K();} // Matrix K const rtabmap::CameraModel & getCameraModel() const {return model_;}
const cv::Mat & distCoeffs() const {return model_.D();} // Matrix D const rtabmap::StereoCameraModel & getStereoCameraModel() const {return stereoModel_;}
float fx() const {return model_.fx();} // K(0)
float fy() const {return model_.fy();} // K(4) void saveSettings(QSettings & settings, const QString & group = "") const;
float cx() const {return model_.cx();} // K(2) void loadSettings(QSettings & settings, const QString & group = "");
float cy() const {return model_.cy();} // K(5)
void setStereoMode(bool stereo);
void setSavingDirectory(const QString & savingDirectory) {savingDirectory_ = savingDirectory;}
public slots: public slots:
void setBoardWidth(int width); void setBoardWidth(int width);
@@ -66,7 +69,7 @@ private slots:
void processImages(const cv::Mat & imageLeft, const cv::Mat & imageRight, const QString & cameraName); void processImages(const cv::Mat & imageLeft, const cv::Mat & imageRight, const QString & cameraName);
void restart(); void restart();
void calibrate(); void calibrate();
void save(); bool save();
protected: protected:
virtual void closeEvent(QCloseEvent* event); virtual void closeEvent(QCloseEvent* event);
@@ -85,13 +88,13 @@ private:
private: private:
// parameters // parameters
cv::Size boardSize_; // innner squares
float squareSize_; // m
bool stereo_; bool stereo_;
QString savingDirectory_;
QString cameraName_; QString cameraName_;
bool calibrated_; bool calibrated_;
bool processingData_; bool processingData_;
bool savedCalibration_;
std::vector<std::vector<std::vector<cv::Point2f> > > imagePoints_; std::vector<std::vector<std::vector<cv::Point2f> > > imagePoints_;
std::vector<std::vector<std::vector<float> > > imageParams_; std::vector<std::vector<std::vector<float> > > imageParams_;

View File

@@ -0,0 +1,61 @@
/*
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.
*/
#ifndef CAMERAVIEWER_H_
#define CAMERAVIEWER_H_
#include "rtabmap/gui/RtabmapGuiExp.h" // DLL export/import defines
#include <rtabmap/utilite/UEventsHandler.h>
#include <QWidget>
#include <rtabmap/core/SensorData.h>
namespace rtabmap {
class ImageView;
class CloudViewer;
class RTABMAPGUI_EXP CameraViewer : public QWidget, public UEventsHandler
{
Q_OBJECT
public:
CameraViewer(QWidget * parent = 0);
virtual ~CameraViewer();
public slots:
void showImage(const rtabmap::SensorData & data);
protected:
void handleEvent(UEvent * event);
private:
ImageView* imageView_;
CloudViewer* cloudView_;
bool processingImages_;
};
} /* namespace rtabmap */
#endif /* CAMERAVIEWER_H_ */

View File

@@ -148,6 +148,8 @@ private slots:
void selectOpenniCv(); void selectOpenniCv();
void selectOpenniCvAsus(); void selectOpenniCvAsus();
void selectOpenni2(); void selectOpenni2();
void selectFreenect2();
void selectStereoDC1394();
void dumpTheMemory(); void dumpTheMemory();
void dumpThePrediction(); void dumpThePrediction();
void downloadAllClouds(); void downloadAllClouds();

View File

@@ -61,6 +61,8 @@ class OdometryThread;
class CameraThread; class CameraThread;
class Signature; class Signature;
class LoopClosureViewer; class LoopClosureViewer;
class CameraRGBD;
class CalibrationDialog;
class RTABMAPGUI_EXP PreferencesDialog : public QDialog class RTABMAPGUI_EXP PreferencesDialog : public QDialog
{ {
@@ -87,7 +89,9 @@ public:
kSrcFreenect, kSrcFreenect,
kSrcOpenNI_CV, kSrcOpenNI_CV,
kSrcOpenNI_CV_ASUS, kSrcOpenNI_CV_ASUS,
kSrcOpenNI2 kSrcOpenNI2,
kSrcFreenect2,
kSrcStereoDC1394
}; };
public: public:
@@ -159,7 +163,7 @@ public:
bool isSourceMirroring() const; bool isSourceMirroring() const;
bool isSourceImageUsed() const; bool isSourceImageUsed() const;
bool isSourceDatabaseUsed() const; bool isSourceDatabaseUsed() const;
bool isSourceOpenniUsed() const; bool isSourceRGBDUsed() const;
PreferencesDialog::Src getSourceImageType() const; PreferencesDialog::Src getSourceImageType() const;
QString getSourceImageTypeStr() const; QString getSourceImageTypeStr() const;
int getSourceWidth() const; int getSourceWidth() const;
@@ -182,10 +186,7 @@ public:
bool getSourceOpenni2Mirroring() const; //Openni group bool getSourceOpenni2Mirroring() const; //Openni group
QString getSourceOpenniDevice() const; //Openni group QString getSourceOpenniDevice() const; //Openni group
Transform getSourceOpenniLocalTransform() const; //Openni group Transform getSourceOpenniLocalTransform() const; //Openni group
float getSourceOpenniFx() const; // Openni group CameraRGBD * createCameraRGBD() const; // return camera should be deleted if not null
float getSourceOpenniFy() const; // Openni group
float getSourceOpenniCx() const; // Openni group
float getSourceOpenniCy() const; // Openni group
int getIgnoredDCComponents() const; int getIgnoredDCComponents() const;
@@ -200,6 +201,7 @@ public:
double getLoopThr() const; double getLoopThr() const;
double getVpThr() const; double getVpThr() const;
int getOdomStrategy() const; int getOdomStrategy() const;
QString getCameraInfoDir() const; // "workinfDir/camera_info"
// //
void setMonitoringState(bool monitoringState) {_monitoringState = monitoringState;} void setMonitoringState(bool monitoringState) {_monitoringState = monitoringState;}
@@ -216,6 +218,7 @@ public slots:
void selectSourceImage(Src src = kSrcUndef); void selectSourceImage(Src src = kSrcUndef);
void selectSourceDatabase(bool user = false); void selectSourceDatabase(bool user = false);
void selectSourceRGBD(Src src = kSrcUndef); void selectSourceRGBD(Src src = kSrcUndef);
void calibrate();
private slots: private slots:
void closeDialog ( QAbstractButton * button ); void closeDialog ( QAbstractButton * button );
@@ -246,8 +249,6 @@ private slots:
void testOdometry(); void testOdometry();
void cleanRGBDCameraTest(); void cleanRGBDCameraTest();
void testRGBDCamera(); void testRGBDCamera();
void calibrate();
void resetCalibration();
protected: protected:
virtual void showEvent ( QShowEvent * event ); virtual void showEvent ( QShowEvent * event );
@@ -302,6 +303,9 @@ private:
CameraThread * _cameraThread; CameraThread * _cameraThread;
OdometryThread * _odomThread; OdometryThread * _odomThread;
//calibration
CalibrationDialog * _calibrationDialog;
QVector<QCheckBox*> _3dRenderingShowClouds; QVector<QCheckBox*> _3dRenderingShowClouds;
QVector<QDoubleSpinBox*> _3dRenderingVoxelSize; QVector<QDoubleSpinBox*> _3dRenderingVoxelSize;
QVector<QSpinBox*> _3dRenderingDecimation; QVector<QSpinBox*> _3dRenderingDecimation;

View File

@@ -17,6 +17,7 @@ SET(headers_ui
../include/${PROJECT_PREFIX}/gui/OdometryViewer.h ../include/${PROJECT_PREFIX}/gui/OdometryViewer.h
../include/${PROJECT_PREFIX}/gui/LoopClosureViewer.h ../include/${PROJECT_PREFIX}/gui/LoopClosureViewer.h
../include/${PROJECT_PREFIX}/gui/DataRecorder.h ../include/${PROJECT_PREFIX}/gui/DataRecorder.h
../include/${PROJECT_PREFIX}/gui/CameraViewer.h
../include/${PROJECT_PREFIX}/gui/CalibrationDialog.h ../include/${PROJECT_PREFIX}/gui/CalibrationDialog.h
./ExportDialog.h ./ExportDialog.h
./PostProcessingDialog.h ./PostProcessingDialog.h
@@ -75,6 +76,7 @@ SET(SRC_FILES
./OdometryViewer.cpp ./OdometryViewer.cpp
./LoopClosureViewer.cpp ./LoopClosureViewer.cpp
./DataRecorder.cpp ./DataRecorder.cpp
./CameraViewer.cpp
./CalibrationDialog.cpp ./CalibrationDialog.cpp
./ExportDialog.cpp ./ExportDialog.cpp
./PostProcessingDialog.cpp ./PostProcessingDialog.cpp

View File

@@ -35,6 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QCloseEvent>
#include <rtabmap/core/CameraEvent.h> #include <rtabmap/core/CameraEvent.h>
#include <rtabmap/gui/UCv2Qt.h> #include <rtabmap/gui/UCv2Qt.h>
@@ -47,13 +48,13 @@ namespace rtabmap {
#define COUNT_MIN 40 #define COUNT_MIN 40
CalibrationDialog::CalibrationDialog(bool stereo, QWidget * parent) : CalibrationDialog::CalibrationDialog(bool stereo, const QString & savingDirectory, QWidget * parent) :
QDialog(parent), QDialog(parent),
boardSize_(8,6),
squareSize_(0.033),
stereo_(stereo), stereo_(stereo),
savingDirectory_(savingDirectory),
calibrated_(false), calibrated_(false),
processingData_(false) processingData_(false),
savedCalibration_(false)
{ {
imagePoints_.resize(2); imagePoints_.resize(2);
imageParams_.resize(2); imageParams_.resize(2);
@@ -64,25 +65,6 @@ CalibrationDialog::CalibrationDialog(bool stereo, QWidget * parent) :
ui_ = new Ui_calibrationDialog(); ui_ = new Ui_calibrationDialog();
ui_->setupUi(this); ui_->setupUi(this);
if(!stereo_)
{
ui_->progressBar_x_2->setVisible(false);
ui_->progressBar_y_2->setVisible(false);
ui_->progressBar_size_2->setVisible(false);
ui_->progressBar_skew_2->setVisible(false);
ui_->image_view_2->setVisible(false);
ui_->label_fx_2->setVisible(false);
ui_->label_fy_2->setVisible(false);
ui_->label_cx_2->setVisible(false);
ui_->label_cy_2->setVisible(false);
ui_->label_baseline->setVisible(false);
ui_->label_baseline_name->setVisible(false);
ui_->lineEdit_K_2->setVisible(false);
ui_->lineEdit_D_2->setVisible(false);
ui_->lineEdit_R_2->setVisible(false);
ui_->lineEdit_P_2->setVisible(false);
}
connect(ui_->pushButton_calibrate, SIGNAL(clicked()), this, SLOT(calibrate())); connect(ui_->pushButton_calibrate, SIGNAL(clicked()), this, SLOT(calibrate()));
connect(ui_->pushButton_restart, SIGNAL(clicked()), this, SLOT(restart())); connect(ui_->pushButton_restart, SIGNAL(clicked()), this, SLOT(restart()));
connect(ui_->pushButton_save, SIGNAL(clicked()), this, SLOT(save())); connect(ui_->pushButton_save, SIGNAL(clicked()), this, SLOT(save()));
@@ -91,15 +73,14 @@ CalibrationDialog::CalibrationDialog(bool stereo, QWidget * parent) :
connect(ui_->spinBox_boardHeight, SIGNAL(valueChanged(int)), this, SLOT(setBoardHeight(int))); connect(ui_->spinBox_boardHeight, SIGNAL(valueChanged(int)), this, SLOT(setBoardHeight(int)));
connect(ui_->doubleSpinBox_squareSize, SIGNAL(valueChanged(double)), this, SLOT(setSquareSize(double))); connect(ui_->doubleSpinBox_squareSize, SIGNAL(valueChanged(double)), this, SLOT(setSquareSize(double)));
connect(ui_->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); connect(ui_->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
connect(ui_->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
ui_->image_view->setFocus(); ui_->image_view->setFocus();
ui_->progressBar_count->setMaximum(COUNT_MIN); ui_->progressBar_count->setMaximum(COUNT_MIN);
ui_->progressBar_count->setFormat("%v"); ui_->progressBar_count->setFormat("%v");
this->restart(); this->setStereoMode(stereo_);
} }
CalibrationDialog::~CalibrationDialog() CalibrationDialog::~CalibrationDialog()
@@ -108,36 +89,120 @@ CalibrationDialog::~CalibrationDialog()
delete ui_; delete ui_;
} }
void CalibrationDialog::saveSettings(QSettings & settings, const QString & group) const
{
if(!group.isEmpty())
{
settings.beginGroup(group);
}
settings.setValue("board_width", ui_->spinBox_boardWidth->value());
settings.setValue("board_height", ui_->spinBox_boardHeight->value());
settings.setValue("board_square_size", ui_->doubleSpinBox_squareSize->value());
settings.setValue("geometry", this->saveGeometry());
if(!group.isEmpty())
{
settings.endGroup();
}
}
void CalibrationDialog::loadSettings(QSettings & settings, const QString & group)
{
if(!group.isEmpty())
{
settings.beginGroup(group);
}
this->setBoardWidth(settings.value("board_width", ui_->spinBox_boardWidth->value()).toInt());
this->setBoardHeight(settings.value("board_height", ui_->spinBox_boardHeight->value()).toInt());
this->setSquareSize(settings.value("board_square_size", ui_->doubleSpinBox_squareSize->value()).toDouble());
QByteArray bytes = settings.value("geometry", QByteArray()).toByteArray();
if(!bytes.isEmpty())
{
this->restoreGeometry(bytes);
}
if(!group.isEmpty())
{
settings.endGroup();
}
}
void CalibrationDialog::setStereoMode(bool stereo)
{
this->restart();
stereo_ = stereo;
ui_->progressBar_x_2->setVisible(stereo_);
ui_->progressBar_y_2->setVisible(stereo_);
ui_->progressBar_size_2->setVisible(stereo_);
ui_->progressBar_skew_2->setVisible(stereo_);
ui_->image_view_2->setVisible(stereo_);
ui_->label_fx_2->setVisible(stereo_);
ui_->label_fy_2->setVisible(stereo_);
ui_->label_cx_2->setVisible(stereo_);
ui_->label_cy_2->setVisible(stereo_);
ui_->label_baseline->setVisible(stereo_);
ui_->label_baseline_name->setVisible(stereo_);
ui_->lineEdit_K_2->setVisible(stereo_);
ui_->lineEdit_D_2->setVisible(stereo_);
ui_->lineEdit_R_2->setVisible(stereo_);
ui_->lineEdit_P_2->setVisible(stereo_);
}
void CalibrationDialog::setBoardWidth(int width) void CalibrationDialog::setBoardWidth(int width)
{ {
if(width != boardSize_.width) if(width != ui_->spinBox_boardWidth->value())
{ {
boardSize_.width = width; ui_->spinBox_boardWidth->setValue(width);
this->restart(); this->restart();
} }
} }
void CalibrationDialog::setBoardHeight(int height) void CalibrationDialog::setBoardHeight(int height)
{ {
if(height != boardSize_.height) if(height != ui_->spinBox_boardHeight->value())
{ {
boardSize_.height = height; ui_->spinBox_boardHeight->setValue(height);
this->restart(); this->restart();
} }
} }
void CalibrationDialog::setSquareSize(double size) void CalibrationDialog::setSquareSize(double size)
{ {
if(size != squareSize_) if(size != ui_->doubleSpinBox_squareSize->value())
{ {
squareSize_ = size; ui_->doubleSpinBox_squareSize->setValue(size);
this->restart(); this->restart();
} }
} }
void CalibrationDialog::closeEvent(QCloseEvent* event) void CalibrationDialog::closeEvent(QCloseEvent* event)
{ {
this->unregisterFromEventsManager(); if(!savedCalibration_ && calibrated_)
{
QMessageBox::StandardButton b = QMessageBox::question(this, tr("Save calibration?"),
tr("The camera is calibrated but you didn't "
"save the calibration, do you want to save it?"),
QMessageBox::Yes | QMessageBox::Ignore | QMessageBox::Cancel, QMessageBox::Yes);
event->ignore();
if(b == QMessageBox::Yes)
{
if(this->save())
{
event->accept();
}
}
else if(b == QMessageBox::Ignore)
{
event->accept();
}
}
else
{
event->accept();
}
if(event->isAccepted())
{
this->unregisterFromEventsManager();
}
} }
void CalibrationDialog::handleEvent(UEvent * event) void CalibrationDialog::handleEvent(UEvent * event)
@@ -207,6 +272,7 @@ void CalibrationDialog::processImages(const cv::Mat & imageLeft, const cv::Mat &
} }
bool found = false; bool found = false;
cv::Size boardSize(ui_->spinBox_boardWidth->value(), ui_->spinBox_boardHeight->value());
if(!viewGray.empty()) if(!viewGray.empty())
{ {
int maxScale = 1; int maxScale = 1;
@@ -217,7 +283,7 @@ void CalibrationDialog::processImages(const cv::Mat & imageLeft, const cv::Mat &
timg = viewGray; timg = viewGray;
else else
cv::resize(viewGray, timg, cv::Size(), scale, scale); cv::resize(viewGray, timg, cv::Size(), scale, scale);
found = cv::findChessboardCorners(timg, boardSize_, pointBuf[id], found = cv::findChessboardCorners(timg, boardSize, pointBuf[id],
CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_NORMALIZE_IMAGE); CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_NORMALIZE_IMAGE);
if(found) if(found)
{ {
@@ -248,10 +314,10 @@ void CalibrationDialog::processImages(const cv::Mat & imageLeft, const cv::Mat &
cv::TermCriteria( CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1 )); cv::TermCriteria( CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1 ));
boardAccepted[id] = true; boardAccepted[id] = true;
getParams(pointBuf[id], boardSize_, imageSize_[id], params[id][0], params[id][1], params[id][2], params[id][3]); getParams(pointBuf[id], boardSize, imageSize_[id], params[id][0], params[id][1], params[id][2], params[id][3]);
// Draw the corners. // Draw the corners.
cv::drawChessboardCorners(images[id], boardSize_, cv::Mat(pointBuf[id]), found); cv::drawChessboardCorners(images[id], boardSize, cv::Mat(pointBuf[id]), found);
} }
} }
@@ -392,6 +458,7 @@ void CalibrationDialog::restart()
{ {
// restart // restart
calibrated_ = false; calibrated_ = false;
savedCalibration_ = false;
imagePoints_[0].clear(); imagePoints_[0].clear();
imagePoints_[1].clear(); imagePoints_[1].clear();
imageParams_[0].clear(); imageParams_[0].clear();
@@ -402,7 +469,6 @@ void CalibrationDialog::restart()
ui_->pushButton_calibrate->setEnabled(false); ui_->pushButton_calibrate->setEnabled(false);
ui_->pushButton_save->setEnabled(false); ui_->pushButton_save->setEnabled(false);
ui_->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
ui_->checkBox_rectified->setEnabled(false); ui_->checkBox_rectified->setEnabled(false);
ui_->progressBar_count->reset(); ui_->progressBar_count->reset();
@@ -442,11 +508,23 @@ void CalibrationDialog::calibrate()
{ {
UINFO("Calibration..."); UINFO("Calibration...");
processingData_ = true; processingData_ = true;
savedCalibration_ = false;
QMessageBox mb(QMessageBox::Information,
tr("Calibrating..."),
tr("Operation in progress. You have time to take a coffee!"));
mb.show();
QApplication::processEvents();
uSleep(100); // hack make sure the text in the QMessageBox is shown...
QApplication::processEvents();
std::vector<std::vector<cv::Point3f> > objectPoints(1); std::vector<std::vector<cv::Point3f> > objectPoints(1);
cv::Size boardSize(ui_->spinBox_boardWidth->value(), ui_->spinBox_boardHeight->value());
float squareSize = ui_->doubleSpinBox_squareSize->value();
// compute board corner positions // compute board corner positions
for( int i = 0; i < boardSize_.height; ++i ) for( int i = 0; i < boardSize.height; ++i )
for( int j = 0; j < boardSize_.width; ++j ) for( int j = 0; j < boardSize.width; ++j )
objectPoints[0].push_back(cv::Point3f(float( j*squareSize_ ), float( i*squareSize_ ), 0)); objectPoints[0].push_back(cv::Point3f(float( j*squareSize ), float( i*squareSize ), 0));
objectPoints.resize(imagePoints_[0].size(),objectPoints[0]); objectPoints.resize(imagePoints_[0].size(),objectPoints[0]);
@@ -523,7 +601,6 @@ void CalibrationDialog::calibrate()
ui_->checkBox_rectified->setEnabled(true); ui_->checkBox_rectified->setEnabled(true);
ui_->checkBox_rectified->setChecked(true); ui_->checkBox_rectified->setChecked(true);
ui_->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
ui_->pushButton_save->setEnabled(true); ui_->pushButton_save->setEnabled(true);
} }
} }
@@ -631,24 +708,23 @@ void CalibrationDialog::calibrate()
ui_->checkBox_rectified->setEnabled(true); ui_->checkBox_rectified->setEnabled(true);
ui_->checkBox_rectified->setChecked(true); ui_->checkBox_rectified->setChecked(true);
ui_->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
ui_->pushButton_save->setEnabled(true); ui_->pushButton_save->setEnabled(true);
} }
} }
UINFO("End calibration"); UINFO("End calibration");
processingData_ = false; processingData_ = false;
} }
void CalibrationDialog::save() bool CalibrationDialog::save()
{ {
bool saved = false;
processingData_ = true; processingData_ = true;
if(!stereo_) if(!stereo_)
{ {
UASSERT(model_.isValid()); UASSERT(model_.isValid());
QString cameraName = model_.name().c_str(); QString cameraName = model_.name().c_str();
QString filePath = QFileDialog::getSaveFileName(this, tr("Export"), cameraName+".yaml", "*.yaml"); QString filePath = QFileDialog::getSaveFileName(this, tr("Export"), savingDirectory_+"/"+cameraName+".yaml", "*.yaml");
if(!filePath.isEmpty()) if(!filePath.isEmpty())
{ {
@@ -656,6 +732,8 @@ void CalibrationDialog::save()
{ {
QMessageBox::information(this, tr("Export"), tr("Calibration file saved to \"%1\".").arg(filePath)); QMessageBox::information(this, tr("Export"), tr("Calibration file saved to \"%1\".").arg(filePath));
UINFO("Saved \"%s\"!", filePath.toStdString().c_str()); UINFO("Saved \"%s\"!", filePath.toStdString().c_str());
savedCalibration_ = true;
saved = true;
} }
else else
{ {
@@ -667,7 +745,7 @@ void CalibrationDialog::save()
{ {
UASSERT(stereoModel_.isValid()); UASSERT(stereoModel_.isValid());
QString cameraName = stereoModel_.name().c_str(); QString cameraName = stereoModel_.name().c_str();
QString filePath = QFileDialog::getSaveFileName(this, tr("Export"), cameraName, "*.yaml"); QString filePath = QFileDialog::getSaveFileName(this, tr("Export"), savingDirectory_ + "/" + cameraName, "*.yaml");
std::string name = UFile::getName(filePath.toStdString()); std::string name = UFile::getName(filePath.toStdString());
std::string dir = UDirectory::getDir(filePath.toStdString()); std::string dir = UDirectory::getDir(filePath.toStdString());
if(!name.empty()) if(!name.empty())
@@ -680,6 +758,8 @@ void CalibrationDialog::save()
QMessageBox::information(this, tr("Export"), tr("Calibration files saved to \"%1\" and \"%2\"."). QMessageBox::information(this, tr("Export"), tr("Calibration files saved to \"%1\" and \"%2\".").
arg(leftPath.c_str()).arg(rightPath.c_str())); arg(leftPath.c_str()).arg(rightPath.c_str()));
UINFO("Saved \"%s\" and \"%s\"!", leftPath.c_str(), rightPath.c_str()); UINFO("Saved \"%s\" and \"%s\"!", leftPath.c_str(), rightPath.c_str());
savedCalibration_ = true;
saved = true;
} }
else else
{ {
@@ -688,6 +768,7 @@ void CalibrationDialog::save()
} }
} }
processingData_ = false; processingData_ = false;
return saved;
} }
float CalibrationDialog::getArea(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize) float CalibrationDialog::getArea(const std::vector<cv::Point2f> & corners, const cv::Size & boardSize)

111
guilib/src/CameraViewer.cpp Normal file
View File

@@ -0,0 +1,111 @@
/*
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/CameraViewer.h"
#include <rtabmap/core/CameraEvent.h>
#include <rtabmap/core/util3d.h>
#include <rtabmap/gui/ImageView.h>
#include <rtabmap/gui/CloudViewer.h>
#include <rtabmap/gui/UCv2Qt.h>
#include <QtCore/QMetaType>
#include <QHBoxLayout>
namespace rtabmap {
CameraViewer::CameraViewer(QWidget * parent) :
QWidget(parent),
imageView_(new ImageView(this)),
cloudView_(new CloudViewer(this)),
processingImages_(false)
{
qRegisterMetaType<rtabmap::SensorData>("rtabmap::SensorData");
imageView_->setImageDepthShown(true);
imageView_->setMinimumSize(320, 240);
QHBoxLayout * layout = new QHBoxLayout(this);
layout->setMargin(0);
layout->addWidget(imageView_);
layout->addWidget(cloudView_);
layout->setStretch(0, 1);
layout->setStretch(1, 1);
this->setLayout(layout);
}
CameraViewer::~CameraViewer()
{
this->unregisterFromEventsManager();
}
void CameraViewer::showImage(const rtabmap::SensorData & data)
{
processingImages_ = true;
imageView_->setImage(uCvMat2QImage(data.image()));
imageView_->setImageDepth(uCvMat2QImage(data.depthOrRightImage()));
if(!data.depth().empty() && data.fx() && data.fy())
{
cloudView_->addOrUpdateCloud("cloud",
util3d::cloudFromDepthRGB(data.image(), data.depth(), data.cx(), data.cy(), data.fx(), data.fy()),
data.localTransform());
}
else if(!data.rightImage().empty() && data.fx() && data.baseline())
{
cloudView_->addOrUpdateCloud("cloud",
util3d::cloudFromStereoImages(data.image(), data.rightImage(), data.cx(), data.cy(), data.fx(), data.baseline()),
data.localTransform());
}
else
{
cloudView_->setVisible(false);
}
cloudView_->update();
processingImages_ = false;
}
void CameraViewer::handleEvent(UEvent * event)
{
if(event->getClassName().compare("CameraEvent") == 0)
{
CameraEvent * camEvent = (CameraEvent*)event;
if(camEvent->getCode() == CameraEvent::kCodeImageDepth ||
camEvent->getCode() == CameraEvent::kCodeImage)
{
if(camEvent->data().isValid())
{
if(!processingImages_ && this->isVisible() && camEvent->data().isValid())
{
processingImages_ = true;
QMetaObject::invokeMethod(this, "showImage",
Q_ARG(rtabmap::SensorData, camEvent->data()));
}
}
}
}
}
} /* namespace rtabmap */

View File

@@ -193,7 +193,7 @@ void CloudViewer::saveSettings(QSettings & settings, const QString & group) cons
settings.setValue("grid", this->isGridShown()); settings.setValue("grid", this->isGridShown());
settings.setValue("grid_cell_count", this->getGridCellCount()); settings.setValue("grid_cell_count", this->getGridCellCount());
settings.setValue("grid_cell_size", this->getGridCellSize()); settings.setValue("grid_cell_size", (double)this->getGridCellSize());
settings.setValue("trajectory_shown", this->isTrajectoryShown()); settings.setValue("trajectory_shown", this->isTrajectoryShown());
settings.setValue("trajectory_size", this->getTrajectorySize()); settings.setValue("trajectory_size", this->getTrajectorySize());

View File

@@ -177,7 +177,7 @@ void DataRecorder::handleEvent(UEvent * event)
processingImages_ = true; processingImages_ = true;
QMetaObject::invokeMethod(this, "showImage", QMetaObject::invokeMethod(this, "showImage",
Q_ARG(cv::Mat, camEvent->data().image()), Q_ARG(cv::Mat, camEvent->data().image()),
Q_ARG(cv::Mat, camEvent->data().depth())); Q_ARG(cv::Mat, camEvent->data().depthOrRightImage()));
} }
} }
} }

View File

@@ -492,8 +492,8 @@ void GraphViewer::saveSettings(QSettings & settings, const QString & group) cons
{ {
settings.beginGroup(group); settings.beginGroup(group);
} }
settings.setValue("node_radius", this->getNodeRadius()); settings.setValue("node_radius", (double)this->getNodeRadius());
settings.setValue("link_width", this->getLinkWidth()); settings.setValue("link_width", (double)this->getLinkWidth());
settings.setValue("node_color", this->getNodeColor()); settings.setValue("node_color", this->getNodeColor());
settings.setValue("neighbor_color", this->getNeighborColor()); settings.setValue("neighbor_color", this->getNeighborColor());
settings.setValue("global_color", this->getGlobalLoopClosureColor()); settings.setValue("global_color", this->getGlobalLoopClosureColor());

View File

@@ -27,5 +27,6 @@
<file>images/kinect_xbox_one.png</file> <file>images/kinect_xbox_one.png</file>
<file>images/sense.png</file> <file>images/sense.png</file>
<file>images/xtion_pro_live.png</file> <file>images/xtion_pro_live.png</file>
<file>images/bumblebee2.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -346,17 +346,21 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) :
connect(_ui->actionOpenNI_PCL, SIGNAL(triggered()), this, SLOT(selectOpenni())); connect(_ui->actionOpenNI_PCL, SIGNAL(triggered()), this, SLOT(selectOpenni()));
connect(_ui->actionOpenNI_PCL_ASUS, SIGNAL(triggered()), this, SLOT(selectOpenni())); connect(_ui->actionOpenNI_PCL_ASUS, SIGNAL(triggered()), this, SLOT(selectOpenni()));
connect(_ui->actionFreenect, SIGNAL(triggered()), this, SLOT(selectFreenect())); connect(_ui->actionFreenect, SIGNAL(triggered()), this, SLOT(selectFreenect()));
_ui->actionFreenect->setEnabled(CameraFreenect::available());
connect(_ui->actionOpenNI_CV, SIGNAL(triggered()), this, SLOT(selectOpenniCv())); connect(_ui->actionOpenNI_CV, SIGNAL(triggered()), this, SLOT(selectOpenniCv()));
connect(_ui->actionOpenNI_CV_ASUS, SIGNAL(triggered()), this, SLOT(selectOpenniCvAsus())); connect(_ui->actionOpenNI_CV_ASUS, SIGNAL(triggered()), this, SLOT(selectOpenniCvAsus()));
connect(_ui->actionOpenNI2, SIGNAL(triggered()), this, SLOT(selectOpenni2()));
connect(_ui->actionOpenNI2_kinect, SIGNAL(triggered()), this, SLOT(selectOpenni2()));
connect(_ui->actionOpenNI2_sense, SIGNAL(triggered()), this, SLOT(selectOpenni2()));
connect(_ui->actionFreenect2, SIGNAL(triggered()), this, SLOT(selectFreenect2()));
connect(_ui->actionStereoDC1394, SIGNAL(triggered()), this, SLOT(selectStereoDC1394()));
_ui->actionFreenect->setEnabled(CameraFreenect::available());
_ui->actionOpenNI_CV->setEnabled(CameraOpenNICV::available()); _ui->actionOpenNI_CV->setEnabled(CameraOpenNICV::available());
_ui->actionOpenNI_CV_ASUS->setEnabled(CameraOpenNICV::available()); _ui->actionOpenNI_CV_ASUS->setEnabled(CameraOpenNICV::available());
connect(_ui->actionOpenNI2, SIGNAL(triggered()), this, SLOT(selectOpenni2()));
_ui->actionOpenNI2->setEnabled(CameraOpenNI2::available()); _ui->actionOpenNI2->setEnabled(CameraOpenNI2::available());
connect(_ui->actionOpenNI2_Sense, SIGNAL(triggered()), this, SLOT(selectOpenni2()));
_ui->actionOpenNI2_Sense->setEnabled(CameraOpenNI2::available());
connect(_ui->actionOpenNI2_kinect, SIGNAL(triggered()), this, SLOT(selectOpenni2()));
_ui->actionOpenNI2_kinect->setEnabled(CameraOpenNI2::available()); _ui->actionOpenNI2_kinect->setEnabled(CameraOpenNI2::available());
_ui->actionOpenNI2_sense->setEnabled(CameraOpenNI2::available());
_ui->actionFreenect2->setEnabled(CameraFreenect2::available());
_ui->actionStereoDC1394->setEnabled(CameraStereoDC1394::available());
this->updateSelectSourceMenu(); this->updateSelectSourceMenu();
connect(_ui->actionSave_state, SIGNAL(triggered()), this, SLOT(saveFigures())); connect(_ui->actionSave_state, SIGNAL(triggered()), this, SLOT(saveFigures()));
@@ -2221,14 +2225,16 @@ void MainWindow::updateSelectSourceMenu()
_ui->actionDatabase->setChecked(_preferencesDialog->isSourceDatabaseUsed()); _ui->actionDatabase->setChecked(_preferencesDialog->isSourceDatabaseUsed());
_ui->actionOpenNI_PCL->setChecked(_preferencesDialog->isSourceOpenniUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_PCL); _ui->actionOpenNI_PCL->setChecked(_preferencesDialog->isSourceRGBDUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_PCL);
_ui->actionOpenNI_PCL_ASUS->setChecked(_preferencesDialog->isSourceOpenniUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_PCL); _ui->actionOpenNI_PCL_ASUS->setChecked(_preferencesDialog->isSourceRGBDUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_PCL);
_ui->actionFreenect->setChecked(_preferencesDialog->isSourceOpenniUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcFreenect); _ui->actionFreenect->setChecked(_preferencesDialog->isSourceRGBDUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcFreenect);
_ui->actionOpenNI_CV->setChecked(_preferencesDialog->isSourceOpenniUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_CV); _ui->actionOpenNI_CV->setChecked(_preferencesDialog->isSourceRGBDUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_CV);
_ui->actionOpenNI_CV_ASUS->setChecked(_preferencesDialog->isSourceOpenniUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_CV_ASUS); _ui->actionOpenNI_CV_ASUS->setChecked(_preferencesDialog->isSourceRGBDUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_CV_ASUS);
_ui->actionOpenNI2->setChecked(_preferencesDialog->isSourceOpenniUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI2); _ui->actionOpenNI2->setChecked(_preferencesDialog->isSourceRGBDUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI2);
_ui->actionOpenNI2_Sense->setChecked(_preferencesDialog->isSourceOpenniUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI2); _ui->actionOpenNI2_kinect->setChecked(_preferencesDialog->isSourceRGBDUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI2);
_ui->actionOpenNI2_kinect->setChecked(_preferencesDialog->isSourceOpenniUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI2); _ui->actionOpenNI2_sense->setChecked(_preferencesDialog->isSourceRGBDUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI2);
_ui->actionFreenect2->setChecked(_preferencesDialog->isSourceRGBDUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcFreenect2);
_ui->actionStereoDC1394->setChecked(_preferencesDialog->isSourceRGBDUsed() && _preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcStereoDC1394);
} }
void MainWindow::changeImgRateSetting() void MainWindow::changeImgRateSetting()
@@ -2555,7 +2561,7 @@ void MainWindow::startDetection()
// Adjust pre-requirements // Adjust pre-requirements
if( !_preferencesDialog->isSourceImageUsed() && if( !_preferencesDialog->isSourceImageUsed() &&
!_preferencesDialog->isSourceDatabaseUsed() && !_preferencesDialog->isSourceDatabaseUsed() &&
!_preferencesDialog->isSourceOpenniUsed()) !_preferencesDialog->isSourceRGBDUsed())
{ {
QMessageBox::warning(this, QMessageBox::warning(this,
tr("RTAB-Map"), tr("RTAB-Map"),
@@ -2565,83 +2571,11 @@ void MainWindow::startDetection()
return; return;
} }
if(_preferencesDialog->isSourceOpenniUsed()) if(_preferencesDialog->isSourceRGBDUsed())
{ {
//Create odometry thread if rgbd slam CameraRGBD * camera = _preferencesDialog->createCameraRGBD();
if(uStr2Bool(parameters.at(Parameters::kRGBDEnabled()).c_str()))
{
if(_odomThread)
{
UERROR("OdomThread must be already deleted here?!");
delete _odomThread;
}
Odometry * odom;
if(_preferencesDialog->getOdomStrategy() == 1)
{
odom = new OdometryOpticalFlow(parameters);
}
else
{
odom = new OdometryBOW(parameters);
}
_odomThread = new OdometryThread(odom);
UEventsManager::addHandler(_odomThread); if(!camera->init(_preferencesDialog->getCameraInfoDir().toStdString()))
_odomThread->start();
}
CameraRGBD * camera = 0;
if(_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_PCL)
{
camera = new CameraOpenni(
_preferencesDialog->getSourceOpenniDevice().toStdString(),
_preferencesDialog->getGeneralInputRate(),
_preferencesDialog->getSourceOpenniLocalTransform(),
_preferencesDialog->getSourceOpenniFx(),
_preferencesDialog->getSourceOpenniFy(),
_preferencesDialog->getSourceOpenniCx(),
_preferencesDialog->getSourceOpenniCy());
}
else if(_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI2)
{
camera = new CameraOpenNI2(
_preferencesDialog->getSourceOpenniDevice().toStdString(),
_preferencesDialog->getGeneralInputRate(),
_preferencesDialog->getSourceOpenniLocalTransform(),
_preferencesDialog->getSourceOpenniFx(),
_preferencesDialog->getSourceOpenniFy(),
_preferencesDialog->getSourceOpenniCx(),
_preferencesDialog->getSourceOpenniCy());
}
else if(_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcFreenect)
{
camera = new CameraFreenect(
_preferencesDialog->getSourceOpenniDevice().isEmpty()?0:atoi(_preferencesDialog->getSourceOpenniDevice().toStdString().c_str()),
_preferencesDialog->getGeneralInputRate(),
_preferencesDialog->getSourceOpenniLocalTransform(),
_preferencesDialog->getSourceOpenniFx(),
_preferencesDialog->getSourceOpenniFy(),
_preferencesDialog->getSourceOpenniCx(),
_preferencesDialog->getSourceOpenniCy());
}
else if(_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_CV ||
_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_CV_ASUS)
{
camera = new CameraOpenNICV(
_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_CV_ASUS,
_preferencesDialog->getGeneralInputRate(),
_preferencesDialog->getSourceOpenniLocalTransform(),
_preferencesDialog->getSourceOpenniFx(),
_preferencesDialog->getSourceOpenniFy(),
_preferencesDialog->getSourceOpenniCx(),
_preferencesDialog->getSourceOpenniCy());
}
else
{
UFATAL("RGBD Source type undefined!");
}
if(!camera->init())
{ {
ULOGGER_WARN("init camera failed... "); ULOGGER_WARN("init camera failed... ");
QMessageBox::warning(this, QMessageBox::warning(this,
@@ -2657,7 +2591,7 @@ void MainWindow::startDetection()
} }
return; return;
} }
else if(_preferencesDialog->getSourceRGBD() == PreferencesDialog::kSrcOpenNI2) else if(dynamic_cast<CameraOpenNI2*>(camera) != 0)
{ {
((CameraOpenNI2*)camera)->setAutoWhiteBalance(_preferencesDialog->getSourceOpenni2AutoWhiteBalance()); ((CameraOpenNI2*)camera)->setAutoWhiteBalance(_preferencesDialog->getSourceOpenni2AutoWhiteBalance());
((CameraOpenNI2*)camera)->setAutoExposure(_preferencesDialog->getSourceOpenni2AutoExposure()); ((CameraOpenNI2*)camera)->setAutoExposure(_preferencesDialog->getSourceOpenni2AutoExposure());
@@ -2671,9 +2605,50 @@ void MainWindow::startDetection()
camera->setMirroringEnabled(_preferencesDialog->isSourceMirroring()); camera->setMirroringEnabled(_preferencesDialog->isSourceMirroring());
_camera = new CameraThread(camera); _camera = new CameraThread(camera);
if(_odomThread)
//Create odometry thread if rgbd slam
if(uStr2Bool(parameters.at(Parameters::kRGBDEnabled()).c_str()))
{ {
UEventsManager::createPipe(_camera, _odomThread, "CameraEvent"); // Require calibrated camera
if(!camera->isCalibrated())
{
UWARN("Camera is not calibrated!");
emit stateChanged(kInitialized);
delete _camera;
_camera = 0;
int button = QMessageBox::question(this,
tr("Camera is not calibrated!"),
tr("RTAB-Map cannot run with an uncalibrated camera. Do you want to calibrate the camera now?"),
QMessageBox::Yes | QMessageBox::No);
if(button == QMessageBox::Yes)
{
QTimer::singleShot(0, _preferencesDialog, SLOT(calibrate()));
}
return;
}
else
{
if(_odomThread)
{
UERROR("OdomThread must be already deleted here?!");
delete _odomThread;
}
Odometry * odom;
if(_preferencesDialog->getOdomStrategy() == 1)
{
odom = new OdometryOpticalFlow(parameters);
}
else
{
odom = new OdometryBOW(parameters);
}
_odomThread = new OdometryThread(odom);
UEventsManager::addHandler(_odomThread);
UEventsManager::createPipe(_camera, _odomThread, "CameraEvent");
_odomThread->start();
}
} }
} }
else if(_preferencesDialog->isSourceDatabaseUsed()) else if(_preferencesDialog->isSourceDatabaseUsed())
@@ -3590,6 +3565,16 @@ void MainWindow::selectOpenni2()
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI2); _preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcOpenNI2);
} }
void MainWindow::selectFreenect2()
{
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcFreenect2);
}
void MainWindow::selectStereoDC1394()
{
_preferencesDialog->selectSourceRGBD(PreferencesDialog::kSrcStereoDC1394);
}
void MainWindow::dumpTheMemory() void MainWindow::dumpTheMemory()
{ {

View File

@@ -56,7 +56,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "rtabmap/core/Graph.h" #include "rtabmap/core/Graph.h"
#include "rtabmap/gui/LoopClosureViewer.h" #include "rtabmap/gui/LoopClosureViewer.h"
#include "rtabmap/gui/DataRecorder.h" #include "rtabmap/gui/CameraViewer.h"
#include "rtabmap/gui/CloudViewer.h" #include "rtabmap/gui/CloudViewer.h"
#include "rtabmap/gui/ImageView.h" #include "rtabmap/gui/ImageView.h"
#include "GraphViewer.h" #include "GraphViewer.h"
@@ -82,7 +82,8 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
_indexModel(0), _indexModel(0),
_initialized(false), _initialized(false),
_cameraThread(0), _cameraThread(0),
_odomThread(0) _odomThread(0),
_calibrationDialog(new CalibrationDialog(false, ".", this))
{ {
ULOGGER_DEBUG(""); ULOGGER_DEBUG("");
@@ -144,6 +145,29 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
{ {
_ui->graphOptimization_type->setItemData(1, 0, Qt::UserRole - 1); _ui->graphOptimization_type->setItemData(1, 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_cameraRGBD->setItemData(6, 0, Qt::UserRole - 1);
}
_ui->openni2_exposure->setEnabled(CameraOpenNI2::exposureGainAvailable());
_ui->openni2_gain->setEnabled(CameraOpenNI2::exposureGainAvailable());
_ui->predictionPlot->showLegend(false); _ui->predictionPlot->showLegend(false);
@@ -275,18 +299,7 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
connect(_ui->source_spinBox_databaseStartPos, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->source_spinBox_databaseStartPos, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
//openni group //openni group
connect(_ui->groupBox_sourceOpenni, SIGNAL(toggled(bool)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->groupBox_sourceOpenni, SIGNAL(toggled(bool)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->radioButton_opennipcl, SIGNAL(toggled(bool)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->comboBox_cameraRGBD, SIGNAL(currentIndexChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->radioButton_freenect, SIGNAL(toggled(bool)), this, SLOT(makeObsoleteSourcePanel()));
_ui->radioButton_freenect->setEnabled(CameraFreenect::available());
connect(_ui->radioButton_opennicv, SIGNAL(toggled(bool)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->radioButton_opennicvasus, SIGNAL(toggled(bool)), this, SLOT(makeObsoleteSourcePanel()));
_ui->radioButton_opennicv->setEnabled(CameraOpenNICV::available());
_ui->radioButton_opennicvasus->setEnabled(CameraOpenNICV::available());
connect(_ui->radioButton_openni2, SIGNAL(toggled(bool)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->radioButton_openni2, SIGNAL(toggled(bool)), this, SLOT(showOpenNI2GroupBox(bool)));
_ui->radioButton_openni2->setEnabled(CameraOpenNI2::available());
_ui->openni2_exposure->setEnabled(CameraOpenNI2::exposureGainAvailable());
_ui->openni2_gain->setEnabled(CameraOpenNI2::exposureGainAvailable());
connect(_ui->openni2_autoWhiteBalance, SIGNAL(stateChanged(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_autoExposure, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->openni2_exposure, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->openni2_exposure, SIGNAL(valueChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
@@ -294,12 +307,7 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
connect(_ui->openni2_mirroring, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->openni2_mirroring, SIGNAL(stateChanged(int)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->lineEdit_openniDevice, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->lineEdit_openniDevice, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->lineEdit_openniLocalTransform, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel())); connect(_ui->lineEdit_openniLocalTransform, SIGNAL(textChanged(const QString &)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->doubleSpinBox_openniFx, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->doubleSpinBox_openniFy, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->doubleSpinBox_openniCx, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->doubleSpinBox_openniCy, SIGNAL(valueChanged(double)), this, SLOT(makeObsoleteSourcePanel()));
connect(_ui->pushButton_calibrate, SIGNAL(clicked()), this, SLOT(calibrate())); connect(_ui->pushButton_calibrate, SIGNAL(clicked()), this, SLOT(calibrate()));
connect(_ui->pushButton_calibrate_reset, SIGNAL(clicked()), this, SLOT(resetCalibration()));
//Rtabmap basic //Rtabmap basic
@@ -918,15 +926,17 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
_ui->groupBox_sourceOpenni->setChecked(true); _ui->groupBox_sourceOpenni->setChecked(true);
#ifdef _WIN32 #ifdef _WIN32
_ui->radioButton_openni2->setChecked(true); _ui->comboBox_cameraRGBD->setCurrentIndex(4); // openni2
_ui->radioButton_opennipcl->setChecked(false);
#else #else
_ui->radioButton_opennipcl->setChecked(true); if(CameraFreenect::available())
_ui->radioButton_openni2->setChecked(false); {
_ui->comboBox_cameraRGBD->setCurrentIndex(1); // freenect
}
else
{
_ui->comboBox_cameraRGBD->setCurrentIndex(0); // openni-pcl
}
#endif #endif
_ui->radioButton_freenect->setChecked(false);
_ui->radioButton_opennicv->setChecked(false);
_ui->radioButton_opennicvasus->setChecked(false);
_ui->openni2_autoWhiteBalance->setChecked(true); _ui->openni2_autoWhiteBalance->setChecked(true);
_ui->openni2_autoExposure->setChecked(true); _ui->openni2_autoExposure->setChecked(true);
_ui->openni2_exposure->setValue(0); _ui->openni2_exposure->setValue(0);
@@ -934,10 +944,6 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
_ui->openni2_mirroring->setChecked(false); _ui->openni2_mirroring->setChecked(false);
_ui->lineEdit_openniDevice->setText(""); _ui->lineEdit_openniDevice->setText("");
_ui->lineEdit_openniLocalTransform->setText("0 0 0 -PI_2 0 -PI_2"); _ui->lineEdit_openniLocalTransform->setText("0 0 0 -PI_2 0 -PI_2");
_ui->doubleSpinBox_openniFx->setValue(0.0);
_ui->doubleSpinBox_openniFy->setValue(0.0);
_ui->doubleSpinBox_openniCx->setValue(0.0);
_ui->doubleSpinBox_openniCy->setValue(0.0);
} }
else if(groupBox->objectName() == _ui->groupBox_rtabmap_basic0->objectName()) else if(groupBox->objectName() == _ui->groupBox_rtabmap_basic0->objectName())
{ {
@@ -1190,11 +1196,7 @@ void PreferencesDialog::readCameraSettings(const QString & filePath)
settings.beginGroup("Openni"); settings.beginGroup("Openni");
_ui->groupBox_sourceOpenni->setChecked(settings.value("openniUsed", _ui->groupBox_sourceOpenni->isChecked()).toBool()); _ui->groupBox_sourceOpenni->setChecked(settings.value("openniUsed", _ui->groupBox_sourceOpenni->isChecked()).toBool());
_ui->radioButton_opennipcl->setChecked(settings.value("openniType", _ui->radioButton_opennipcl->isChecked()).toBool()); _ui->comboBox_cameraRGBD->setCurrentIndex(settings.value("cameraRGBDType", _ui->comboBox_cameraRGBD->currentIndex()).toInt());
_ui->radioButton_freenect->setChecked(settings.value("freenectType", _ui->radioButton_freenect->isChecked()).toBool());
_ui->radioButton_openni2->setChecked(settings.value("openni2", _ui->radioButton_openni2->isChecked()).toBool());
_ui->radioButton_opennicv->setChecked(settings.value("openniCvType", _ui->radioButton_opennicv->isChecked()).toBool());
_ui->radioButton_opennicvasus->setChecked(settings.value("openniCvAsusType", _ui->radioButton_opennicvasus->isChecked()).toBool());
_ui->openni2_autoWhiteBalance->setChecked(settings.value("openni2AutoWhiteBalance", _ui->openni2_autoWhiteBalance->isChecked()).toBool()); _ui->openni2_autoWhiteBalance->setChecked(settings.value("openni2AutoWhiteBalance", _ui->openni2_autoWhiteBalance->isChecked()).toBool());
_ui->openni2_autoExposure->setChecked(settings.value("openni2AutoExposure", _ui->openni2_autoExposure->isChecked()).toBool()); _ui->openni2_autoExposure->setChecked(settings.value("openni2AutoExposure", _ui->openni2_autoExposure->isChecked()).toBool());
_ui->openni2_exposure->setValue(settings.value("openni2Exposure", _ui->openni2_exposure->value()).toInt()); _ui->openni2_exposure->setValue(settings.value("openni2Exposure", _ui->openni2_exposure->value()).toInt());
@@ -1202,10 +1204,7 @@ void PreferencesDialog::readCameraSettings(const QString & filePath)
_ui->openni2_mirroring->setChecked(settings.value("openni2Mirroring", _ui->openni2_mirroring->isChecked()).toBool()); _ui->openni2_mirroring->setChecked(settings.value("openni2Mirroring", _ui->openni2_mirroring->isChecked()).toBool());
_ui->lineEdit_openniDevice->setText(settings.value("device",_ui->lineEdit_openniDevice->text()).toString()); _ui->lineEdit_openniDevice->setText(settings.value("device",_ui->lineEdit_openniDevice->text()).toString());
_ui->lineEdit_openniLocalTransform->setText(settings.value("localTransform",_ui->lineEdit_openniLocalTransform->text()).toString()); _ui->lineEdit_openniLocalTransform->setText(settings.value("localTransform",_ui->lineEdit_openniLocalTransform->text()).toString());
_ui->doubleSpinBox_openniFx->setValue(settings.value("fx", _ui->doubleSpinBox_openniFx->value()).toDouble()); _calibrationDialog->loadSettings(settings, "CalibrationDialog");
_ui->doubleSpinBox_openniFy->setValue(settings.value("fy", _ui->doubleSpinBox_openniFy->value()).toDouble());
_ui->doubleSpinBox_openniCx->setValue(settings.value("cx", _ui->doubleSpinBox_openniCx->value()).toDouble());
_ui->doubleSpinBox_openniCy->setValue(settings.value("cy", _ui->doubleSpinBox_openniCy->value()).toDouble());
settings.endGroup(); // Openni settings.endGroup(); // Openni
} }
@@ -1462,11 +1461,7 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath) const
settings.beginGroup("Openni"); settings.beginGroup("Openni");
settings.setValue("openniUsed", _ui->groupBox_sourceOpenni->isChecked()); settings.setValue("openniUsed", _ui->groupBox_sourceOpenni->isChecked());
settings.setValue("openniType", _ui->radioButton_opennipcl->isChecked()); settings.setValue("cameraRGBDType", _ui->comboBox_cameraRGBD->currentIndex());
settings.setValue("freenectType", _ui->radioButton_freenect->isChecked());
settings.setValue("openni2", _ui->radioButton_openni2->isChecked());
settings.setValue("openniCvType", _ui->radioButton_opennicv->isChecked());
settings.setValue("openniCvAsusType", _ui->radioButton_opennicvasus->isChecked());
settings.setValue("openni2AutoWhiteBalance", _ui->openni2_autoWhiteBalance->isChecked()); settings.setValue("openni2AutoWhiteBalance", _ui->openni2_autoWhiteBalance->isChecked());
settings.setValue("openni2AutoExposure", _ui->openni2_autoExposure->isChecked()); settings.setValue("openni2AutoExposure", _ui->openni2_autoExposure->isChecked());
settings.setValue("openni2Exposure", _ui->openni2_exposure->value()); settings.setValue("openni2Exposure", _ui->openni2_exposure->value());
@@ -1474,11 +1469,8 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath) const
settings.setValue("openni2Mirroring", _ui->openni2_mirroring->isChecked()); settings.setValue("openni2Mirroring", _ui->openni2_mirroring->isChecked());
settings.setValue("device", _ui->lineEdit_openniDevice->text()); settings.setValue("device", _ui->lineEdit_openniDevice->text());
settings.setValue("localTransform", _ui->lineEdit_openniLocalTransform->text()); settings.setValue("localTransform", _ui->lineEdit_openniLocalTransform->text());
settings.setValue("fx", _ui->doubleSpinBox_openniFx->value()); _calibrationDialog->saveSettings(settings, "CalibrationDialog");
settings.setValue("fy", _ui->doubleSpinBox_openniFy->value()); settings.endGroup(); // Openni
settings.setValue("cx", _ui->doubleSpinBox_openniCx->value());
settings.setValue("cy", _ui->doubleSpinBox_openniCy->value());
settings.endGroup();
} }
void PreferencesDialog::writeCoreSettings(const QString & filePath) const void PreferencesDialog::writeCoreSettings(const QString & filePath) const
@@ -1795,6 +1787,7 @@ void PreferencesDialog::saveWidgetState(const QWidget * widget)
const ExportCloudsDialog * exportCloudsDialog = qobject_cast<const ExportCloudsDialog*>(widget); const ExportCloudsDialog * exportCloudsDialog = qobject_cast<const ExportCloudsDialog*>(widget);
const PostProcessingDialog * postProcessingDialog = qobject_cast<const PostProcessingDialog *>(widget); const PostProcessingDialog * postProcessingDialog = qobject_cast<const PostProcessingDialog *>(widget);
const GraphViewer * graphViewer = qobject_cast<const GraphViewer *>(widget); const GraphViewer * graphViewer = qobject_cast<const GraphViewer *>(widget);
const CalibrationDialog * calibrationDialog = qobject_cast<const CalibrationDialog *>(widget);
if(cloudViewer) if(cloudViewer)
{ {
@@ -1816,6 +1809,10 @@ void PreferencesDialog::saveWidgetState(const QWidget * widget)
{ {
graphViewer->saveSettings(settings); graphViewer->saveSettings(settings);
} }
else if(calibrationDialog)
{
calibrationDialog->saveSettings(settings);
}
else else
{ {
UERROR("Widget \"%s\" cannot be exported in config file.", widget->objectName().toStdString().c_str()); UERROR("Widget \"%s\" cannot be exported in config file.", widget->objectName().toStdString().c_str());
@@ -1840,6 +1837,7 @@ void PreferencesDialog::loadWidgetState(QWidget * widget)
ExportCloudsDialog * exportCloudsDialog = qobject_cast<ExportCloudsDialog*>(widget); ExportCloudsDialog * exportCloudsDialog = qobject_cast<ExportCloudsDialog*>(widget);
PostProcessingDialog * postProcessingDialog = qobject_cast<PostProcessingDialog *>(widget); PostProcessingDialog * postProcessingDialog = qobject_cast<PostProcessingDialog *>(widget);
GraphViewer * graphViewer = qobject_cast<GraphViewer *>(widget); GraphViewer * graphViewer = qobject_cast<GraphViewer *>(widget);
CalibrationDialog * calibrationDialog = qobject_cast<CalibrationDialog *>(widget);
if(cloudViewer) if(cloudViewer)
{ {
@@ -1861,6 +1859,10 @@ void PreferencesDialog::loadWidgetState(QWidget * widget)
{ {
graphViewer->loadSettings(settings); graphViewer->loadSettings(settings);
} }
else if(calibrationDialog)
{
calibrationDialog->loadSettings(settings);
}
else else
{ {
UERROR("Widget \"%s\" cannot be loaded from config file.", widget->objectName().toStdString().c_str()); UERROR("Widget \"%s\" cannot be loaded from config file.", widget->objectName().toStdString().c_str());
@@ -2059,36 +2061,12 @@ void PreferencesDialog::selectSourceRGBD(Src src)
} }
_ui->groupBox_sourceOpenni->setChecked(true); _ui->groupBox_sourceOpenni->setChecked(true);
_ui->radioButton_opennipcl->setChecked(src == kSrcOpenNI_PCL); _ui->comboBox_cameraRGBD->setCurrentIndex(src - kSrcOpenNI_PCL);
_ui->radioButton_freenect->setChecked(src == kSrcFreenect);
_ui->radioButton_opennicv->setChecked(src == kSrcOpenNI_CV);
_ui->radioButton_opennicvasus->setChecked(src == kSrcOpenNI_CV_ASUS);
_ui->radioButton_openni2->setChecked(src == kSrcOpenNI2);
if(_ui->groupBox_sourceOpenni->isChecked()) if(_ui->groupBox_sourceOpenni->isChecked())
{ {
_ui->groupBox_sourceImage->setChecked(false); _ui->groupBox_sourceImage->setChecked(false);
_ui->groupBox_sourceDatabase->setChecked(false); _ui->groupBox_sourceDatabase->setChecked(false);
if(_ui->doubleSpinBox_openniFx->value() != 0 ||
_ui->doubleSpinBox_openniFy->value() != 0 ||
_ui->doubleSpinBox_openniCx->value() != 0 ||
_ui->doubleSpinBox_openniCy->value() != 0 )
{
int button = QMessageBox::information(this,
tr("Calibration detected"),
tr("Some calibration values (fx=%1, fy=%2, cx=%3, cy=%4) are set.\n"
"Do you want to reset them to factory defaults?")
.arg(_ui->doubleSpinBox_openniFx->value())
.arg(_ui->doubleSpinBox_openniFy->value())
.arg(_ui->doubleSpinBox_openniCx->value())
.arg(_ui->doubleSpinBox_openniCy->value()),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if(button & QMessageBox::Yes)
{
this->resetCalibration();
}
}
} }
if(validateForm()) if(validateForm())
@@ -2984,7 +2962,7 @@ bool PreferencesDialog::isSourceDatabaseUsed() const
{ {
return _ui->groupBox_sourceDatabase->isChecked(); return _ui->groupBox_sourceDatabase->isChecked();
} }
bool PreferencesDialog::isSourceOpenniUsed() const bool PreferencesDialog::isSourceRGBDUsed() const
{ {
return _ui->groupBox_sourceOpenni->isChecked(); return _ui->groupBox_sourceOpenni->isChecked();
} }
@@ -3052,26 +3030,7 @@ int PreferencesDialog::getSourceDatabaseStartPos() const
PreferencesDialog::Src PreferencesDialog::getSourceRGBD() const PreferencesDialog::Src PreferencesDialog::getSourceRGBD() const
{ {
if(_ui->radioButton_freenect->isChecked()) return (PreferencesDialog::Src)(_ui->comboBox_cameraRGBD->currentIndex()+kSrcOpenNI_PCL);
{
return kSrcFreenect;
}
else if(_ui->radioButton_opennicv->isChecked())
{
return kSrcOpenNI_CV;
}
else if (_ui->radioButton_opennicvasus->isChecked())
{
return kSrcOpenNI_CV_ASUS;
}
else if (_ui->radioButton_openni2->isChecked())
{
return kSrcOpenNI2;
}
else
{
return kSrcOpenNI_PCL;
}
} }
bool PreferencesDialog::getSourceOpenni2AutoWhiteBalance() const bool PreferencesDialog::getSourceOpenni2AutoWhiteBalance() const
{ {
@@ -3129,21 +3088,55 @@ Transform PreferencesDialog::getSourceOpenniLocalTransform() const
return t; return t;
} }
float PreferencesDialog::getSourceOpenniFx() const CameraRGBD * PreferencesDialog::createCameraRGBD() const
{ {
return _ui->doubleSpinBox_openniFx->value(); if(this->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_PCL)
} {
float PreferencesDialog::getSourceOpenniFy() const return new CameraOpenni(
{ this->getSourceOpenniDevice().toStdString(),
return _ui->doubleSpinBox_openniFy->value(); this->getGeneralInputRate(),
} this->getSourceOpenniLocalTransform());
float PreferencesDialog::getSourceOpenniCx() const }
{ else if(this->getSourceRGBD() == PreferencesDialog::kSrcOpenNI2)
return _ui->doubleSpinBox_openniCx->value(); {
} return new CameraOpenNI2(
float PreferencesDialog::getSourceOpenniCy() const this->getSourceOpenniDevice().toStdString(),
{ this->getGeneralInputRate(),
return _ui->doubleSpinBox_openniCy->value(); this->getSourceOpenniLocalTransform());
}
else if(this->getSourceRGBD() == PreferencesDialog::kSrcFreenect)
{
return new CameraFreenect(
this->getSourceOpenniDevice().isEmpty()?0:atoi(this->getSourceOpenniDevice().toStdString().c_str()),
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform());
}
else if(this->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_CV ||
this->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_CV_ASUS)
{
return new CameraOpenNICV(
this->getSourceRGBD() == PreferencesDialog::kSrcOpenNI_CV_ASUS,
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform());
}
else if(this->getSourceRGBD() == kSrcFreenect2)
{
return new CameraFreenect2(
this->getSourceOpenniDevice().isEmpty()?0:atoi(this->getSourceOpenniDevice().toStdString().c_str()),
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform());
}
else if(this->getSourceRGBD() == kSrcStereoDC1394)
{
return new CameraStereoDC1394(
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform());
}
else
{
UFATAL("RGBD Source type undefined!");
}
return 0;
} }
bool PreferencesDialog::isStatisticsPublished() const bool PreferencesDialog::isStatisticsPublished() const
@@ -3163,6 +3156,11 @@ int PreferencesDialog::getOdomStrategy() const
return _ui->odom_strategy->currentIndex(); return _ui->odom_strategy->currentIndex();
} }
QString PreferencesDialog::getCameraInfoDir() const
{
return (this->getWorkingDirectory().isEmpty()?".":this->getWorkingDirectory())+"/camera_info";
}
bool PreferencesDialog::isImagesKept() const bool PreferencesDialog::isImagesKept() const
{ {
return _ui->general_checkBox_imagesKept->isChecked(); return _ui->general_checkBox_imagesKept->isChecked();
@@ -3266,58 +3264,9 @@ void PreferencesDialog::testOdometry(int type)
UASSERT(_odomThread == 0 && _cameraThread == 0); UASSERT(_odomThread == 0 && _cameraThread == 0);
CameraRGBD * camera = 0; CameraRGBD * camera = this->createCameraRGBD();
if(this->getSourceRGBD() == kSrcOpenNI_PCL)
{
camera = new CameraOpenni(
this->getSourceOpenniDevice().toStdString(),
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform(),
this->getSourceOpenniFx(),
this->getSourceOpenniFy(),
this->getSourceOpenniCx(),
this->getSourceOpenniCy());
}
else if(this->getSourceRGBD() == kSrcOpenNI2)
{
camera = new CameraOpenNI2(
this->getSourceOpenniDevice().toStdString(),
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform(),
this->getSourceOpenniFx(),
this->getSourceOpenniFy(),
this->getSourceOpenniCx(),
this->getSourceOpenniCy());
} if(!camera->init(this->getCameraInfoDir().toStdString()))
else if(this->getSourceRGBD() == kSrcFreenect)
{
camera = new CameraFreenect(
this->getSourceOpenniDevice().isEmpty()?0:atoi(this->getSourceOpenniDevice().toStdString().c_str()),
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform(),
this->getSourceOpenniFx(),
this->getSourceOpenniFy(),
this->getSourceOpenniCx(),
this->getSourceOpenniCy());
}
else if(this->getSourceRGBD() == kSrcOpenNI_CV || this->getSourceRGBD() == kSrcOpenNI_CV_ASUS)
{
camera = new CameraOpenNICV(
this->getSourceRGBD() == kSrcOpenNI_CV_ASUS,
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform(),
this->getSourceOpenniFx(),
this->getSourceOpenniFy(),
this->getSourceOpenniCx(),
this->getSourceOpenniCy());
}
else
{
UFATAL("RGBD Source type undefined!");
}
if(!camera->init())
{ {
QMessageBox::warning(this, QMessageBox::warning(this,
tr("RTAB-Map"), tr("RTAB-Map"),
@@ -3325,7 +3274,7 @@ void PreferencesDialog::testOdometry(int type)
delete camera; delete camera;
camera = 0; camera = 0;
} }
else if(this->getSourceRGBD() == kSrcOpenNI2) else if(dynamic_cast<CameraOpenNI2*>(camera) != 0)
{ {
((CameraOpenNI2*)camera)->setAutoWhiteBalance(getSourceOpenni2AutoWhiteBalance()); ((CameraOpenNI2*)camera)->setAutoWhiteBalance(getSourceOpenni2AutoWhiteBalance());
((CameraOpenNI2*)camera)->setAutoExposure(getSourceOpenni2AutoExposure()); ((CameraOpenNI2*)camera)->setAutoExposure(getSourceOpenni2AutoExposure());
@@ -3434,58 +3383,8 @@ void PreferencesDialog::testRGBDCamera()
tr("A camera is already running!")); tr("A camera is already running!"));
} }
CameraRGBD * camera = 0; CameraRGBD * camera = this->createCameraRGBD();
if(this->getSourceRGBD() == kSrcOpenNI_PCL) if(!camera->init(this->getCameraInfoDir().toStdString()))
{
camera = new CameraOpenni(
this->getSourceOpenniDevice().toStdString(),
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform(),
this->getSourceOpenniFx(),
this->getSourceOpenniFy(),
this->getSourceOpenniCx(),
this->getSourceOpenniCy());
}
else if(this->getSourceRGBD() == kSrcOpenNI2)
{
camera = new CameraOpenNI2(
this->getSourceOpenniDevice().toStdString(),
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform(),
this->getSourceOpenniFx(),
this->getSourceOpenniFy(),
this->getSourceOpenniCx(),
this->getSourceOpenniCy());
}
else if(this->getSourceRGBD() == kSrcFreenect)
{
camera = new CameraFreenect(
this->getSourceOpenniDevice().isEmpty()?0:atoi(this->getSourceOpenniDevice().toStdString().c_str()),
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform(),
this->getSourceOpenniFx(),
this->getSourceOpenniFy(),
this->getSourceOpenniCx(),
this->getSourceOpenniCy());
}
else if(this->getSourceRGBD() == kSrcOpenNI_CV || this->getSourceRGBD() == kSrcOpenNI_CV_ASUS)
{
camera = new CameraOpenNICV(
this->getSourceRGBD() == kSrcOpenNI_CV_ASUS,
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform(),
this->getSourceOpenniFx(),
this->getSourceOpenniFy(),
this->getSourceOpenniCx(),
this->getSourceOpenniCy());
}
else
{
UFATAL("RGBD Source type undefined!");
}
if(!camera->init())
{ {
QMessageBox::warning(this, QMessageBox::warning(this,
tr("RTAB-Map"), tr("RTAB-Map"),
@@ -3493,7 +3392,7 @@ void PreferencesDialog::testRGBDCamera()
delete camera; delete camera;
camera = 0; camera = 0;
} }
else if(this->getSourceRGBD() == kSrcOpenNI2) else if(dynamic_cast<CameraOpenNI2*>(camera) != 0)
{ {
((CameraOpenNI2*)camera)->setAutoWhiteBalance(getSourceOpenni2AutoWhiteBalance()); ((CameraOpenNI2*)camera)->setAutoWhiteBalance(getSourceOpenni2AutoWhiteBalance());
((CameraOpenNI2*)camera)->setAutoExposure(getSourceOpenni2AutoExposure()); ((CameraOpenNI2*)camera)->setAutoExposure(getSourceOpenni2AutoExposure());
@@ -3512,13 +3411,13 @@ void PreferencesDialog::testRGBDCamera()
_ui->pushButton_test_rgbd_camera->setEnabled(false); _ui->pushButton_test_rgbd_camera->setEnabled(false);
// Create DataRecorder without init it, just to show images... // Create DataRecorder without init it, just to show images...
DataRecorder * window = new DataRecorder(this); CameraViewer * window = new CameraViewer(this);
window->setWindowModality(Qt::WindowModal); window->setWindowModality(Qt::WindowModal);
window->setAttribute(Qt::WA_DeleteOnClose); window->setAttribute(Qt::WA_DeleteOnClose);
window->setWindowFlags(Qt::Dialog); window->setWindowFlags(Qt::Dialog);
window->setWindowTitle(tr("RGBD camera viewer")); window->setWindowTitle(tr("RGBD camera viewer"));
window->setMinimumWidth(800); window->setMinimumWidth(1280);
window->setMinimumHeight(600); window->setMinimumHeight(480);
connect( window, SIGNAL(destroyed(QObject*)), this, SLOT(cleanRGBDCameraTest()) ); connect( window, SIGNAL(destroyed(QObject*)), this, SLOT(cleanRGBDCameraTest()) );
window->registerToEventsManager(); window->registerToEventsManager();
@@ -3533,58 +3432,8 @@ void PreferencesDialog::testRGBDCamera()
void PreferencesDialog::calibrate() void PreferencesDialog::calibrate()
{ {
CameraRGBD * camera = 0; CameraRGBD * camera = this->createCameraRGBD();
if(this->getSourceRGBD() == kSrcOpenNI_PCL) if(!camera->init("")) // don't set calibration folder to use raw images
{
camera = new CameraOpenni(
this->getSourceOpenniDevice().toStdString(),
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform(),
this->getSourceOpenniFx(),
this->getSourceOpenniFy(),
this->getSourceOpenniCx(),
this->getSourceOpenniCy());
}
else if(this->getSourceRGBD() == kSrcOpenNI2)
{
camera = new CameraOpenNI2(
this->getSourceOpenniDevice().toStdString(),
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform(),
this->getSourceOpenniFx(),
this->getSourceOpenniFy(),
this->getSourceOpenniCx(),
this->getSourceOpenniCy());
}
else if(this->getSourceRGBD() == kSrcFreenect)
{
camera = new CameraFreenect(
this->getSourceOpenniDevice().isEmpty()?0:atoi(this->getSourceOpenniDevice().toStdString().c_str()),
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform(),
this->getSourceOpenniFx(),
this->getSourceOpenniFy(),
this->getSourceOpenniCx(),
this->getSourceOpenniCy());
}
else if(this->getSourceRGBD() == kSrcOpenNI_CV || this->getSourceRGBD() == kSrcOpenNI_CV_ASUS)
{
camera = new CameraOpenNICV(
this->getSourceRGBD() == kSrcOpenNI_CV_ASUS,
this->getGeneralInputRate(),
this->getSourceOpenniLocalTransform(),
this->getSourceOpenniFx(),
this->getSourceOpenniFy(),
this->getSourceOpenniCx(),
this->getSourceOpenniCy());
}
else
{
UFATAL("RGBD Source type undefined!");
}
if(!camera->init())
{ {
QMessageBox::warning(this, QMessageBox::warning(this,
tr("RTAB-Map"), tr("RTAB-Map"),
@@ -3592,7 +3441,7 @@ void PreferencesDialog::calibrate()
delete camera; delete camera;
camera = 0; camera = 0;
} }
else if(this->getSourceRGBD() == kSrcOpenNI2) else if(dynamic_cast<CameraOpenNI2*>(camera) != 0)
{ {
((CameraOpenNI2*)camera)->setAutoWhiteBalance(getSourceOpenni2AutoWhiteBalance()); ((CameraOpenNI2*)camera)->setAutoWhiteBalance(getSourceOpenni2AutoWhiteBalance());
((CameraOpenNI2*)camera)->setAutoExposure(getSourceOpenni2AutoExposure()); ((CameraOpenNI2*)camera)->setAutoExposure(getSourceOpenni2AutoExposure());
@@ -3608,33 +3457,32 @@ void PreferencesDialog::calibrate()
if(camera) if(camera)
{ {
CalibrationDialog * dialog = new CalibrationDialog(this); if(!this->getCameraInfoDir().isEmpty())
dialog->registerToEventsManager(); {
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(dynamic_cast<CameraStereoDC1394*>(camera)!=0);
_calibrationDialog->setSavingDirectory(this->getCameraInfoDir());
_calibrationDialog->registerToEventsManager();
CameraThread cameraThread(camera); CameraThread cameraThread(camera);
UEventsManager::createPipe(&cameraThread, dialog, "CameraEvent"); UEventsManager::createPipe(&cameraThread, _calibrationDialog, "CameraEvent");
cameraThread.start(); cameraThread.start();
if(dialog->exec() == QDialog::Accepted) _calibrationDialog->exec();
{ _calibrationDialog->unregisterFromEventsManager();
_ui->doubleSpinBox_openniFx->setValue(dialog->fx());
_ui->doubleSpinBox_openniFy->setValue(dialog->fy());
_ui->doubleSpinBox_openniCx->setValue(dialog->cx());
_ui->doubleSpinBox_openniCy->setValue(dialog->cy());
}
cameraThread.join(true); cameraThread.join(true);
delete dialog;
} }
} }
void PreferencesDialog::resetCalibration()
{
_ui->doubleSpinBox_openniFx->setValue(0);
_ui->doubleSpinBox_openniFy->setValue(0);
_ui->doubleSpinBox_openniCx->setValue(0);
_ui->doubleSpinBox_openniCy->setValue(0);
}
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>875</width> <width>1310</width>
<height>834</height> <height>834</height>
</rect> </rect>
</property> </property>
@@ -586,7 +586,7 @@
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons"> <property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> <set>QDialogButtonBox::Close</set>
</property> </property>
</widget> </widget>
</item> </item>

View File

@@ -135,11 +135,33 @@
<iconset resource="../GuiLib.qrc"> <iconset resource="../GuiLib.qrc">
<normaloff>:/images/sense.png</normaloff>:/images/sense.png</iconset> <normaloff>:/images/sense.png</normaloff>:/images/sense.png</iconset>
</property> </property>
<addaction name="actionOpenNI2_Sense"/> <addaction name="actionOpenNI2_sense"/>
</widget>
<widget class="QMenu" name="menuKinect_v2">
<property name="title">
<string>Kinect v2</string>
</property>
<property name="icon">
<iconset resource="../GuiLib.qrc">
<normaloff>:/images/kinect_xbox_one.png</normaloff>:/images/kinect_xbox_one.png</iconset>
</property>
<addaction name="actionFreenect2"/>
</widget>
<widget class="QMenu" name="menuBumblebee2">
<property name="title">
<string>Bumblebee2</string>
</property>
<property name="icon">
<iconset resource="../GuiLib.qrc">
<normaloff>:/images/bumblebee2.png</normaloff>:/images/bumblebee2.png</iconset>
</property>
<addaction name="actionStereoDC1394"/>
</widget> </widget>
<addaction name="menuKinect_for_Xbox_360"/> <addaction name="menuKinect_for_Xbox_360"/>
<addaction name="menuXtion_PRO_LIVE"/> <addaction name="menuXtion_PRO_LIVE"/>
<addaction name="menuSense_3D_scanner"/> <addaction name="menuSense_3D_scanner"/>
<addaction name="menuKinect_v2"/>
<addaction name="menuBumblebee2"/>
</widget> </widget>
<addaction name="menuRGB_D_camera"/> <addaction name="menuRGB_D_camera"/>
<addaction name="menuImage"/> <addaction name="menuImage"/>
@@ -1113,14 +1135,6 @@
<string>View scans...</string> <string>View scans...</string>
</property> </property>
</action> </action>
<action name="actionOpenNI2_Sense">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>OpenNI2</string>
</property>
</action>
<action name="actionOpen_database"> <action name="actionOpen_database">
<property name="icon"> <property name="icon">
<iconset resource="../GuiLib.qrc"> <iconset resource="../GuiLib.qrc">
@@ -1163,6 +1177,22 @@
<string>Save config</string> <string>Save config</string>
</property> </property>
</action> </action>
<action name="actionFreenect2">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Freenect2</string>
</property>
</action>
<action name="actionStereoDC1394">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>StereoDC1394</string>
</property>
</action>
<action name="actionOpenNI2_kinect"> <action name="actionOpenNI2_kinect">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
@@ -1171,6 +1201,14 @@
<string>OpenNI2</string> <string>OpenNI2</string>
</property> </property>
</action> </action>
<action name="actionOpenNI2_sense">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>OpenNI2</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>

View File

@@ -64,8 +64,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>744</width> <width>737</width>
<height>1110</height> <height>982</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_16"> <layout class="QVBoxLayout" name="verticalLayout_16">
@@ -86,7 +86,7 @@
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>23</number> <number>3</number>
</property> </property>
<widget class="QWidget" name="page_22"> <widget class="QWidget" name="page_22">
<layout class="QVBoxLayout" name="verticalLayout_29"> <layout class="QVBoxLayout" name="verticalLayout_29">
@@ -1687,65 +1687,83 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_7"> <layout class="QGridLayout" name="gridLayout_55" columnstretch="0,0,1">
<item> <item row="0" column="1">
<widget class="QRadioButton" name="radioButton_opennipcl"> <widget class="QComboBox" name="comboBox_cameraRGBD">
<property name="text"> <property name="sizeAdjustPolicy">
<string>OpenNI-PCL</string> <enum>QComboBox::AdjustToContents</enum>
</property> </property>
<property name="checked"> <item>
<property name="text">
<string>OpenNI-PCL</string>
</property>
</item>
<item>
<property name="text">
<string>Freenect</string>
</property>
</item>
<item>
<property name="text">
<string>OpenNI-CV</string>
</property>
</item>
<item>
<property name="text">
<string>OpenNI-CV-ASUS</string>
</property>
</item>
<item>
<property name="text">
<string>OpenNI2</string>
</property>
</item>
<item>
<property name="text">
<string>Freenect2</string>
</property>
</item>
<item>
<property name="text">
<string>StereoDC1394</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButton_calibrate">
<property name="text">
<string>Calibrate</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_46">
<property name="text">
<string>On initialization, calibration files are loaded from the &quot;camera_info&quot; folder in the working directory.</string>
</property>
<property name="wordWrap">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="2" column="1">
<widget class="QRadioButton" name="radioButton_freenect">
<property name="text">
<string>Feeenect</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_opennicv">
<property name="text">
<string>OpenNI-CV</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_opennicvasus">
<property name="text">
<string>OpenNI-CV-ASUS</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_openni2">
<property name="text">
<string>OpenNI2</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_test_rgbd_camera"> <widget class="QPushButton" name="pushButton_test_rgbd_camera">
<property name="text"> <property name="text">
<string>Test</string> <string>Test</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2">
<widget class="QLabel" name="label_228">
<property name="text">
<string>Driver</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@@ -1895,116 +1913,6 @@ when using the file type, logs are saved in LogRtabmap.txt (located in the worki
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Calibration</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_41">
<item>
<widget class="QLabel" name="label_160">
<property name="text">
<string>Camera intrinsic parameters. While the default values are good, a calibration is recommended to increase the precision of the 3D clouds. Set values to 0 to use the default parameters from the camera. For example, the focal length is ~525 for Kinect and ~545 for Xtion Pro Live. The button &quot;Calibrate&quot; below can be used to calibrate the camera with a chessboard pattern.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_55" columnstretch="0,1">
<item row="0" column="0">
<widget class="QDoubleSpinBox" name="doubleSpinBox_openniFx">
<property name="maximum">
<double>1000.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_161">
<property name="text">
<string>fx=K[0]</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QDoubleSpinBox" name="doubleSpinBox_openniFy">
<property name="maximum">
<double>1000.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_162">
<property name="text">
<string>fy=K[4]</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QDoubleSpinBox" name="doubleSpinBox_openniCx">
<property name="maximum">
<double>1000.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_166">
<property name="text">
<string>cx=K[2]</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QDoubleSpinBox" name="doubleSpinBox_openniCy">
<property name="maximum">
<double>1000.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_165">
<property name="text">
<string>cy=K[5]</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QPushButton" name="pushButton_calibrate">
<property name="text">
<string>Calibrate</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_calibrate_reset">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@@ -180,12 +180,12 @@ int main(int argc, char * argv[])
} }
else if(driver == 6) else if(driver == 6)
{ {
if(!rtabmap::CameraDC1394::available()) if(!rtabmap::CameraStereoDC1394::available())
{ {
UERROR("Not built with DC1394 support..."); UERROR("Not built with DC1394 support...");
exit(-1); exit(-1);
} }
camera = new rtabmap::CameraDC1394(); camera = new rtabmap::CameraStereoDC1394();
} }
else else
{ {

View File

@@ -120,12 +120,12 @@ int main(int argc, char * argv[])
} }
else if(driver == 6) else if(driver == 6)
{ {
if(!rtabmap::CameraDC1394::available()) if(!rtabmap::CameraStereoDC1394::available())
{ {
UERROR("Not built with DC1394 support..."); UERROR("Not built with DC1394 support...");
exit(-1); exit(-1);
} }
camera = new rtabmap::CameraDC1394("camera_info"); camera = new rtabmap::CameraStereoDC1394();
} }
else else
{ {