Go to the documentation of this file.
30 saveToConfigFile(
"", cfg);
37 out << focalLengthMeters;
38 for (
unsigned int k = 0; k < 5; k++) out << dist[k];
39 out << intrinsicParams;
41 out << nrows << ncols;
51 in >> focalLengthMeters;
53 for (
unsigned int k = 0; k < 5; k++) in >> dist[k];
55 in >> intrinsicParams;
60 in >> __distortionParams;
88 const char* fields[] = {
"K",
"dist",
"f",
"ncols",
"nrows"};
89 mexplus::MxArray params_struct(
90 mexplus::MxArray::Struct(
sizeof(fields) /
sizeof(fields[0]), fields));
93 params_struct.set(
"f", this->focalLengthMeters);
94 params_struct.set(
"ncols", this->ncols);
95 params_struct.set(
"nrows", this->nrows);
96 return params_struct.release();
118 section,
"resolution",
119 format(
"[%u %u]", (
unsigned int)ncols, (
unsigned int)nrows));
127 "[%e %e %e %e %e]", dist[0], dist[1], dist[2], dist[3], dist[4]));
128 if (focalLengthMeters != 0)
129 cfg.
write(section,
"focal_length", focalLengthMeters);
138 vector<uint64_t> out_res;
139 cfg.
read_vector(section,
"resolution", vector<uint64_t>(), out_res,
true);
140 if (out_res.size() != 2)
145 double fx, fy, cx, cy;
151 if (fx < 2.0) fx *= ncols;
152 if (fy < 2.0) fy *= nrows;
153 if (cx < 2.0) cx *= ncols;
154 if (cy < 2.0) cy *= nrows;
156 setIntrinsicParamsFromValues(fx, fy, cx, cy);
160 if (dists.size() != 4 && dists.size() != 5)
164 for (CVectorDouble::Index i = 0; i < dists.size(); i++) dist[i] = dists[i];
167 cfg.
read_double(section,
"focal_length", 0,
false );
175 if (ncols == new_ncols && nrows == new_nrows)
return;
177 ASSERT_(new_nrows > 0 && new_ncols > 0);
179 const double prev_aspect_ratio = ncols / double(nrows);
180 const double new_aspect_ratio = new_ncols / double(new_nrows);
183 std::abs(prev_aspect_ratio - new_aspect_ratio) < 1e-3,
184 "TCamera: Trying to scale camera parameters for a resolution of "
185 "different aspect ratio.");
187 const double K = new_ncols / double(ncols);
193 intrinsicParams(0, 0) *= K;
194 intrinsicParams(1, 1) *= K;
195 intrinsicParams(0, 2) *= K;
196 intrinsicParams(1, 2) *= K;
204 return a.ncols ==
b.ncols &&
a.nrows ==
b.nrows &&
205 a.intrinsicParams ==
b.intrinsicParams &&
a.dist ==
b.dist &&
206 a.focalLengthMeters ==
b.focalLengthMeters;
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())
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
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(),...
double read_double(const std::string §ion, const std::string &name, double defaultValue, bool failIfNotFound=false) const
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...
mxArray * convertToMatlab(const Eigen::EigenBase< Derived > &mat)
Convert vectors, arrays and matrices into Matlab vectors/matrices.
bool operator==(const mrpt::img::TCamera &a, const mrpt::img::TCamera &b)
#define THROW_EXCEPTION(msg)
#define ASSERT_(f)
Defines an assertion mechanism.
dynamic_vector< double > CVectorDouble
Column vector, like Eigen::MatrixXd, but automatically initialized to zeros since construction.
Virtual base class for "archives": classes abstracting I/O streams.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
This class allows loading and storing values and vectors of different types from a configuration text...
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
Structure to hold the parameters of a pinhole camera model.
void saveToConfigFile(const std::string §ion, mrpt::config::CConfigFileBase &cfg) const
Save as a config block:
void getContent(std::string &str) const
Return the current contents of the virtual "config file".
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
A numeric matrix of compile-time fixed size.
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
bool operator!=(const mrpt::img::TCamera &a, const mrpt::img::TCamera &b)
This base provides a set of functions for maths stuff.
#define IMPLEMENTS_MEXPLUS_FROM(complete_type)
GLsizei const GLchar ** string
virtual mxArray * writeToMatlab() const
Introduces a pure virtual method responsible for writing to a mxArray Matlab object,...
This class implements a config file-like interface over a memory-stored string list.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
struct mxArray_tag mxArray
Forward declaration for mxArray (avoid #including as much as possible to speed up compiling)
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 ....
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
GLubyte GLubyte GLubyte a
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |