41 #ifndef VP_CAMERA_PARAMETERS_H
42 #define VP_CAMERA_PARAMETERS_H
47 #include <visp3/core/vpConfig.h>
48 #include <visp3/core/vpColVector.h>
49 #include <visp3/core/vpMatrix.h>
51 #ifdef VISP_HAVE_NLOHMANN_JSON
52 #include VISP_NLOHMANN_JSON(json.hpp)
319 ProjWithKannalaBrandtDistortion
320 } vpCameraParametersProjType;
326 vpCameraParameters(
double px,
double py,
double u0,
double v0,
double kud,
double kdu);
327 vpCameraParameters(
double px,
double py,
double u0,
double v0,
const std::vector<double> &distortion_coefficients);
336 void initFromCalibrationMatrix(
const vpMatrix &_K);
337 void initFromFov(
const unsigned int &w,
const unsigned int &h,
const double &hfov,
const double &vfov);
338 void initPersProjWithoutDistortion(
double px,
double py,
double u0,
double v0);
339 void initPersProjWithDistortion(
double px,
double py,
double u0,
double v0,
double kud,
double kdu);
340 void initProjWithKannalaBrandtDistortion(
double px,
double py,
double u0,
double v0,
341 const std::vector<double> &distortion_coefficients);
352 void computeFov(
const unsigned int &w,
const unsigned int &h);
364 std::cout <<
"Warning: The FOV is not computed, getHorizontalFovAngle() won't be significant." << std::endl;
379 std::cout <<
"Warning: The FOV is not computed, getVerticalFovAngle() won't be significant." << std::endl;
399 std::cout <<
"Warning: The FOV is not computed, getFovNormals() won't be significant." << std::endl;
404 inline double get_px()
const {
return m_px; }
407 inline double get_py()
const {
return m_py; }
408 inline double get_u0()
const {
return m_u0; }
409 inline double get_v0()
const {
return m_v0; }
410 inline double get_kud()
const {
return m_kud; }
411 inline double get_kdu()
const {
return m_kdu; }
419 void printParameters();
420 friend VISP_EXPORT std::ostream &operator<<(std::ostream &os,
const vpCameraParameters &cam);
423 static const double DEFAULT_U0_PARAMETER;
424 static const double DEFAULT_V0_PARAMETER;
425 static const double DEFAULT_PX_PARAMETER;
426 static const double DEFAULT_PY_PARAMETER;
427 static const double DEFAULT_KUD_PARAMETER;
428 static const double DEFAULT_KDU_PARAMETER;
429 static const vpCameraParametersProjType DEFAULT_PROJ_TYPE;
435 std::vector<double> m_dist_coefs;
437 unsigned int m_width;
438 unsigned int m_height;
442 std::vector<vpColVector> m_fovNormals;
444 double m_inv_px, m_inv_py;
446 vpCameraParametersProjType m_projModel;
447 #ifdef VISP_HAVE_NLOHMANN_JSON
453 #ifdef VISP_HAVE_NLOHMANN_JSON
454 #include VISP_NLOHMANN_JSON(json.hpp)
473 j[
"model"] = cam.m_projModel;
475 switch (cam.m_projModel) {
478 j[
"kud"] = cam.m_kud;
479 j[
"kdu"] = cam.m_kdu;
484 j[
"dist_coeffs"] = cam.m_dist_coefs;
522 const double px = j.at(
"px").get<
double>();
523 const double py = j.at(
"py").get<
double>();
524 const double u0 = j.at(
"u0").get<
double>();
525 const double v0 = j.at(
"v0").get<
double>();
536 const double kud = j.at(
"kud").get<
double>();
537 const double kdu = j.at(
"kdu").get<
double>();
543 const std::vector<double> coeffs = j.at(
"dist_coeffs").get<std::vector<double>>();
Generic class defining intrinsic camera parameters.
void initPersProjWithoutDistortion(double px, double py, double u0, double v0)
std::vector< double > getKannalaBrandtDistortionCoefficients() const
bool isFovComputed() const
vpCameraParametersProjType
@ perspectiveProjWithDistortion
Perspective projection with distortion model.
@ ProjWithKannalaBrandtDistortion
Projection with Kannala-Brandt distortion model.
@ perspectiveProjWithoutDistortion
Perspective projection without distortion model.
std::vector< vpColVector > getFovNormals() const
void initPersProjWithDistortion(double px, double py, double u0, double v0, double kud, double kdu)
double getHorizontalFovAngle() const
double getVerticalFovAngle() const
double get_px_inverse() const
double get_py_inverse() const
vpCameraParametersProjType get_projModel() const
void initProjWithKannalaBrandtDistortion(double px, double py, double u0, double v0, const std::vector< double > &distortion_coefficients)
Implementation of a matrix and operations on matrices.