17 #include <mexplus/mxarray.h> 34 out << cameraPose << leftCamera << rightCamera << imageLeft;
35 out << hasImageDisparity << hasImageRight;
36 if (hasImageRight)
out << imageRight;
37 if (hasImageDisparity)
out << imageDisparity;
39 out << rightCameraPose;
50 in >> cameraPose >> leftCamera >> rightCamera >> imageLeft;
51 in >> hasImageDisparity >> hasImageRight;
52 if (hasImageRight) in >> imageRight;
53 if (hasImageDisparity) in >> imageDisparity;
55 in >> rightCameraPose;
69 hasImageDisparity =
false;
80 in >> cameraPose >> leftCamera >> rightCamera;
88 leftCamera.intrinsicParams = intParams;
90 rightCamera.intrinsicParams = intParams;
93 in >> imageLeft >> imageRight;
108 in >> rightCameraPose;
116 if (version >= 3 && version < 5)
120 leftCamera.focalLengthMeters = rightCamera.focalLengthMeters =
123 else if (version < 3)
124 leftCamera.focalLengthMeters = rightCamera.focalLengthMeters =
150 const char* fields[] = {
"class",
"ts",
"sensorLabel",
"imageL",
151 "imageR",
"poseL",
"poseLR",
"poseR",
152 "paramsL",
"paramsR"};
153 mexplus::MxArray obs_struct(
154 mexplus::MxArray::Struct(
sizeof(fields) /
sizeof(fields[0]), fields));
156 obs_struct.set(
"class", this->GetRuntimeClass()->className);
158 obs_struct.set(
"sensorLabel", this->sensorLabel);
159 obs_struct.set(
"imageL", this->imageLeft);
160 obs_struct.set(
"imageR", this->imageRight);
161 obs_struct.set(
"poseL", this->cameraPose);
162 obs_struct.set(
"poseR", this->cameraPose + this->rightCameraPose);
163 obs_struct.set(
"poseLR", this->rightCameraPose);
164 obs_struct.set(
"paramsL", this->leftCamera);
165 obs_struct.set(
"paramsR", this->rightCamera);
166 return obs_struct.release();
200 leftCamera.dist.begin(), leftCamera.dist.end(),
201 [](
auto v) {
return v == 0; });
228 o <<
"Homogeneous matrix for the sensor's 3D pose, relative to robot " 231 <<
"Camera pose: " << cameraPose <<
"\n" 232 <<
"Camera pose (YPR): " <<
CPose3D(cameraPose) <<
"\n" 236 getStereoCameraParams(stParams);
239 o <<
"Right camera pose wrt left camera (YPR):" 243 if (imageLeft.isExternallyStored())
244 o <<
" Left image is stored externally in file: " 245 << imageLeft.getExternalStorageFile() <<
"\n";
250 if (imageRight.isExternallyStored())
251 o <<
" is stored externally in file: " 252 << imageRight.getExternalStorageFile() <<
"\n";
257 o <<
" Disparity image";
258 if (hasImageDisparity)
260 if (imageDisparity.isExternallyStored())
261 o <<
" is stored externally in file: " 262 << imageDisparity.getExternalStorageFile() <<
"\n";
267 if (!imageLeft.isEmpty())
270 " Image size: %ux%u pixels\n", (
unsigned int)imageLeft.getWidth(),
271 (
unsigned int)imageLeft.getHeight());
273 o <<
" Channels order: " << imageLeft.getChannelsOrder() <<
"\n";
276 " Rows are stored in top-bottom order: %s\n",
277 imageLeft.isOriginTopLeft() ?
"YES" :
"NO");
283 imageLeft.forceLoad();
284 imageRight.forceLoad();
285 imageDisparity.forceLoad();
static double toDouble(const time_point t) noexcept
Converts a timestamp to a UNIX time_t-like number, with fractional part.
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)
std::string std::string format(std::string_view fmt, ARGS &&... args)
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.
void load() const override
Makes sure all images and other fields which may be externally stored are loaded in memory...
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).
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.
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...