51 #include <visp/vpCameraParameters.h>
52 #include <visp/vpDebug.h>
53 #include <visp/vpException.h>
54 #include <visp/vpRotationMatrix.h>
58 const double vpCameraParameters::DEFAULT_PX_PARAMETER = 600.0;
59 const double vpCameraParameters::DEFAULT_PY_PARAMETER = 600.0;
60 const double vpCameraParameters::DEFAULT_U0_PARAMETER = 192.0;
61 const double vpCameraParameters::DEFAULT_V0_PARAMETER = 144.0;
62 const double vpCameraParameters::DEFAULT_KUD_PARAMETER = 0.0;
63 const double vpCameraParameters::DEFAULT_KDU_PARAMETER = 0.0;
65 vpCameraParameters::DEFAULT_PROJ_TYPE =
100 const double u0,
const double v0)
120 const double u0,
const double v0,
121 const double kud,
const double kdu)
137 this->projModel = DEFAULT_PROJ_TYPE ;
139 this->px = DEFAULT_PX_PARAMETER ;
140 this->py = DEFAULT_PY_PARAMETER ;
141 this->u0 = DEFAULT_U0_PARAMETER ;
142 this->v0 = DEFAULT_V0_PARAMETER ;
143 this->kud = DEFAULT_KUD_PARAMETER ;
144 this->kdu = DEFAULT_KDU_PARAMETER ;
146 if (fabs(this->px)<1e-6)
150 "Camera parameter px = 0")) ;
152 if (fabs(this->py)<1e-6)
156 "Camera parameter px = 0")) ;
158 this->inv_px = 1./this->px;
159 this->inv_py = 1./this->py;
170 const double py,
const double u0,
const double v0)
185 "Camera parameter px = 0")) ;
191 "Camera parameter px = 0")) ;
193 this->inv_px = 1./px;
194 this->inv_py = 1./py;
207 const double u0,
const double v0,
208 const double kud,
const double kdu)
223 "Camera parameter px = 0")) ;
229 "Camera parameter px = 0")) ;
231 this->inv_px = 1./px;
232 this->inv_py = 1./py;
274 if( std::fabs(_K[2][2] - 1.0) > std::numeric_limits<double>::epsilon()){
287 projModel = cam.projModel ;
299 fovAngleX = cam.fovAngleX;
300 fovAngleY = cam.fovAngleY;
301 fovNormals = cam.fovNormals;
317 if( !isFov && w != width && h != height && w != 0 && h != 0){
318 fovNormals = std::vector<vpColVector>(4);
322 fovAngleX = atan((
double)w / ( 2.0 * px ));
323 fovAngleY = atan((
double)h / ( 2.0 * py ));
337 nLeft = Rleft * (-n);
392 vpERROR_TRACE(
"\n\t getting K matrix in the case of projection \
393 with distortion has no sense");
395 "\n\t getting K matrix in the case of projection \
396 with distortion has no sense"));
424 K_inv[0][0] = inv_px ;
425 K_inv[1][1] = inv_py ;
426 K_inv[0][2] = -u0*inv_px ;
427 K_inv[1][2] = -v0*inv_py ;
432 vpERROR_TRACE(
"\n\t getting K^-1 matrix in the case of projection \
433 with distortion has no sense");
435 "\n\t getting K matrix in the case of projection \
436 with distortion has no sense"));
452 std::cout.precision(10);
453 std::cout <<
"Camera parameters for perspective projection without distortion:"
455 std::cout <<
" px = " << px <<
"\t py = "<< py << std::endl ;
456 std::cout <<
" u0 = " << u0 <<
"\t v0 = "<< v0 << std::endl ;
459 std::cout.precision(10);
460 std::cout <<
"Camera parameters for perspective projection with distortion:"
462 std::cout <<
" px = " << px <<
"\t py = "<< py << std::endl ;
463 std::cout <<
" u0 = " << u0 <<
"\t v0 = "<< v0 << std::endl ;
464 std::cout <<
" kud = " << kud << std::endl ;
465 std::cout <<
" kdu = " << kdu << std::endl ;
481 os <<
"Camera parameters for perspective projection without distortion:"
483 os <<
" px = " << cam.
get_px() <<
"\t py = "<< cam.
get_py()
485 os <<
" u0 = " << cam.
get_u0() <<
"\t v0 = "<< cam.
get_v0()
490 os <<
"Camera parameters for perspective projection with distortion:"
492 os <<
" px = " << cam.
get_px() <<
"\t py = "<< cam.
get_py()
494 os <<
" u0 = " << cam.
get_u0() <<
"\t v0 = "<< cam.
get_v0()
496 os <<
" kud = " << cam.
get_kud() << std::endl ;
497 os <<
" kdu = " << cam.
get_kdu() << std::endl ;
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.
VISP_EXPORT std::ostream & operator<<(std::ostream &os, const vpImagePoint &ip)
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)