43 #ifndef vpCameraParameters_H
44 #define vpCameraParameters_H
48 #include <visp3/core/vpColVector.h>
49 #include <visp3/core/vpConfig.h>
50 #include <visp3/core/vpDebug.h>
51 #include <visp3/core/vpMatrix.h>
53 #ifdef VISP_HAVE_NLOHMANN_JSON
54 #include<nlohmann/json.hpp>
315 ProjWithKannalaBrandtDistortion
316 } vpCameraParametersProjType;
322 vpCameraParameters(
double px,
double py,
double u0,
double v0,
double kud,
double kdu);
323 vpCameraParameters(
double px,
double py,
double u0,
double v0,
const std::vector<double> &distortion_coefficients);
332 void initFromCalibrationMatrix(
const vpMatrix &_K);
333 void initFromFov(
const unsigned int &w,
const unsigned int &h,
const double &hfov,
const double &vfov);
334 void initPersProjWithoutDistortion(
double px,
double py,
double u0,
double v0);
335 void initPersProjWithDistortion(
double px,
double py,
double u0,
double v0,
double kud,
double kdu);
336 void initProjWithKannalaBrandtDistortion(
double px,
double py,
double u0,
double v0,
337 const std::vector<double> &distortion_coefficients);
348 void computeFov(
const unsigned int &w,
const unsigned int &h);
360 vpTRACE(
"Warning: The FOV is not computed, getHorizontalFovAngle() "
361 "won't be significant.");
376 vpTRACE(
"Warning: The FOV is not computed, getVerticalFovAngle() won't "
397 vpTRACE(
"Warning: The FOV is not computed, getFovNormals() won't be "
403 inline double get_px()
const {
return px; }
406 inline double get_py()
const {
return py; }
407 inline double get_u0()
const {
return u0; }
408 inline double get_v0()
const {
return v0; }
418 void printParameters();
419 friend VISP_EXPORT std::ostream &operator<<(std::ostream &os,
const vpCameraParameters &cam);
422 static const double DEFAULT_U0_PARAMETER;
423 static const double DEFAULT_V0_PARAMETER;
424 static const double DEFAULT_PX_PARAMETER;
425 static const double DEFAULT_PY_PARAMETER;
426 static const double DEFAULT_KUD_PARAMETER;
427 static const double DEFAULT_KDU_PARAMETER;
428 static const vpCameraParametersProjType DEFAULT_PROJ_TYPE;
434 std::vector<double> m_dist_coefs;
441 std::vector<vpColVector> fovNormals;
443 double inv_px, inv_py;
445 vpCameraParametersProjType projModel;
446 #ifdef VISP_HAVE_NLOHMANN_JSON
452 #ifdef VISP_HAVE_NLOHMANN_JSON
453 #include<nlohmann/json.hpp>
472 j[
"model"] = cam.projModel;
474 switch (cam.projModel) {
483 j[
"dist_coeffs"] = cam.m_dist_coefs;
519 const double px = j.at(
"px").get<
double>();
520 const double py = j.at(
"py").get<
double>();
521 const double u0 = j.at(
"u0").get<
double>();
522 const double v0 = j.at(
"v0").get<
double>();
533 const double kud = j.at(
"kud").get<
double>();
534 const double kdu = j.at(
"kdu").get<
double>();
540 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.