Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef STEREOCAMERAMODEL_H_
00029 #define STEREOCAMERAMODEL_H_
00030
00031 #include <rtabmap/core/CameraModel.h>
00032
00033 namespace rtabmap {
00034
00035 class RTABMAP_EXP StereoCameraModel
00036 {
00037 public:
00038 StereoCameraModel() {}
00039 StereoCameraModel(
00040 const std::string & name,
00041 const cv::Size & imageSize1,
00042 const cv::Mat & K1, const cv::Mat & D1, const cv::Mat & R1, const cv::Mat & P1,
00043 const cv::Size & imageSize2,
00044 const cv::Mat & K2, const cv::Mat & D2, const cv::Mat & R2, const cv::Mat & P2,
00045 const cv::Mat & R, const cv::Mat & T, const cv::Mat & E, const cv::Mat & F,
00046 const Transform & localTransform = Transform::getIdentity());
00047
00048
00049 StereoCameraModel(
00050 const std::string & name,
00051 const CameraModel & leftCameraModel,
00052 const CameraModel & rightCameraModel,
00053 const cv::Mat & R = cv::Mat(),
00054 const cv::Mat & T = cv::Mat(),
00055 const cv::Mat & E = cv::Mat(),
00056 const cv::Mat & F = cv::Mat());
00057
00058 StereoCameraModel(
00059 const std::string & name,
00060 const CameraModel & leftCameraModel,
00061 const CameraModel & rightCameraModel,
00062 const Transform & extrinsics);
00063
00064
00065 StereoCameraModel(
00066 double fx,
00067 double fy,
00068 double cx,
00069 double cy,
00070 double baseline,
00071 const Transform & localTransform = Transform::getIdentity(),
00072 const cv::Size & imageSize = cv::Size(0,0));
00073
00074 StereoCameraModel(
00075 const std::string & name,
00076 double fx,
00077 double fy,
00078 double cx,
00079 double cy,
00080 double baseline,
00081 const Transform & localTransform = Transform::getIdentity(),
00082 const cv::Size & imageSize = cv::Size(0,0));
00083 virtual ~StereoCameraModel() {}
00084
00085 bool isValidForProjection() const {return left_.isValidForProjection() && right_.isValidForProjection() && baseline() > 0.0;}
00086 bool isValidForRectification() const {return left_.isValidForRectification() && right_.isValidForRectification();}
00087
00088 void initRectificationMap() {left_.initRectificationMap(); right_.initRectificationMap();}
00089
00090 void setName(const std::string & name);
00091 const std::string & name() const {return name_;}
00092
00093
00094 void setImageSize(const cv::Size & size) {left_.setImageSize(size); right_.setImageSize(size);}
00095
00096 bool load(const std::string & directory, const std::string & cameraName, bool ignoreStereoTransform = true);
00097 bool save(const std::string & directory, bool ignoreStereoTransform = true) const;
00098
00099 double baseline() const {return right_.fx()!=0.0?-right_.Tx()/right_.fx():0.0;}
00100
00101 float computeDepth(float disparity) const;
00102 float computeDisparity(float depth) const;
00103 float computeDisparity(unsigned short depth) const;
00104
00105 const cv::Mat & R() const {return R_;}
00106 const cv::Mat & T() const {return T_;}
00107 const cv::Mat & E() const {return E_;}
00108 const cv::Mat & F() const {return F_;}
00109
00110 void scale(double scale);
00111
00112 void setLocalTransform(const Transform & transform) {left_.setLocalTransform(transform);}
00113 const Transform & localTransform() const {return left_.localTransform();}
00114 Transform stereoTransform() const;
00115
00116 const CameraModel & left() const {return left_;}
00117 const CameraModel & right() const {return right_;}
00118
00119 private:
00120 CameraModel left_;
00121 CameraModel right_;
00122 std::string name_;
00123 cv::Mat R_;
00124 cv::Mat T_;
00125 cv::Mat E_;
00126 cv::Mat F_;
00127 };
00128
00129 }
00130
00131 #endif