17 #include <mexplus/mxarray.h> 31 : cameraPose(),
image(iplImage)
38 out << cameraPose << cameraParams <<
image << timestamp << sensorLabel;
60 CMatrix intrinsicParams, distortionParams;
61 in >> distortionParams >> intrinsicParams;
63 if (distortionParams.rows() == 1 &&
64 distortionParams.cols() == 5)
67 cameraParams.setDistortionParamsVector(
p);
70 cameraParams.dist.fill(0);
72 cameraParams.intrinsicParams =
73 intrinsicParams.block(0, 0, 3, 3).cast<
double>();
78 if (version >= 1)
in >> timestamp;
82 if (version < 4)
in >> cameraParams.focalLengthMeters;
85 cameraParams.focalLengthMeters = 0.002;
109 const char* fields[] = {
"class",
"ts",
"sensorLabel",
110 "image",
"pose",
"params"};
111 mexplus::MxArray obs_struct(
112 mexplus::MxArray::Struct(
sizeof(fields) /
sizeof(fields[0]), fields));
114 obs_struct.set(
"class", this->GetRuntimeClass()->className);
115 obs_struct.set(
"ts", this->timestamp);
116 obs_struct.set(
"sensorLabel", this->sensorLabel);
117 obs_struct.set(
"image", this->
image);
118 obs_struct.set(
"pose", this->cameraPose);
119 obs_struct.set(
"params", this->cameraParams);
120 return obs_struct.release();
128 image.rectifyImage(out_img, cameraParams);
136 o <<
"Homogeneous matrix for the sensor's 3D pose, relative to robot " 138 o << cameraPose.getHomogeneousMatrixVal<
CMatrixDouble44>() << cameraPose
142 "Focal length: %.03f mm\n", cameraParams.focalLengthMeters * 1000);
144 o <<
"Intrinsic parameters matrix for the camera:" << endl
145 << cameraParams.intrinsicParams.inMatlabFormat() << endl
146 << cameraParams.intrinsicParams << endl;
148 o <<
"Distorsion parameters for the camera: " 149 << cameraParams.getDistortionParamsAsVector() << endl;
151 if (
image.isExternallyStored())
152 o <<
" Image is stored externally in file: " 153 <<
image.getExternalStorageFile() << endl;
156 " Image size: %ux%u pixels\n", (
unsigned int)
image.getWidth(),
157 (
unsigned int)
image.getHeight());
159 o <<
" Channels order: " <<
image.getChannelsOrder() << endl;
162 " Rows are stored in top-bottom order: %s\n",
163 image.isOriginTopLeft() ?
"YES" :
"NO");
Declares a class derived from "CObservation" that encapsules an image from a camera, whose relative pose to robot is also stored.
#define THROW_EXCEPTION(msg)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
void getDescriptionAsText(std::ostream &o) const override
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
void getRectifiedImage(mrpt::img::CImage &out_img) const
Computes the rectified (un-distorted) image, using the embeded distortion parameters.
GLenum GLsizei GLenum GLenum const GLvoid * image
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
A numeric matrix of compile-time fixed size.
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.
This namespace contains representation of robot actions and observations.
#define IMPLEMENTS_MEXPLUS_FROM(complete_type)
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
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) ...
Virtual base class for "archives": classes abstracting I/O streams.
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.
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
This class is a "CSerializable" wrapper for "CMatrixFloat".
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...