47 #include <visp3/core/vpCameraParameters.h>
48 #include <visp3/core/vpDebug.h>
49 #include <visp3/core/vpException.h>
50 #include <visp3/core/vpRotationMatrix.h>
57 const double vpCameraParameters::DEFAULT_PX_PARAMETER = 600.0;
58 const double vpCameraParameters::DEFAULT_PY_PARAMETER = 600.0;
59 const double vpCameraParameters::DEFAULT_U0_PARAMETER = 192.0;
60 const double vpCameraParameters::DEFAULT_V0_PARAMETER = 144.0;
61 const double vpCameraParameters::DEFAULT_KUD_PARAMETER = 0.0;
62 const double vpCameraParameters::DEFAULT_KDU_PARAMETER = 0.0;
64 vpCameraParameters::DEFAULT_PROJ_TYPE =
75 px(DEFAULT_PX_PARAMETER), py(DEFAULT_PY_PARAMETER),
76 u0(DEFAULT_U0_PARAMETER), v0(DEFAULT_V0_PARAMETER),
77 kud(DEFAULT_KUD_PARAMETER), kdu(DEFAULT_KDU_PARAMETER),
79 isFov(false), m_hFovAngle(0), m_vFovAngle(0), fovNormals(),
80 inv_px(1./DEFAULT_PX_PARAMETER), inv_py(1./DEFAULT_PY_PARAMETER),
81 projModel(DEFAULT_PROJ_TYPE)
91 px(DEFAULT_PX_PARAMETER), py(DEFAULT_PY_PARAMETER),
92 u0(DEFAULT_U0_PARAMETER), v0(DEFAULT_V0_PARAMETER),
93 kud(DEFAULT_KUD_PARAMETER), kdu(DEFAULT_KDU_PARAMETER),
95 isFov(false), m_hFovAngle(0), m_vFovAngle(0), fovNormals(),
96 inv_px(1./DEFAULT_PX_PARAMETER), inv_py(1./DEFAULT_PY_PARAMETER),
97 projModel(DEFAULT_PROJ_TYPE)
110 const double cam_u0,
const double cam_v0)
112 px(DEFAULT_PX_PARAMETER), py(DEFAULT_PY_PARAMETER),
113 u0(DEFAULT_U0_PARAMETER), v0(DEFAULT_V0_PARAMETER),
114 kud(DEFAULT_KUD_PARAMETER), kdu(DEFAULT_KDU_PARAMETER),
116 isFov(false), m_hFovAngle(0), m_vFovAngle(0), fovNormals(),
117 inv_px(1./DEFAULT_PX_PARAMETER), inv_py(1./DEFAULT_PY_PARAMETER),
118 projModel(DEFAULT_PROJ_TYPE)
133 const double cam_u0,
const double cam_v0,
134 const double cam_kud,
const double cam_kdu)
136 px(DEFAULT_PX_PARAMETER), py(DEFAULT_PY_PARAMETER),
137 u0(DEFAULT_U0_PARAMETER), v0(DEFAULT_V0_PARAMETER),
138 kud(DEFAULT_KUD_PARAMETER), kdu(DEFAULT_KDU_PARAMETER),
140 isFov(false), m_hFovAngle(0), m_vFovAngle(0), fovNormals(),
141 inv_px(1./DEFAULT_PX_PARAMETER), inv_py(1./DEFAULT_PY_PARAMETER),
142 projModel(DEFAULT_PROJ_TYPE)
153 if (fabs(this->px)<1e-6)
157 "Camera parameter px = 0")) ;
159 if (fabs(this->py)<1e-6)
163 "Camera parameter px = 0")) ;
165 this->inv_px = 1./this->px;
166 this->inv_py = 1./this->py;
207 const double cam_u0,
const double cam_v0)
222 "Camera parameter px = 0")) ;
228 "Camera parameter px = 0")) ;
230 this->inv_px = 1./px;
231 this->inv_py = 1./py;
276 const double cam_u0,
const double cam_v0,
277 const double cam_kud,
const double cam_kdu)
285 this->kud = cam_kud ;
286 this->kdu = cam_kdu ;
292 "Camera parameter px = 0")) ;
298 "Camera parameter px = 0")) ;
300 this->inv_px = 1./px;
301 this->inv_py = 1./py;
343 if( std::fabs(_K[2][2] - 1.0) > std::numeric_limits<double>::epsilon()){
389 px = u0 / tan(hfov/2);
390 py = v0 / tan(vfov/2);
404 projModel = cam.projModel ;
416 m_hFovAngle = cam.m_hFovAngle;
417 m_vFovAngle = cam.m_vFovAngle;
420 fovNormals = cam.fovNormals;
434 if( !isFov && w != width && h != height && w != 0 && h != 0){
435 fovNormals = std::vector<vpColVector>(4);
439 double hFovAngle = atan(((
double)w - u0) * ( 1.0 / px ));
440 double vFovAngle = atan(( v0 ) * ( 1.0 / py ));
441 double minushFovAngle = atan(( u0 ) * ( 1.0 / px ));
442 double minusvFovAngle = atan(((
double)h - v0) * ( 1.0 / py ));
456 nLeft = Rleft * (-n);
476 m_hFovAngle = hFovAngle + minushFovAngle;
477 m_vFovAngle = vFovAngle + minusvFovAngle;
520 K_inv[0][0] = inv_px ;
521 K_inv[1][1] = inv_py ;
522 K_inv[0][2] = -u0*inv_px ;
523 K_inv[1][2] = -v0*inv_py ;
538 std::ios::fmtflags original_flags( std::cout.flags() );
541 std::cout.precision(10);
542 std::cout <<
"Camera parameters for perspective projection without distortion:"
544 std::cout <<
" px = " << px <<
"\t py = "<< py << std::endl ;
545 std::cout <<
" u0 = " << u0 <<
"\t v0 = "<< v0 << std::endl ;
548 std::cout.precision(10);
549 std::cout <<
"Camera parameters for perspective projection with distortion:"
551 std::cout <<
" px = " << px <<
"\t py = "<< py << std::endl ;
552 std::cout <<
" u0 = " << u0 <<
"\t v0 = "<< v0 << std::endl ;
553 std::cout <<
" kud = " << kud << std::endl ;
554 std::cout <<
" kdu = " << kdu << std::endl ;
558 std::cout.flags(original_flags);
571 os <<
"Camera parameters for perspective projection without distortion:"
573 os <<
" px = " << cam.
get_px() <<
"\t py = "<< cam.
get_py()
575 os <<
" u0 = " << cam.
get_u0() <<
"\t v0 = "<< cam.
get_v0()
579 std::ios_base::fmtflags original_flags = os.flags();
581 os <<
"Camera parameters for perspective projection with distortion:"
583 os <<
" px = " << cam.
get_px() <<
"\t py = "<< cam.
get_py()
585 os <<
" u0 = " << cam.
get_u0() <<
"\t v0 = "<< cam.
get_v0()
587 os <<
" kud = " << cam.
get_kud() << std::endl ;
588 os <<
" kdu = " << cam.
get_kdu() << std::endl ;
590 os.flags(original_flags);
vpMatrix get_K_inverse() const
Implementation of a matrix and operations on matrices.
void initFromCalibrationMatrix(const vpMatrix &_K)
void init()
basic initialization with the default parameters
Perspective projection without distortion model.
error that can be emited by ViSP classes.
unsigned int getCols() const
Return the number of columns of the 2D array.
virtual ~vpCameraParameters()
Implementation of a rotation matrix and operations on such kind of matrices.
void initPersProjWithoutDistortion(const double px, const double py, const double u0, const double v0)
vpColVector & normalize()
void initFromFov(const unsigned int &w, const unsigned int &h, const double &hfov, const double &vfov)
vpCameraParametersProjType
Generic class defining intrinsic camera parameters.
friend std::ostream & operator<<(std::ostream &s, const vpArray2D< Type > &A)
unsigned int getRows() const
Return the number of rows of the 2D array.
Perspective projection with distortion model.
Implementation of column vector and the associated operations.
vpCameraParametersProjType get_projModel() const
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)