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/vpException.h>
50#include <visp3/core/vpMatrix.h>
52#ifdef VISP_HAVE_NLOHMANN_JSON
53#include VISP_NLOHMANN_JSON(json.hpp)
321 } vpCameraParametersProjType;
327 vpCameraParameters(
double px,
double py,
double u0,
double v0,
double kud,
double kdu);
328 vpCameraParameters(
double px,
double py,
double u0,
double v0,
const std::vector<double> &distortion_coefficients);
337 void initFromCalibrationMatrix(
const vpMatrix &K);
338 void initFromFov(
const unsigned int &w,
const unsigned int &h,
const double &hfov,
const double &vfov);
339 void initPersProjWithoutDistortion(
double px,
double py,
double u0,
double v0);
340 void initPersProjWithDistortion(
double px,
double py,
double u0,
double v0,
double kud,
double kdu);
341 void initProjWithKannalaBrandtDistortion(
double px,
double py,
double u0,
double v0,
342 const std::vector<double> &distortion_coefficients);
353 void computeFov(
const unsigned int &w,
const unsigned int &h);
365 std::cout <<
"Warning: The FOV is not computed, getHorizontalFovAngle() won't be significant." << std::endl;
380 std::cout <<
"Warning: The FOV is not computed, getVerticalFovAngle() won't be significant." << std::endl;
400 std::cout <<
"Warning: The FOV is not computed, getFovNormals() won't be significant." << std::endl;
405 inline double get_px()
const {
return m_px; }
408 inline double get_py()
const {
return m_py; }
409 inline double get_u0()
const {
return m_u0; }
410 inline double get_v0()
const {
return m_v0; }
411 inline double get_kud()
const {
return m_kud; }
412 inline double get_kdu()
const {
return m_kdu; }
420 void printParameters();
421 friend VISP_EXPORT std::ostream &operator<<(std::ostream &os,
const vpCameraParameters &cam);
424 static const double DEFAULT_U0_PARAMETER;
425 static const double DEFAULT_V0_PARAMETER;
426 static const double DEFAULT_PX_PARAMETER;
427 static const double DEFAULT_PY_PARAMETER;
428 static const double DEFAULT_KUD_PARAMETER;
429 static const double DEFAULT_KDU_PARAMETER;
430 static const vpCameraParametersProjType DEFAULT_PROJ_TYPE;
436 std::vector<double> m_dist_coefs;
438 unsigned int m_width;
439 unsigned int m_height;
443 std::vector<vpColVector> m_fovNormals;
445 double m_inv_px, m_inv_py;
447 vpCameraParametersProjType m_projModel;
448#ifdef VISP_HAVE_NLOHMANN_JSON
454#ifdef VISP_HAVE_NLOHMANN_JSON
456#if defined(__clang__)
459# pragma clang diagnostic push
460# pragma clang diagnostic ignored "-Wexit-time-destructors"
463#include VISP_NLOHMANN_JSON(json.hpp)
470#if defined(__clang__)
471# pragma clang diagnostic pop
486 j[
"model"] = cam.m_projModel;
488 switch (cam.m_projModel) {
491 j[
"kud"] = cam.m_kud;
492 j[
"kdu"] = cam.m_kdu;
497 j[
"dist_coeffs"] = cam.m_dist_coefs;
536 const double px = j.at(
"px").get<
double>();
537 const double py = j.at(
"py").get<
double>();
538 const double u0 = j.at(
"u0").get<
double>();
539 const double v0 = j.at(
"v0").get<
double>();
545 cam.initPersProjWithoutDistortion(px, py, u0, v0);
550 const double kud = j.at(
"kud").get<
double>();
551 const double kdu = j.at(
"kdu").get<
double>();
552 cam.initPersProjWithDistortion(px, py, u0, v0, kud, kdu);
557 const std::vector<double> coeffs = j.at(
"dist_coeffs").get<std::vector<double>>();
558 cam.initProjWithKannalaBrandtDistortion(px, py, u0, v0, coeffs);
Generic class defining intrinsic camera parameters.
bool isFovComputed() const
vpCameraParametersProjType
@ perspectiveProjWithDistortion
Perspective projection with distortion model.
@ ProjWithKannalaBrandtDistortion
Projection with Kannala-Brandt distortion model.
@ perspectiveProjWithoutDistortion
Perspective projection without distortion model.
friend void to_json(nlohmann::json &j, const vpCameraParameters &cam)
Converts camera parameters into a JSON representation.
friend class vpMeterPixelConversion
double getHorizontalFovAngle() const
friend class vpPixelMeterConversion
std::vector< double > getKannalaBrandtDistortionCoefficients() const
std::vector< vpColVector > getFovNormals() const
double getVerticalFovAngle() const
double get_px_inverse() const
double get_py_inverse() const
vpCameraParametersProjType get_projModel() const
friend void from_json(const nlohmann::json &j, vpCameraParameters &cam)
Deserialize a JSON object into camera parameters. The minimal required properties are:
error that can be emitted by ViSP classes.
Implementation of a matrix and operations on matrices.