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 #include "exports.h"
6 
7 namespace image_geometry {
8 
14 {
15 public:
17 
19 
20  StereoCameraModel& operator=(const StereoCameraModel& other);
21 
25  bool fromCameraInfo(const sensor_msgs::CameraInfo& left,
26  const sensor_msgs::CameraInfo& right);
27 
31  bool fromCameraInfo(const sensor_msgs::CameraInfoConstPtr& left,
32  const sensor_msgs::CameraInfoConstPtr& right);
33 
37  const PinholeCameraModel& left() const;
38 
42  const PinholeCameraModel& right() const;
43 
50  std::string tfFrame() const;
51 
55  void projectDisparityTo3d(const cv::Point2d& left_uv_rect, float disparity, cv::Point3d& xyz) const;
56 
63  void projectDisparityImageTo3d(const cv::Mat& disparity, cv::Mat& point_cloud,
64  bool handleMissingValues = false) const;
65  static const double MISSING_Z;
66 
70  const cv::Matx44d& reprojectionMatrix() const;
71 
75  double baseline() const;
76 
82  double getZ(double disparity) const;
83 
89  double getDisparity(double Z) const;
90 
94  bool initialized() const { return left_.initialized() && right_.initialized(); }
95 protected:
97  cv::Matx44d Q_;
98 
99  void updateQ();
100 };
101 
102 
103 /* Trivial inline functions */
104 inline const PinholeCameraModel& StereoCameraModel::left() const { return left_; }
105 inline const PinholeCameraModel& StereoCameraModel::right() const { return right_; }
106 
107 inline std::string StereoCameraModel::tfFrame() const { return left_.tfFrame(); }
108 
109 inline const cv::Matx44d& StereoCameraModel::reprojectionMatrix() const { return Q_; }
110 
111 inline double StereoCameraModel::baseline() const
112 {
114  return -right_.Tx() / right_.fx();
115 }
116 
117 inline double StereoCameraModel::getZ(double disparity) const
118 {
119  assert( initialized() );
120  return -right_.Tx() / (disparity - (left().cx() - right().cx()));
121 }
122 
123 inline double StereoCameraModel::getDisparity(double Z) const
124 {
125  assert( initialized() );
126  return -right_.Tx() / Z + (left().cx() - right().cx()); ;
127 }
128 
129 } //namespace image_geometry
130 
131 #endif
image_geometry::StereoCameraModel::tfFrame
std::string tfFrame() const
Get the name of the camera coordinate frame in tf.
Definition: stereo_camera_model.h:107
pinhole_camera_model.h
image_geometry::PinholeCameraModel
Simplifies interpreting images geometrically using the parameters from sensor_msgs/CameraInfo.
Definition: pinhole_camera_model.h:24
image_geometry::StereoCameraModel::initialized
bool initialized() const
Returns true if the camera has been initialized.
Definition: stereo_camera_model.h:94
image_geometry
Definition: pinhole_camera_model.h:12
image_geometry::StereoCameraModel::getDisparity
double getDisparity(double Z) const
Returns the disparity observed for a point at depth Z.
Definition: stereo_camera_model.h:123
image_geometry::PinholeCameraModel::tfFrame
std::string tfFrame() const
Get the name of the camera coordinate frame in tf.
Definition: pinhole_camera_model.h:302
image_geometry::PinholeCameraModel::Tx
double Tx() const
Returns the x-translation term of the projection matrix.
Definition: pinhole_camera_model.h:326
image_geometry::StereoCameraModel::Q_
cv::Matx44d Q_
Definition: stereo_camera_model.h:97
image_geometry::PinholeCameraModel::fx
double fx() const
Returns the focal length (pixels) in x direction of the rectified image.
Definition: pinhole_camera_model.h:322
exports.h
image_geometry::StereoCameraModel
Simplifies interpreting stereo image pairs geometrically using the parameters from the left and right...
Definition: stereo_camera_model.h:13
image_geometry::StereoCameraModel::right
const PinholeCameraModel & right() const
Get the right monocular camera model.
Definition: stereo_camera_model.h:105
image_geometry::StereoCameraModel::getZ
double getZ(double disparity) const
Returns the depth at which a point is observed with a given disparity.
Definition: stereo_camera_model.h:117
image_geometry::StereoCameraModel::MISSING_Z
static const double MISSING_Z
Definition: stereo_camera_model.h:65
image_geometry::StereoCameraModel::reprojectionMatrix
const cv::Matx44d & reprojectionMatrix() const
Returns the disparity reprojection matrix.
Definition: stereo_camera_model.h:109
image_geometry::StereoCameraModel::right_
PinholeCameraModel right_
Definition: stereo_camera_model.h:96
IMAGE_GEOMETRY_DECL
#define IMAGE_GEOMETRY_DECL
Definition: exports.h:15
image_geometry::StereoCameraModel::left_
PinholeCameraModel left_
Definition: stereo_camera_model.h:96
image_geometry::PinholeCameraModel::cx
double cx() const
Returns the x coordinate of the optical center.
Definition: pinhole_camera_model.h:324
image_geometry::StereoCameraModel::baseline
double baseline() const
Returns the horizontal baseline in world coordinates.
Definition: stereo_camera_model.h:111
image_geometry::StereoCameraModel::left
const PinholeCameraModel & left() const
Get the left monocular camera model.
Definition: stereo_camera_model.h:104


image_geometry
Author(s): Patrick Mihelich
autogenerated on Mon Oct 3 2022 02:45:58