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), fovAngleX(0), fovAngleY(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), fovAngleX(0), fovAngleY(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), fovAngleX(0), fovAngleY(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), fovAngleX(0), fovAngleY(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;
181 const double cam_u0,
const double cam_v0)
196 "Camera parameter px = 0")) ;
202 "Camera parameter px = 0")) ;
204 this->inv_px = 1./px;
205 this->inv_py = 1./py;
218 const double cam_u0,
const double cam_v0,
219 const double cam_kud,
const double cam_kdu)
227 this->kud = cam_kud ;
228 this->kdu = cam_kdu ;
234 "Camera parameter px = 0")) ;
240 "Camera parameter px = 0")) ;
242 this->inv_px = 1./px;
243 this->inv_py = 1./py;
285 if( std::fabs(_K[2][2] - 1.0) > std::numeric_limits<double>::epsilon()){
298 projModel = cam.projModel ;
310 fovAngleX = cam.fovAngleX;
311 fovAngleY = cam.fovAngleY;
312 fovNormals = cam.fovNormals;
328 if( !isFov && w != width && h != height && w != 0 && h != 0){
329 fovNormals = std::vector<vpColVector>(4);
333 fovAngleX = atan((
double)w / ( 2.0 * px ));
334 fovAngleY = atan((
double)h / ( 2.0 * py ));
348 nLeft = Rleft * (-n);
403 vpERROR_TRACE(
"\n\t getting K matrix in the case of projection \
404 with distortion has no sense");
406 "\n\t getting K matrix in the case of projection \
407 with distortion has no sense"));
435 K_inv[0][0] = inv_px ;
436 K_inv[1][1] = inv_py ;
437 K_inv[0][2] = -u0*inv_px ;
438 K_inv[1][2] = -v0*inv_py ;
443 vpERROR_TRACE(
"\n\t getting K^-1 matrix in the case of projection \
444 with distortion has no sense");
446 "\n\t getting K matrix in the case of projection \
447 with distortion has no sense"));
461 std::ios::fmtflags original_flags( std::cout.flags() );
464 std::cout.precision(10);
465 std::cout <<
"Camera parameters for perspective projection without distortion:"
467 std::cout <<
" px = " << px <<
"\t py = "<< py << std::endl ;
468 std::cout <<
" u0 = " << u0 <<
"\t v0 = "<< v0 << std::endl ;
471 std::cout.precision(10);
472 std::cout <<
"Camera parameters for perspective projection with distortion:"
474 std::cout <<
" px = " << px <<
"\t py = "<< py << std::endl ;
475 std::cout <<
" u0 = " << u0 <<
"\t v0 = "<< v0 << std::endl ;
476 std::cout <<
" kud = " << kud << std::endl ;
477 std::cout <<
" kdu = " << kdu << std::endl ;
481 std::cout.flags(original_flags);
494 os <<
"Camera parameters for perspective projection without distortion:"
496 os <<
" px = " << cam.
get_px() <<
"\t py = "<< cam.
get_py()
498 os <<
" u0 = " << cam.
get_u0() <<
"\t v0 = "<< cam.
get_v0()
502 std::ios_base::fmtflags original_flags = os.flags();
504 os <<
"Camera parameters for perspective projection with distortion:"
506 os <<
" px = " << cam.
get_px() <<
"\t py = "<< cam.
get_py()
508 os <<
" u0 = " << cam.
get_u0() <<
"\t v0 = "<< cam.
get_v0()
510 os <<
" kud = " << cam.
get_kud() << std::endl ;
511 os <<
" kdu = " << cam.
get_kdu() << std::endl ;
513 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)
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)