52 #include <visp3/core/vpCameraParameters.h> 53 #include <visp3/core/vpDebug.h> 54 #include <visp3/core/vpException.h> 55 #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;
73 : px(DEFAULT_PX_PARAMETER), py(DEFAULT_PY_PARAMETER), u0(DEFAULT_U0_PARAMETER), v0(DEFAULT_V0_PARAMETER),
74 kud(DEFAULT_KUD_PARAMETER), kdu(DEFAULT_KDU_PARAMETER), width(0), height(0), isFov(false), m_hFovAngle(0),
75 m_vFovAngle(0), fovNormals(), inv_px(1. / DEFAULT_PX_PARAMETER), inv_py(1. / DEFAULT_PY_PARAMETER),
76 projModel(DEFAULT_PROJ_TYPE)
85 : px(DEFAULT_PX_PARAMETER), py(DEFAULT_PY_PARAMETER), u0(DEFAULT_U0_PARAMETER), v0(DEFAULT_V0_PARAMETER),
86 kud(DEFAULT_KUD_PARAMETER), kdu(DEFAULT_KDU_PARAMETER), width(0), height(0), isFov(false), m_hFovAngle(0),
87 m_vFovAngle(0), fovNormals(), inv_px(1. / DEFAULT_PX_PARAMETER), inv_py(1. / DEFAULT_PY_PARAMETER),
88 projModel(DEFAULT_PROJ_TYPE)
102 : px(DEFAULT_PX_PARAMETER), py(DEFAULT_PY_PARAMETER), u0(DEFAULT_U0_PARAMETER), v0(DEFAULT_V0_PARAMETER),
103 kud(DEFAULT_KUD_PARAMETER), kdu(DEFAULT_KDU_PARAMETER), width(0), height(0), isFov(false), m_hFovAngle(0),
104 m_vFovAngle(0), fovNormals(), inv_px(1. / DEFAULT_PX_PARAMETER), inv_py(1. / DEFAULT_PY_PARAMETER),
105 projModel(DEFAULT_PROJ_TYPE)
120 const double cam_v0,
const double cam_kud,
const double cam_kdu)
121 : px(DEFAULT_PX_PARAMETER), py(DEFAULT_PY_PARAMETER), u0(DEFAULT_U0_PARAMETER), v0(DEFAULT_V0_PARAMETER),
122 kud(DEFAULT_KUD_PARAMETER), kdu(DEFAULT_KDU_PARAMETER), width(0), height(0), isFov(false), m_hFovAngle(0),
123 m_vFovAngle(0), fovNormals(), inv_px(1. / DEFAULT_PX_PARAMETER), inv_py(1. / DEFAULT_PY_PARAMETER),
124 projModel(DEFAULT_PROJ_TYPE)
134 if (fabs(this->px) < 1e-6) {
138 if (fabs(this->py) < 1e-6) {
142 this->inv_px = 1. / this->px;
143 this->inv_py = 1. / this->py;
195 if (fabs(px) < 1e-6) {
199 if (fabs(py) < 1e-6) {
203 this->inv_px = 1. / px;
204 this->inv_py = 1. / py;
250 const double cam_v0,
const double cam_kud,
const double cam_kdu)
261 if (fabs(px) < 1e-6) {
265 if (fabs(py) < 1e-6) {
269 this->inv_px = 1. / px;
270 this->inv_py = 1. / py;
304 if (std::fabs(_K[2][2] - 1.0) > std::numeric_limits<double>::epsilon()) {
349 px = u0 / tan(hfov / 2);
350 py = v0 / tan(vfov / 2);
363 projModel = cam.projModel;
375 m_hFovAngle = cam.m_hFovAngle;
376 m_vFovAngle = cam.m_vFovAngle;
379 fovNormals = cam.fovNormals;
392 if ((!isFov || w != width || h != height) && w != 0 && h != 0) {
393 fovNormals = std::vector<vpColVector>(4);
397 double hFovAngle = atan(((
double)w - u0) * (1.0 / px));
398 double vFovAngle = atan((v0) * (1.0 / py));
399 double minushFovAngle = atan((u0) * (1.0 / px));
400 double minusvFovAngle = atan(((
double)h - v0) * (1.0 / py));
414 nLeft = Rleft * (-n);
434 m_hFovAngle = hFovAngle + minushFovAngle;
435 m_vFovAngle = vFovAngle + minusvFovAngle;
475 K_inv[0][0] = inv_px;
476 K_inv[1][1] = inv_py;
477 K_inv[0][2] = -u0 * inv_px;
478 K_inv[1][2] = -v0 * inv_py;
491 std::ios::fmtflags original_flags(std::cout.flags());
494 std::cout.precision(10);
495 std::cout <<
"Camera parameters for perspective projection without distortion:" << std::endl;
496 std::cout <<
" px = " << px <<
"\t py = " << py << std::endl;
497 std::cout <<
" u0 = " << u0 <<
"\t v0 = " << v0 << std::endl;
500 std::cout.precision(10);
501 std::cout <<
"Camera parameters for perspective projection with distortion:" << std::endl;
502 std::cout <<
" px = " << px <<
"\t py = " << py << std::endl;
503 std::cout <<
" u0 = " << u0 <<
"\t v0 = " << v0 << std::endl;
504 std::cout <<
" kud = " << kud << std::endl;
505 std::cout <<
" kdu = " << kdu << std::endl;
509 std::cout.flags(original_flags);
522 os <<
"Camera parameters for perspective projection without distortion:" << std::endl;
523 os <<
" px = " << cam.
get_px() <<
"\t py = " << cam.
get_py() << std::endl;
524 os <<
" u0 = " << cam.
get_u0() <<
"\t v0 = " << cam.
get_v0() << std::endl;
527 std::ios_base::fmtflags original_flags = os.flags();
529 os <<
"Camera parameters for perspective projection with distortion:" << std::endl;
530 os <<
" px = " << cam.
get_px() <<
"\t py = " << cam.
get_py() << std::endl;
531 os <<
" u0 = " << cam.
get_u0() <<
"\t v0 = " << cam.
get_v0() << std::endl;
532 os <<
" kud = " << cam.
get_kud() << std::endl;
533 os <<
" kdu = " << cam.
get_kdu() << std::endl;
535 os.flags(original_flags);
Implementation of a matrix and operations on matrices.
void initFromCalibrationMatrix(const vpMatrix &_K)
void init()
basic initialization with the default parameters
vpCameraParametersProjType get_projModel() const
error that can be emited by ViSP classes.
unsigned int getRows() const
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)
unsigned int getCols() const
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.
Implementation of column vector and the associated operations.
friend VISP_EXPORT std::ostream & operator<<(std::ostream &os, const vpCameraParameters &cam)
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)
vpMatrix get_K_inverse() const
void computeFov(const unsigned int &w, const unsigned int &h)