16 #include <mexplus/mxarray.h> 32 void* iplImageLeft,
void* iplImageRight,
void* iplImageDisparity,
37 hasImageDisparity(iplImageDisparity !=
nullptr),
38 hasImageRight(iplImageRight !=
nullptr)
41 ownMemory ? imageLeft.setFromIplImage(iplImageLeft)
42 : imageLeft.loadFromIplImage(iplImageLeft);
44 ownMemory ? imageRight.setFromIplImage(iplImageRight)
45 : imageRight.loadFromIplImage(iplImageRight);
46 if (iplImageDisparity)
47 ownMemory ? imageDisparity.setFromIplImage(iplImageDisparity)
48 : imageDisparity.loadFromIplImage(iplImageDisparity);
56 out << cameraPose << leftCamera << rightCamera << imageLeft;
57 out << hasImageDisparity << hasImageRight;
58 if (hasImageRight) out << imageRight;
59 if (hasImageDisparity) out << imageDisparity;
61 out << rightCameraPose;
72 in >> cameraPose >> leftCamera >> rightCamera >> imageLeft;
73 in >> hasImageDisparity >> hasImageRight;
74 if (hasImageRight)
in >> imageRight;
75 if (hasImageDisparity)
in >> imageDisparity;
77 in >> rightCameraPose;
91 hasImageDisparity =
false;
102 in >> cameraPose >> leftCamera >> rightCamera;
108 leftCamera.intrinsicParams =
114 in >> imageLeft >> imageRight;
129 in >> rightCameraPose;
136 if (version >= 3 && version < 5)
140 leftCamera.focalLengthMeters = rightCamera.focalLengthMeters =
143 else if (version < 3)
144 leftCamera.focalLengthMeters = rightCamera.focalLengthMeters =
170 const char* fields[] = {
"class",
"ts",
"sensorLabel",
"imageL",
171 "imageR",
"poseL",
"poseLR",
"poseR",
172 "paramsL",
"paramsR"};
173 mexplus::MxArray obs_struct(
174 mexplus::MxArray::Struct(
sizeof(fields) /
sizeof(fields[0]), fields));
176 obs_struct.set(
"class", this->GetRuntimeClass()->className);
177 obs_struct.set(
"ts", this->timestamp);
178 obs_struct.set(
"sensorLabel", this->sensorLabel);
179 obs_struct.set(
"imageL", this->imageLeft);
180 obs_struct.set(
"imageR", this->imageRight);
181 obs_struct.set(
"poseL", this->cameraPose);
182 obs_struct.set(
"poseR", this->cameraPose + this->rightCameraPose);
183 obs_struct.set(
"poseLR", this->rightCameraPose);
184 obs_struct.set(
"paramsL", this->leftCamera);
185 obs_struct.set(
"paramsR", this->rightCamera);
186 return obs_struct.release();
220 leftCamera.dist.begin(), leftCamera.dist.end(),
221 [](
auto v) {
return v == 0; });
248 o <<
"Homogeneous matrix for the sensor's 3D pose, relative to robot " 251 <<
"Camera pose: " << cameraPose << endl
252 <<
"Camera pose (YPR): " <<
CPose3D(cameraPose) << endl
256 getStereoCameraParams(stParams);
259 o <<
"Right camera pose wrt left camera (YPR):" << endl
262 if (imageLeft.isExternallyStored())
263 o <<
" Left image is stored externally in file: " 264 << imageLeft.getExternalStorageFile() << endl;
269 if (imageRight.isExternallyStored())
270 o <<
" is stored externally in file: " 271 << imageRight.getExternalStorageFile() << endl;
276 o <<
" Disparity image";
277 if (hasImageDisparity)
279 if (imageDisparity.isExternallyStored())
280 o <<
" is stored externally in file: " 281 << imageDisparity.getExternalStorageFile() << endl;
287 " Image size: %ux%u pixels\n", (
unsigned int)imageLeft.getWidth(),
288 (
unsigned int)imageLeft.getHeight());
290 o <<
" Channels order: " << imageLeft.getChannelsOrder() << endl;
293 " Rows are stored in top-bottom order: %s\n",
294 imageLeft.isOriginTopLeft() ?
"YES" :
"NO");
bool hasImageRight
Whether imageRight actually contains data (Default upon construction: true)
mrpt::img::CImage imageDisparity
Disparity image, only contains a valid image if hasImageDisparity == true.
mrpt::img::CImage imageLeft
Image from the left camera (this image will be ALWAYS present)
#define THROW_EXCEPTION(msg)
bool areImagesRectified() const
This method only checks whether ALL the distortion parameters in leftCamera are set to zero...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
void getStereoCameraParams(mrpt::img::TStereoCamera &out_params) const
Populates a TStereoCamera structure with the parameters in leftCamera, rightCamera and rightCameraPos...
bool hasImageDisparity
Whether imageDisparity actually contains data (Default upon construction: false)
void swap(CObservation &o)
Swap with another observation, ONLY the data defined here in the base class CObservation.
void getDescriptionAsText(std::ostream &o) const override
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
mrpt::poses::CPose3DQuat cameraPose
The pose of the LEFT camera, relative to the robot.
A numeric matrix of compile-time fixed size.
This base provides a set of functions for maths stuff.
Observation class for either a pair of left+right or left+disparity images from a stereo camera...
This namespace contains representation of robot actions and observations.
std::string dumpAsText() const
Dumps all the parameters as a multi-line string, with the same format than saveToConfigFile.
#define IMPLEMENTS_MEXPLUS_FROM(complete_type)
mrpt::img::TCamera rightCamera
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
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) ...
void setStereoCameraParams(const mrpt::img::TStereoCamera &in_params)
Sets leftCamera, rightCamera and rightCameraPose from a TStereoCamera structure.
Virtual base class for "archives": classes abstracting I/O streams.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
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.
void swap(CObservationStereoImages &o)
Do an efficient swap of all data members of this object with "o".
mrpt::poses::CPose3DQuat rightCameraPose
The pose of the right camera, relative to the left one: Note that using the conventional reference co...
CMatrixFixedNumeric< double, 3, 3 > CMatrixDouble33
TCamera leftCamera
Intrinsic and distortion parameters of the left and right cameras.
mrpt::math::TPose3DQuat rightCameraPose
Pose of the right camera with respect to the coordinate origin of the left camera.
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
This class is a "CSerializable" wrapper for "CMatrixFloat".
mrpt::img::TCamera leftCamera
Parameters for the left/right cameras: individual intrinsic and distortion parameters of the cameras...
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 stereo camera model.
#define INVALID_TIMESTAMP
Represents an invalid timestamp, where applicable.
mrpt::img::CImage imageRight
Image from the right camera, only contains a valid image if hasImageRight == true.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
virtual void getDescriptionAsText(std::ostream &o) const
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...