1 #ifndef IMAGE_GEOMETRY_PINHOLE_CAMERA_MODEL_H 2 #define IMAGE_GEOMETRY_PINHOLE_CAMERA_MODEL_H 4 #include <sensor_msgs/CameraInfo.h> 5 #include <opencv2/core/core.hpp> 6 #include <opencv2/imgproc/imgproc.hpp> 7 #include <opencv2/calib3d/calib3d.hpp> 16 Exception(
const std::string& description) :
std::runtime_error(description) {}
36 bool fromCameraInfo(
const sensor_msgs::CameraInfo& msg);
41 bool fromCameraInfo(
const sensor_msgs::CameraInfoConstPtr& msg);
46 std::string tfFrame()
const;
59 cv::Size fullResolution()
const;
68 cv::Size reducedResolution()
const;
70 cv::Point2d toFullResolution(
const cv::Point2d& uv_reduced)
const;
72 cv::Rect toFullResolution(
const cv::Rect& roi_reduced)
const;
74 cv::Point2d toReducedResolution(
const cv::Point2d& uv_full)
const;
76 cv::Rect toReducedResolution(
const cv::Rect& roi_full)
const;
81 cv::Rect rawRoi()
const;
86 cv::Rect rectifiedRoi()
const;
96 cv::Point2d project3dToPixel(
const cv::Point3d& xyz)
const;
109 cv::Point3d projectPixelTo3dRay(
const cv::Point2d& uv_rect)
const;
114 void rectifyImage(
const cv::Mat& raw, cv::Mat& rectified,
115 int interpolation = cv::INTER_LINEAR)
const;
120 void unrectifyImage(
const cv::Mat& rectified, cv::Mat& raw,
121 int interpolation = cv::INTER_LINEAR)
const;
126 cv::Point2d rectifyPoint(
const cv::Point2d& uv_raw)
const;
131 cv::Point2d unrectifyPoint(
const cv::Point2d& uv_rect)
const;
136 cv::Rect rectifyRoi(
const cv::Rect& roi_raw)
const;
141 cv::Rect unrectifyRoi(
const cv::Rect& roi_rect)
const;
146 const sensor_msgs::CameraInfo& cameraInfo()
const;
151 const cv::Matx33d& intrinsicMatrix()
const;
156 const cv::Mat_<double>& distortionCoeffs()
const;
161 const cv::Matx33d& rotationMatrix()
const;
166 const cv::Matx34d& projectionMatrix()
const;
171 const cv::Matx33d& fullIntrinsicMatrix()
const;
176 const cv::Matx34d& fullProjectionMatrix()
const;
211 uint32_t binningX()
const;
216 uint32_t binningY()
const;
226 double getDeltaU(
double deltaX,
double Z)
const;
236 double getDeltaV(
double deltaY,
double Z)
const;
246 double getDeltaX(
double deltaU,
double Z)
const;
256 double getDeltaY(
double deltaV,
double Z)
const;
274 #ifdef BOOST_SHARED_PTR_HPP_INCLUDED 277 std::shared_ptr<Cache>
cache_;
280 void initRectificationMaps()
const;
289 assert( initialized() );
290 return cam_info_.header.frame_id;
295 assert( initialized() );
296 return cam_info_.header.stamp;
319 assert( initialized() );
320 return fx() * deltaX / Z;
325 assert( initialized() );
326 return fy() * deltaY / Z;
331 assert( initialized() );
332 return Z * deltaU / fx();
337 assert( initialized() );
338 return Z * deltaV / fy();
const cv::Matx33d & intrinsicMatrix() const
Returns the original camera matrix.
bool initialized() const
Returns true if the camera has been initialized.
double Ty() const
Returns the y-translation term of the projection matrix.
const sensor_msgs::CameraInfo & cameraInfo() const
Returns the camera info message held internally.
double cx() const
Returns the x coordinate of the optical center.
double getDeltaY(double deltaV, double Z) const
Compute delta Y, given Z in Cartesian space and delta v in pixels.
double cy() const
Returns the y coordinate of the optical center.
uint32_t binningX() const
Returns the number of columns in each bin.
std::string tfFrame() const
Get the name of the camera coordinate frame in tf.
sensor_msgs::CameraInfo cam_info_
const cv::Matx33d & rotationMatrix() const
Returns the rotation matrix.
double Tx() const
Returns the x-translation term of the projection matrix.
ros::Time stamp() const
Get the time stamp associated with this camera model.
double getDeltaU(double deltaX, double Z) const
Compute delta u, given Z and delta X in Cartesian space.
const cv::Matx34d & fullProjectionMatrix() const
Returns the projection matrix for full resolution.
double getDeltaX(double deltaU, double Z) const
Compute delta X, given Z in Cartesian space and delta u in pixels.
std::shared_ptr< Cache > cache_
Simplifies interpreting images geometrically using the parameters from sensor_msgs/CameraInfo.
double fy() const
Returns the focal length (pixels) in y direction of the rectified image.
uint32_t binningY() const
Returns the number of rows in each bin.
double getDeltaV(double deltaY, double Z) const
Compute delta v, given Z and delta Y in Cartesian space.
const cv::Matx34d & projectionMatrix() const
Returns the projection matrix.
const cv::Mat_< double > & distortionCoeffs() const
Returns the distortion coefficients.
const cv::Matx33d & fullIntrinsicMatrix() const
Returns the original camera matrix for full resolution.
double fx() const
Returns the focal length (pixels) in x direction of the rectified image.
Exception(const std::string &description)
Simplifies interpreting stereo image pairs geometrically using the parameters from the left and right...