16 #include <mexplus/mxarray.h> 33 out << cameraPose << leftCamera << rightCamera << imageLeft;
34 out << hasImageDisparity << hasImageRight;
35 if (hasImageRight) out << imageRight;
36 if (hasImageDisparity) out << imageDisparity;
38 out << rightCameraPose;
49 in >> cameraPose >> leftCamera >> rightCamera >> imageLeft;
50 in >> hasImageDisparity >> hasImageRight;
51 if (hasImageRight)
in >> imageRight;
52 if (hasImageDisparity)
in >> imageDisparity;
54 in >> rightCameraPose;
68 hasImageDisparity =
false;
79 in >> cameraPose >> leftCamera >> rightCamera;
87 leftCamera.intrinsicParams = intParams;
89 rightCamera.intrinsicParams = intParams;
92 in >> imageLeft >> imageRight;
107 in >> rightCameraPose;
115 if (version >= 3 && version < 5)
119 leftCamera.focalLengthMeters = rightCamera.focalLengthMeters =
122 else if (version < 3)
123 leftCamera.focalLengthMeters = rightCamera.focalLengthMeters =
149 const char* fields[] = {
"class",
"ts",
"sensorLabel",
"imageL",
150 "imageR",
"poseL",
"poseLR",
"poseR",
151 "paramsL",
"paramsR"};
152 mexplus::MxArray obs_struct(
153 mexplus::MxArray::Struct(
sizeof(fields) /
sizeof(fields[0]), fields));
155 obs_struct.set(
"class", this->GetRuntimeClass()->className);
156 obs_struct.set(
"ts", this->timestamp);
157 obs_struct.set(
"sensorLabel", this->sensorLabel);
158 obs_struct.set(
"imageL", this->imageLeft);
159 obs_struct.set(
"imageR", this->imageRight);
160 obs_struct.set(
"poseL", this->cameraPose);
161 obs_struct.set(
"poseR", this->cameraPose + this->rightCameraPose);
162 obs_struct.set(
"poseLR", this->rightCameraPose);
163 obs_struct.set(
"paramsL", this->leftCamera);
164 obs_struct.set(
"paramsR", this->rightCamera);
165 return obs_struct.release();
199 leftCamera.dist.begin(), leftCamera.dist.end(),
200 [](
auto v) {
return v == 0; });
227 o <<
"Homogeneous matrix for the sensor's 3D pose, relative to robot " 230 <<
"Camera pose: " << cameraPose << endl
231 <<
"Camera pose (YPR): " <<
CPose3D(cameraPose) << endl
235 getStereoCameraParams(stParams);
238 o <<
"Right camera pose wrt left camera (YPR):" << endl
241 if (imageLeft.isExternallyStored())
242 o <<
" Left image is stored externally in file: " 243 << imageLeft.getExternalStorageFile() << endl;
248 if (imageRight.isExternallyStored())
249 o <<
" is stored externally in file: " 250 << imageRight.getExternalStorageFile() << endl;
255 o <<
" Disparity image";
256 if (hasImageDisparity)
258 if (imageDisparity.isExternallyStored())
259 o <<
" is stored externally in file: " 260 << imageDisparity.getExternalStorageFile() << endl;
266 " Image size: %ux%u pixels\n", (
unsigned int)imageLeft.getWidth(),
267 (
unsigned int)imageLeft.getHeight());
269 o <<
" Channels order: " << imageLeft.getChannelsOrder() << endl;
272 " Rows are stored in top-bottom order: %s\n",
273 imageLeft.isOriginTopLeft() ?
"YES" :
"NO");
bool hasImageRight
Whether imageRight actually contains data (Default upon construction: true)
A compile-time fixed-size numeric matrix container.
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)
To be added to 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.
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.
This class is a "CSerializable" wrapper for "CMatrixFloat".
Virtual base class for "archives": classes abstracting I/O streams.
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...
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 ...
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...