51 #include <visp/vpCameraParameters.h>
52 #include <visp/vpDebug.h>
53 #include <visp/vpException.h>
54 #include <visp/vpRotationMatrix.h>
61 const double vpCameraParameters::DEFAULT_PX_PARAMETER = 600.0;
62 const double vpCameraParameters::DEFAULT_PY_PARAMETER = 600.0;
63 const double vpCameraParameters::DEFAULT_U0_PARAMETER = 192.0;
64 const double vpCameraParameters::DEFAULT_V0_PARAMETER = 144.0;
65 const double vpCameraParameters::DEFAULT_KUD_PARAMETER = 0.0;
66 const double vpCameraParameters::DEFAULT_KDU_PARAMETER = 0.0;
68 vpCameraParameters::DEFAULT_PROJ_TYPE =
79 px(DEFAULT_PX_PARAMETER), py(DEFAULT_PY_PARAMETER),
80 u0(DEFAULT_U0_PARAMETER), v0(DEFAULT_V0_PARAMETER),
81 kud(DEFAULT_KUD_PARAMETER), kdu(DEFAULT_KDU_PARAMETER),
83 isFov(false), m_hFovAngle(0), m_vFovAngle(0), fovNormals(),
84 inv_px(1./DEFAULT_PX_PARAMETER), inv_py(1./DEFAULT_PY_PARAMETER),
85 projModel(DEFAULT_PROJ_TYPE)
95 px(DEFAULT_PX_PARAMETER), py(DEFAULT_PY_PARAMETER),
96 u0(DEFAULT_U0_PARAMETER), v0(DEFAULT_V0_PARAMETER),
97 kud(DEFAULT_KUD_PARAMETER), kdu(DEFAULT_KDU_PARAMETER),
99 isFov(false), m_hFovAngle(0), m_vFovAngle(0), fovNormals(),
100 inv_px(1./DEFAULT_PX_PARAMETER), inv_py(1./DEFAULT_PY_PARAMETER),
101 projModel(DEFAULT_PROJ_TYPE)
114 const double cam_u0,
const double cam_v0)
116 px(DEFAULT_PX_PARAMETER), py(DEFAULT_PY_PARAMETER),
117 u0(DEFAULT_U0_PARAMETER), v0(DEFAULT_V0_PARAMETER),
118 kud(DEFAULT_KUD_PARAMETER), kdu(DEFAULT_KDU_PARAMETER),
120 isFov(false), m_hFovAngle(0), m_vFovAngle(0), fovNormals(),
121 inv_px(1./DEFAULT_PX_PARAMETER), inv_py(1./DEFAULT_PY_PARAMETER),
122 projModel(DEFAULT_PROJ_TYPE)
137 const double cam_u0,
const double cam_v0,
138 const double cam_kud,
const double cam_kdu)
140 px(DEFAULT_PX_PARAMETER), py(DEFAULT_PY_PARAMETER),
141 u0(DEFAULT_U0_PARAMETER), v0(DEFAULT_V0_PARAMETER),
142 kud(DEFAULT_KUD_PARAMETER), kdu(DEFAULT_KDU_PARAMETER),
144 isFov(false), m_hFovAngle(0), m_vFovAngle(0), fovNormals(),
145 inv_px(1./DEFAULT_PX_PARAMETER), inv_py(1./DEFAULT_PY_PARAMETER),
146 projModel(DEFAULT_PROJ_TYPE)
157 if (fabs(this->px)<1e-6)
161 "Camera parameter px = 0")) ;
163 if (fabs(this->py)<1e-6)
167 "Camera parameter px = 0")) ;
169 this->inv_px = 1./this->px;
170 this->inv_py = 1./this->py;
211 const double cam_u0,
const double cam_v0)
226 "Camera parameter px = 0")) ;
232 "Camera parameter px = 0")) ;
234 this->inv_px = 1./px;
235 this->inv_py = 1./py;
280 const double cam_u0,
const double cam_v0,
281 const double cam_kud,
const double cam_kdu)
289 this->kud = cam_kud ;
290 this->kdu = cam_kdu ;
296 "Camera parameter px = 0")) ;
302 "Camera parameter px = 0")) ;
304 this->inv_px = 1./px;
305 this->inv_py = 1./py;
347 if( std::fabs(_K[2][2] - 1.0) > std::numeric_limits<double>::epsilon()){
393 px = u0 / tan(hfov/2);
394 py = v0 / tan(vfov/2);
408 projModel = cam.projModel ;
420 m_hFovAngle = cam.m_hFovAngle;
421 m_vFovAngle = cam.m_vFovAngle;
424 fovNormals = cam.fovNormals;
438 if( !isFov && w != width && h != height && w != 0 && h != 0){
439 fovNormals = std::vector<vpColVector>(4);
443 double half_hFovAngle = atan((
double)w / ( 2.0 * px ));
444 double half_vFovAngle = atan((
double)h / ( 2.0 * py ));
458 nLeft = Rleft * (-n);
478 m_hFovAngle = 2 * half_hFovAngle;
479 m_vFovAngle = 2 * half_vFovAngle;
516 vpERROR_TRACE(
"\n\t getting K matrix in the case of projection \
517 with distortion has no sense");
519 "\n\t getting K matrix in the case of projection \
520 with distortion has no sense"));
548 K_inv[0][0] = inv_px ;
549 K_inv[1][1] = inv_py ;
550 K_inv[0][2] = -u0*inv_px ;
551 K_inv[1][2] = -v0*inv_py ;
556 vpERROR_TRACE(
"\n\t getting K^-1 matrix in the case of projection \
557 with distortion has no sense");
559 "\n\t getting K matrix in the case of projection \
560 with distortion has no sense"));
574 std::ios::fmtflags original_flags( std::cout.flags() );
577 std::cout.precision(10);
578 std::cout <<
"Camera parameters for perspective projection without distortion:"
580 std::cout <<
" px = " << px <<
"\t py = "<< py << std::endl ;
581 std::cout <<
" u0 = " << u0 <<
"\t v0 = "<< v0 << std::endl ;
584 std::cout.precision(10);
585 std::cout <<
"Camera parameters for perspective projection with distortion:"
587 std::cout <<
" px = " << px <<
"\t py = "<< py << std::endl ;
588 std::cout <<
" u0 = " << u0 <<
"\t v0 = "<< v0 << std::endl ;
589 std::cout <<
" kud = " << kud << std::endl ;
590 std::cout <<
" kdu = " << kdu << std::endl ;
594 std::cout.flags(original_flags);
607 os <<
"Camera parameters for perspective projection without distortion:"
609 os <<
" px = " << cam.
get_px() <<
"\t py = "<< cam.
get_py()
611 os <<
" u0 = " << cam.
get_u0() <<
"\t v0 = "<< cam.
get_v0()
615 std::ios_base::fmtflags original_flags = os.flags();
617 os <<
"Camera parameters for perspective projection with distortion:"
619 os <<
" px = " << cam.
get_px() <<
"\t py = "<< cam.
get_py()
621 os <<
" u0 = " << cam.
get_u0() <<
"\t v0 = "<< cam.
get_v0()
623 os <<
" kud = " << cam.
get_kud() << std::endl ;
624 os <<
" kdu = " << cam.
get_kdu() << std::endl ;
626 os.flags(original_flags);
vpMatrix get_K_inverse() const
Definition of the vpMatrix class.
void initFromCalibrationMatrix(const vpMatrix &_K)
void init()
basic initialization with the default parameters
void resize(const unsigned int nrows, const unsigned int ncols, const bool nullify=true)
Perspective projection without distortion model.
error that can be emited by ViSP classes.
virtual ~vpCameraParameters()
The vpRotationMatrix considers the particular case of a rotation matrix.
void initPersProjWithoutDistortion(const double px, const double py, const double u0, const double v0)
void initFromFov(const unsigned int &w, const unsigned int &h, const double &hfov, const double &vfov)
vpCameraParametersProjType
Generic class defining intrinsic camera parameters.
Perspective projection with distortion model.
Class that provides a data structure for the column vectors as well as a set of operations on these v...
vpCameraParametersProjType get_projModel() const
unsigned int getCols() const
Return the number of columns of the matrix.
unsigned int getRows() const
Return the number of rows of the matrix.
vpColVector & normalize()
Normalise the vector.
vpCameraParameters & operator=(const vpCameraParameters &c)
void initPersProjWithDistortion(const double px, const double py, const double u0, const double v0, const double kud, const double kdu)
void computeFov(const unsigned int &w, const unsigned int &h)