29     setIntrinsicParamsFromValues(0, 0, 0, 0);
    37     saveToConfigFile(
"", cfg);
    44     out << focalLengthMeters;
    46     for (
size_t k = 0; k < dist.size(); k++) 
out << dist[k];
    48     out << fx() << fy() << cx() << cy();
    50     out << nrows << ncols;  
    62             in >> focalLengthMeters;
    65             for (
unsigned int k = 0; k < 5; k++) in >> dist[k];
    67                 for (
unsigned int k = 5; k < 8; k++) in >> dist[k];
    71                 in >> intrinsicParams;
    73                 intrinsicParams(0, 1) = 0;
    74                 intrinsicParams(1, 0) = 0;
    75                 intrinsicParams(2, 0) = 0;
    76                 intrinsicParams(2, 1) = 0;
    77                 intrinsicParams(2, 2) = 1;
    81                 double vfx, vfy, vcx, vcy;
    82                 in >> vfx >> vfy >> vcx >> vcy;
    83                 setIntrinsicParamsFromValues(vfx, vfy, vcx, vcy);
    89                 in >> __distortionParams;
   117     const char* fields[] = {
"K", 
"dist", 
"f", 
"ncols", 
"nrows"};
   118     mexplus::MxArray params_struct(
   119         mexplus::MxArray::Struct(
sizeof(fields) / 
sizeof(fields[0]), fields));
   122     params_struct.set(
"f", this->focalLengthMeters);
   123     params_struct.set(
"ncols", this->ncols);
   124     params_struct.set(
"nrows", this->nrows);
   125     return params_struct.release();
   147         section, 
"resolution",
   148         format(
"[%u %u]", (
unsigned int)ncols, (
unsigned int)nrows));
   156             "[%e %e %e %e %e %e %e %e]", dist[0], dist[1], dist[2], dist[3],
   157             dist[4], dist[5], dist[6], dist[7]));
   158     if (focalLengthMeters != 0)
   159         cfg.
write(section, 
"focal_length", focalLengthMeters);
   168     vector<uint64_t> out_res;
   169     cfg.
read_vector(section, 
"resolution", vector<uint64_t>(), out_res, 
true);
   170     if (out_res.size() != 2)
   175     double fx, fy, cx, cy;
   181     if (fx < 2.0) fx *= ncols;
   182     if (fy < 2.0) fy *= nrows;
   183     if (cx < 2.0) cx *= ncols;
   184     if (cy < 2.0) cy *= nrows;
   186     setIntrinsicParamsFromValues(fx, fy, cx, cy);
   190     if (dists.
size() != 4 && dists.
size() != 5 && dists.
size() != 8)
   197         cfg.
read_double(section, 
"focal_length", 0, 
false );
   205     if (ncols == new_ncols && nrows == new_nrows) 
return;  
   207     ASSERT_(new_nrows > 0 && new_ncols > 0);
   209     const double prev_aspect_ratio = ncols / double(nrows);
   210     const double new_aspect_ratio = new_ncols / double(new_nrows);
   213         std::abs(prev_aspect_ratio - new_aspect_ratio) < 1e-3,
   214         "TCamera: Trying to scale camera parameters for a resolution of "   215         "different aspect ratio.");
   217     const double K = new_ncols / double(ncols);
   223     intrinsicParams(0, 0) *= K;
   224     intrinsicParams(1, 1) *= K;
   225     intrinsicParams(0, 2) *= K;
   226     intrinsicParams(1, 2) *= K;
 This class implements a config file-like interface over a memory-stored string list. 
 
A compile-time fixed-size numeric matrix container. 
 
void scaleToResolution(unsigned int new_ncols, unsigned int new_nrows)
Rescale all the parameters for a new camera resolution (it raises an exception if the aspect ratio is...
 
#define THROW_EXCEPTION(msg)
 
std::string std::string format(std::string_view fmt, ARGS &&... args)
 
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files. 
 
size_type size() const
Get a 2-vector with [NROWS NCOLS] (as in MATLAB command size(x)) 
 
std::string dumpAsText() const
Dumps all the parameters as a multi-line string, with the same format than saveToConfigFile. 
 
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive. 
 
void loadFromConfigFile(const std::string §ion, const mrpt::config::CConfigFileBase &cfg)
Load all the params from a config source, in the format used in saveToConfigFile(), that is: 
 
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations. 
 
mrpt::math::CMatrixDouble33 intrinsicParams
Matrix of intrinsic parameters (containing the focal length and principal point coordinates): ...
 
#define ASSERT_(f)
Defines an assertion mechanism. 
 
double focalLengthMeters
The focal length of the camera, in meters (can be used among 'intrinsicParams' to determine the pixel...
 
This class allows loading and storing values and vectors of different types from a configuration text...
 
This base provides a set of functions for maths stuff. 
 
CVectorDynamic< double > CVectorDouble
 
mxArray * convertVectorToMatlab(const CONTAINER &vec)
Convert std::vector<> or std::deque<> of numeric types into Matlab vectors. 
 
#define IMPLEMENTS_MEXPLUS_FROM(complete_type)
 
Parameters for the Brown-Conrady camera lens distortion model. 
 
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism. 
 
double read_double(const std::string §ion, const std::string &name, double defaultValue, bool failIfNotFound=false) const
 
std::array< double, 8 > dist
[k1 k2 t1 t2 k3 k4 k5 k6] -> k_i: parameters of radial distortion, t_i: parameters of tangential dist...
 
struct mxArray_tag mxArray
Forward declaration for mxArray (avoid #including as much as possible to speed up compiling) ...
 
void write(const std::string §ion, const std::string &name, enum_t value, const int name_padding_width=-1, const int value_padding_width=-1, const std::string &comment=std::string())
 
bool operator==(const mrpt::img::TCamera &a, const mrpt::img::TCamera &b)
 
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object. 
 
Virtual base class for "archives": classes abstracting I/O streams. 
 
mrpt::vision::TStereoCalibResults out
 
virtual mxArray * writeToMatlab() const
Introduces a pure virtual method responsible for writing to a mxArray Matlab object, typically a MATLAB struct whose contents are documented in each derived class. 
 
void saveToConfigFile(const std::string §ion, mrpt::config::CConfigFileBase &cfg) const
Save as a config block: 
 
This file implements matrix/vector text and binary serialization. 
 
void getContent(std::string &str) const
Return the current contents of the virtual "config file". 
 
bool operator!=(const mrpt::img::TCamera &a, const mrpt::img::TCamera &b)
 
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive. 
 
uint32_t ncols
Camera resolution. 
 
mxArray * convertToMatlab(const MATRIX &mat)
Convert vectors, arrays and matrices into Matlab vectors/matrices. 
 
void read_vector(const std::string §ion, const std::string &name, const VECTOR_TYPE &defaultValue, VECTOR_TYPE &outValues, bool failIfNotFound=false) const
Reads a configuration parameter of type vector, stored in the file as a string: "[v1 v2 v3 ...