28 #ifndef CAMERAMODEL_H_ 29 #define CAMERAMODEL_H_ 31 #include <opencv2/opencv.hpp> 47 const std::string & name,
48 const cv::Size & imageSize,
63 const cv::Size & imageSize = cv::Size(0,0));
66 const std::string & name,
73 const cv::Size & imageSize = cv::Size(0,0));
77 void initRectificationMap();
81 bool isValidForReprojection()
const {
return fx()>0.0 && fy()>0.0 && cx()>0.0 && cy()>0.0 && imageWidth()>0 && imageHeight()>0;}
84 return imageSize_.width>0 &&
85 imageSize_.height>0 &&
92 void setName(
const std::string & name) {name_=name;}
93 const std::string &
name()
const {
return name_;}
95 double fx()
const {
return P_.empty()?K_.empty()?0.0:K_.at<
double>(0,0):P_.at<
double>(0,0);}
96 double fy()
const {
return P_.empty()?K_.empty()?0.0:K_.at<
double>(1,1):P_.at<
double>(1,1);}
97 double cx()
const {
return P_.empty()?K_.empty()?0.0:K_.at<
double>(0,2):P_.at<
double>(0,2);}
98 double cy()
const {
return P_.empty()?K_.empty()?0.0:K_.at<
double>(1,2):P_.at<
double>(1,2);}
99 double Tx()
const {
return P_.empty()?0.0:P_.at<
double>(0,3);}
103 cv::Mat
K()
const {
return !P_.empty()?P_.colRange(0,3):K_;}
104 cv::Mat
D()
const {
return P_.empty()&&!D_.empty()?D_:cv::Mat::zeros(1,5,CV_64FC1);}
105 cv::Mat
R()
const {
return R_;}
106 cv::Mat
P()
const {
return P_;}
111 void setImageSize(
const cv::Size & size);
116 bool load(
const std::string & directory,
const std::string & cameraName);
117 bool save(
const std::string & directory)
const;
122 double horizontalFOV()
const;
123 double verticalFOV()
const;
126 cv::Mat rectifyImage(
const cv::Mat & raw,
int interpolation = cv::INTER_LINEAR)
const;
127 cv::Mat rectifyDepth(
const cv::Mat & raw)
const;
130 void project(
float u,
float v,
float depth,
float & x,
float & y,
float & z)
const;
132 void reproject(
float x,
float y,
float z,
float & u,
float & v)
const;
133 void reproject(
float x,
float y,
float z,
int & u,
int & v)
const;
134 bool inFrame(
int u,
int v)
const;
void setLocalTransform(const Transform &transform)
const cv::Size & imageSize() const
const std::string & name() const
Transform localTransform_
bool isRectificationMapInitialized()
bool isValidForRectification() const
bool isValidForReprojection() const
bool isValidForProjection() const
void setName(const std::string &name)
const Transform & localTransform() const