16 #include <Eigen/Dense> 20 #include <mexplus/mxarray.h> 34 out << cameraPose << cameraParams << image << timestamp << sensorLabel;
56 CMatrixF intrinsicParams, distortionParams;
57 in >> distortionParams >> intrinsicParams;
59 if (distortionParams.
rows() == 1 &&
60 distortionParams.
cols() == 5)
64 cameraParams.setDistortionParamsVector(p);
67 cameraParams.dist.
fill(0);
70 intrinsicParams.block<3, 3>(0, 0).cast<
double>());
75 if (version >= 1) in >> timestamp;
79 if (version < 4) in >> cameraParams.focalLengthMeters;
82 cameraParams.focalLengthMeters = 0.002;
106 const char* fields[] = {
"class",
"ts",
"sensorLabel",
107 "image",
"pose",
"params"};
108 mexplus::MxArray obs_struct(
109 mexplus::MxArray::Struct(
sizeof(fields) /
sizeof(fields[0]), fields));
111 obs_struct.set(
"class", this->GetRuntimeClass()->className);
113 obs_struct.set(
"sensorLabel", this->sensorLabel);
114 obs_struct.set(
"image", this->image);
115 obs_struct.set(
"pose", this->cameraPose);
116 obs_struct.set(
"params", this->cameraParams);
117 return obs_struct.release();
125 image.undistort(out_img, cameraParams);
133 o <<
"Homogeneous matrix for the sensor's 3D pose, relative to robot " 135 o << cameraPose.getHomogeneousMatrixVal<
CMatrixDouble44>() << cameraPose
139 "Focal length: %.03f mm\n", cameraParams.focalLengthMeters * 1000);
141 o <<
"Intrinsic parameters matrix for the camera:" 143 << cameraParams.intrinsicParams.inMatlabFormat() <<
"\n" 144 << cameraParams.intrinsicParams <<
"\n";
146 o <<
"Distorsion parameters for the camera: " 147 << cameraParams.getDistortionParamsAsVector() <<
"\n";
149 if (image.isExternallyStored())
150 o <<
" Image is stored externally in file: " 151 << image.getExternalStorageFile() <<
"\n";
153 if (!image.isEmpty())
156 " Image size: %ux%u pixels\n", (
unsigned int)image.getWidth(),
157 (
unsigned int)image.getHeight());
159 o <<
" Channels order: " << image.getChannelsOrder() <<
"\n";
162 " Rows are stored in top-bottom order: %s\n",
163 image.isOriginTopLeft() ?
"YES" :
"NO");
static double toDouble(const time_point t) noexcept
Converts a timestamp to a UNIX time_t-like number, with fractional part.
Declares a class derived from "CObservation" that encapsules an image from a camera, whose relative pose to robot is also stored.
A compile-time fixed-size numeric matrix container.
#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.
void fill(const Scalar &val)
void getDescriptionAsText(std::ostream &o) const override
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
CMatrixDynamic< double > cast_double() const
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
CMatrixFixed< double, 3, 3 > CMatrixDouble33
This base provides a set of functions for maths stuff.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
void getUndistortedImage(mrpt::img::CImage &out_img) const
Computes the un-distorted image, using the embeded camera intrinsic & distortion parameters.
This namespace contains representation of robot actions and observations.
#define IMPLEMENTS_MEXPLUS_FROM(complete_type)
void load() const override
Makes sure all images and other fields which may be externally stored are loaded in memory...
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
size_type rows() const
Number of rows in the matrix.
size_type cols() const
Number of columns in the matrix.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
struct mxArray_tag mxArray
Forward declaration for mxArray (avoid #including as much as possible to speed up compiling) ...
This class is a "CSerializable" wrapper for "CMatrixFloat".
Virtual base class for "archives": classes abstracting I/O streams.
mrpt::vision::TStereoCalibResults out
Declares a class that represents any robot's observation.
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.
A class for storing images as grayscale or RGB bitmaps.
virtual void getDescriptionAsText(std::ostream &o) const
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...