mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 01:20:25 +08:00
Added stereo option for the CalibrationDialog class
This commit is contained in:
@@ -44,9 +44,10 @@ public:
|
||||
};
|
||||
|
||||
public:
|
||||
CameraEvent(const cv::Mat & image, int seq=0, double stamp = 0.0) :
|
||||
CameraEvent(const cv::Mat & image, int seq=0, double stamp = 0.0, const std::string & cameraName = "") :
|
||||
UEvent(kCodeImage),
|
||||
data_(image, seq, stamp)
|
||||
data_(image, seq, stamp),
|
||||
cameraName_(cameraName)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -55,26 +56,23 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
CameraEvent(const cv::Mat & rgb, const cv::Mat & depth, float fx, float fy, float cx, float cy, const Transform & localTransform, int id, double stamp) :
|
||||
CameraEvent(const SensorData & data, const std::string & cameraName = "") :
|
||||
UEvent(kCodeImageDepth),
|
||||
data_(rgb, depth, fx, fy, cx, cy, localTransform, Transform(), 1.0f, 1.0f, id, stamp)
|
||||
{
|
||||
}
|
||||
|
||||
CameraEvent(const SensorData & data) :
|
||||
UEvent(kCodeImageDepth),
|
||||
data_(data)
|
||||
data_(data),
|
||||
cameraName_(cameraName)
|
||||
{
|
||||
}
|
||||
|
||||
// Image or descriptors
|
||||
const SensorData & data() const {return data_;}
|
||||
const std::string & cameraName() const {return cameraName_;}
|
||||
|
||||
virtual ~CameraEvent() {}
|
||||
virtual std::string getClassName() const {return std::string("CameraEvent");}
|
||||
|
||||
private:
|
||||
SensorData data_;
|
||||
std::string cameraName_;
|
||||
};
|
||||
|
||||
} // namespace rtabmap
|
||||
|
||||
@@ -36,8 +36,23 @@ class CameraModel
|
||||
{
|
||||
public:
|
||||
CameraModel();
|
||||
// K is the camera intrinsic 3x3 CV_64FC1
|
||||
// D is the distortion coefficients 1x5 CV_64FC1
|
||||
// R is the rectification matrix 3x3 CV_64FC1 (computed from stereo or Identity)
|
||||
// P is the projection matrix 3x4 CV_64FC1 (computed from stereo or equal to [K [0 0 1]'])
|
||||
CameraModel(const std::string & name, const cv::Size & imageSize, const cv::Mat & K, const cv::Mat & D, const cv::Mat & R, const cv::Mat & P);
|
||||
virtual ~CameraModel() {}
|
||||
|
||||
bool isValid() const {return !K_.empty() &&
|
||||
!D_.empty() &&
|
||||
!R_.empty() &&
|
||||
!P_.empty() &&
|
||||
imageSize_.height &&
|
||||
imageSize_.width &&
|
||||
!name_.empty();}
|
||||
|
||||
const std::string & name() const {return name_;}
|
||||
|
||||
double fx() const {return P_.at<double>(0,0);}
|
||||
double fy() const {return P_.at<double>(1,1);}
|
||||
double cx() const {return P_.at<double>(0,2);}
|
||||
@@ -49,17 +64,18 @@ public:
|
||||
const cv::Mat & R() const {return R_;}
|
||||
const cv::Mat & P() const {return P_;}
|
||||
|
||||
int width() const {return width_;}
|
||||
int height() const {return height_;}
|
||||
const cv::Size & imageSize() const {return imageSize_;}
|
||||
int imageWidth() const {return imageSize_.width;}
|
||||
int imageWeight() const {return imageSize_.height;}
|
||||
|
||||
bool load(const std::string & directory, const std::string & cameraName);
|
||||
void save(const std::string & directory, const std::string & cameraName);
|
||||
bool load(const std::string & filePath);
|
||||
bool save(const std::string & filePath);
|
||||
|
||||
cv::Mat rectifyImage(const cv::Mat & raw) const;
|
||||
|
||||
private:
|
||||
int width_;
|
||||
int height_;
|
||||
std::string name_;
|
||||
cv::Size imageSize_;
|
||||
cv::Mat K_;
|
||||
cv::Mat D_;
|
||||
cv::Mat R_;
|
||||
@@ -72,17 +88,29 @@ class StereoCameraModel
|
||||
{
|
||||
public:
|
||||
StereoCameraModel() {}
|
||||
StereoCameraModel(const std::string & name, const cv::Size & imageSize,
|
||||
const cv::Mat & K1, const cv::Mat & D1, const cv::Mat & R1, const cv::Mat & P1,
|
||||
const cv::Mat & K2, const cv::Mat & D2, const cv::Mat & R2, const cv::Mat & P2) :
|
||||
left_(name+"_left", imageSize, K1, D1, R1, P1),
|
||||
right_(name+"_right", imageSize, K2, D2, R2, P2),
|
||||
name_(name)
|
||||
{
|
||||
}
|
||||
virtual ~StereoCameraModel() {}
|
||||
|
||||
bool isValid() const {return left_.isValid() && right_.isValid();}
|
||||
const std::string & name() const {return name_;}
|
||||
|
||||
bool load(const std::string & directory, const std::string & cameraName)
|
||||
{
|
||||
return left_.load(directory, cameraName+"_left") &&
|
||||
right_.load(directory, cameraName+"_right");
|
||||
name_ = cameraName;
|
||||
return left_.load(directory+"/"+cameraName+"_left.yaml") &&
|
||||
right_.load(directory+"/"+cameraName+"_right.yaml");
|
||||
}
|
||||
void save(const std::string & directory, const std::string & cameraName)
|
||||
bool save(const std::string & directory, const std::string & cameraName)
|
||||
{
|
||||
left_.save(directory, cameraName+"_left");
|
||||
right_.save(directory, cameraName+"_right");
|
||||
return left_.save(directory+"/"+cameraName+"_left.yaml") &&
|
||||
right_.save(directory+"/"+cameraName+"_right.yaml");
|
||||
}
|
||||
double baseline() const {return -right_.Tx()/right_.fx();}
|
||||
|
||||
@@ -92,6 +120,7 @@ public:
|
||||
private:
|
||||
CameraModel left_;
|
||||
CameraModel right_;
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
} /* namespace rtabmap */
|
||||
|
||||
@@ -81,6 +81,7 @@ public:
|
||||
virtual ~CameraRGBD();
|
||||
void takeImage(cv::Mat & rgb, cv::Mat & depth, float & fx, float & fy, float & cx, float & cy);
|
||||
virtual bool init() = 0;
|
||||
virtual std::string getSerial() const = 0;
|
||||
|
||||
//getters
|
||||
float getImageRate() const {return _imageRate;}
|
||||
@@ -154,7 +155,8 @@ public:
|
||||
const boost::shared_ptr<openni_wrapper::DepthImage>& depth,
|
||||
float constant);
|
||||
|
||||
bool init();
|
||||
virtual bool init();
|
||||
virtual std::string getSerial() const;
|
||||
|
||||
protected:
|
||||
virtual void captureImage(cv::Mat & rgb, cv::Mat & depth, float & fx, float & fy, float & cx, float & cy);
|
||||
@@ -191,6 +193,7 @@ public:
|
||||
virtual ~CameraOpenNICV();
|
||||
|
||||
virtual bool init();
|
||||
virtual std::string getSerial() const {return "";} // unknown with OpenCV
|
||||
|
||||
protected:
|
||||
virtual void captureImage(cv::Mat & rgb, cv::Mat & depth, float & fx, float & fy, float & cx, float & cy);
|
||||
@@ -223,6 +226,7 @@ public:
|
||||
virtual ~CameraOpenNI2();
|
||||
|
||||
virtual bool init();
|
||||
virtual std::string getSerial() const;
|
||||
|
||||
bool setAutoWhiteBalance(bool enabled);
|
||||
bool setAutoExposure(bool enabled);
|
||||
@@ -266,6 +270,7 @@ public:
|
||||
virtual ~CameraFreenect();
|
||||
|
||||
bool init();
|
||||
virtual std::string getSerial() const;
|
||||
|
||||
protected:
|
||||
virtual void captureImage(cv::Mat & rgb, cv::Mat & depth, float & fx, float & fy, float & cx, float & cy);
|
||||
@@ -298,6 +303,7 @@ public:
|
||||
virtual ~CameraFreenect2();
|
||||
|
||||
bool init();
|
||||
virtual std::string getSerial() const;
|
||||
|
||||
protected:
|
||||
virtual void captureImage(cv::Mat & rgb, cv::Mat & depth, float & fx, float & fy, float & cx, float & cy);
|
||||
@@ -321,7 +327,14 @@ public:
|
||||
static bool available();
|
||||
|
||||
public:
|
||||
// default local transform z in, x right, y down));
|
||||
// The first constructor will not check for calibration files, so
|
||||
// the images returned won't be rectified
|
||||
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(),
|
||||
@@ -332,11 +345,13 @@ public:
|
||||
virtual ~CameraDC1394();
|
||||
|
||||
bool init();
|
||||
virtual std::string getSerial() const;
|
||||
|
||||
protected:
|
||||
virtual void captureImage(cv::Mat & left, cv::Mat & right, float & fx, float & baseline, float & cx, float & cy);
|
||||
|
||||
private:
|
||||
bool lookForCalibration_;
|
||||
std::string calibrationFolder_;
|
||||
DC1394Device *device_;
|
||||
StereoCameraModel stereoModel_;
|
||||
|
||||
Reference in New Issue
Block a user