stereo_camera_model.h
Go to the documentation of this file.
1 #ifndef IMAGE_GEOMETRY_STEREO_CAMERA_MODEL_H
2 #define IMAGE_GEOMETRY_STEREO_CAMERA_MODEL_H
3 
5 
6 namespace image_geometry {
7 
13 {
14 public:
16 
18 
20 
24  bool fromCameraInfo(const sensor_msgs::CameraInfo& left,
25  const sensor_msgs::CameraInfo& right);
26 
30  bool fromCameraInfo(const sensor_msgs::CameraInfoConstPtr& left,
31  const sensor_msgs::CameraInfoConstPtr& right);
32 
36  const PinholeCameraModel& left() const;
37 
41  const PinholeCameraModel& right() const;
42 
49  std::string tfFrame() const;
50 
54  void projectDisparityTo3d(const cv::Point2d& left_uv_rect, float disparity, cv::Point3d& xyz) const;
55 
62  void projectDisparityImageTo3d(const cv::Mat& disparity, cv::Mat& point_cloud,
63  bool handleMissingValues = false) const;
64  static const double MISSING_Z;
65 
69  const cv::Matx44d& reprojectionMatrix() const;
70 
74  double baseline() const;
75 
81  double getZ(double disparity) const;
82 
88  double getDisparity(double Z) const;
89 
93  bool initialized() const { return left_.initialized() && right_.initialized(); }
94 protected:
96  cv::Matx44d Q_;
97 
98  void updateQ();
99 };
100 
101 
102 /* Trivial inline functions */
103 inline const PinholeCameraModel& StereoCameraModel::left() const { return left_; }
104 inline const PinholeCameraModel& StereoCameraModel::right() const { return right_; }
105 
106 inline std::string StereoCameraModel::tfFrame() const { return left_.tfFrame(); }
107 
108 inline const cv::Matx44d& StereoCameraModel::reprojectionMatrix() const { return Q_; }
109 
110 inline double StereoCameraModel::baseline() const
111 {
113  return -right_.Tx() / right_.fx();
114 }
115 
116 inline double StereoCameraModel::getZ(double disparity) const
117 {
118  assert( initialized() );
119  return -right_.Tx() / (disparity - (left().cx() - right().cx()));
120 }
121 
122 inline double StereoCameraModel::getDisparity(double Z) const
123 {
124  assert( initialized() );
125  return -right_.Tx() / Z + (left().cx() - right().cx()); ;
126 }
127 
128 } //namespace image_geometry
129 
130 #endif
StereoCameraModel & operator=(const StereoCameraModel &other)
const PinholeCameraModel & right() const
Get the right monocular camera model.
bool initialized() const
Returns true if the camera has been initialized.
std::string tfFrame() const
Get the name of the camera coordinate frame in tf.
const PinholeCameraModel & left() const
Get the left monocular camera model.
bool fromCameraInfo(const sensor_msgs::CameraInfo &left, const sensor_msgs::CameraInfo &right)
Set the camera parameters from the sensor_msgs/CameraInfo messages.
double cx() const
Returns the x coordinate of the optical center.
void projectDisparityTo3d(const cv::Point2d &left_uv_rect, float disparity, cv::Point3d &xyz) const
Project a rectified pixel with disparity to a 3d point.
void projectDisparityImageTo3d(const cv::Mat &disparity, cv::Mat &point_cloud, bool handleMissingValues=false) const
Project a disparity image to a 3d point cloud.
std::string tfFrame() const
Get the name of the camera coordinate frame in tf.
bool initialized() const
Returns true if the camera has been initialized.
double Tx() const
Returns the x-translation term of the projection matrix.
double baseline() const
Returns the horizontal baseline in world coordinates.
Simplifies interpreting images geometrically using the parameters from sensor_msgs/CameraInfo.
const cv::Matx44d & reprojectionMatrix() const
Returns the disparity reprojection matrix.
double getZ(double disparity) const
Returns the depth at which a point is observed with a given disparity.
double getDisparity(double Z) const
Returns the disparity observed for a point at depth Z.
double fx() const
Returns the focal length (pixels) in x direction of the rectified image.
Simplifies interpreting stereo image pairs geometrically using the parameters from the left and right...


image_geometry
Author(s): Patrick Mihelich
autogenerated on Thu Jun 6 2019 19:58:02