MRPT  1.9.9
CObservationStereoImages.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef CObservationStereoImages_H
10 #define CObservationStereoImages_H
11 
13 #include <mrpt/img/CImage.h>
14 #include <mrpt/img/TStereoCamera.h>
15 #include <mrpt/obs/CObservation.h>
16 #include <mrpt/poses/CPose3D.h>
17 #include <mrpt/poses/CPose3DQuat.h>
18 #include <mrpt/poses/CPose2D.h>
19 
20 namespace mrpt::obs
21 {
22 /** Observation class for either a pair of left+right or left+disparity images
23  *from a stereo camera.
24  *
25  * To find whether the observation contains a right image and/or a disparity
26  *image, see the fields hasImageDisparity and hasImageRight, respectively.
27  * This figure illustrates the coordinate frames involved in this class:
28  *
29  * <center>
30  * <img src="CObservationStereoImages_figRefSystem.png">
31  * </center>
32  *
33  * \note The images stored in this class can be raw or undistorted images. In
34  *the latter case, the "distortion" params of the corresponding "leftCamera" and
35  *"rightCamera" fields should be all zeros.
36  * \sa CObservation
37  * \ingroup mrpt_obs_grp
38  */
40 {
42  // This must be added for declaration of MEX-related functions
44 
45  public:
46  CObservationStereoImages() = default;
47 
48  /** Constructor from "IplImage*" images, which could be NULL.
49  * The fields hasImageDisparity and hasImageRight will be set to
50  * true/false depending on them being !=nullptr.
51  * Note that the IplImage's will be COPIED, so it's still the caller's
52  * reponsibility to free the original images,
53  * unless ownMemory is set to true: in that case the IplImage pointers are
54  * copied and those IplImage's will be automatically freed by this object.
55  *
56  */
58  void* iplImageLeft, void* iplImageRight,
59  void* iplImageDisparity = nullptr, bool ownMemory = false);
60 
61  /** @name Main observation data members
62  @{ */
63 
64  /** Image from the left camera (this image will be ALWAYS present) \sa
65  * areImagesRectified() */
67 
68  /** Image from the right camera, only contains a valid image if
69  * hasImageRight == true. \sa areImagesRectified() */
71 
72  /** Disparity image, only contains a valid image if hasImageDisparity ==
73  * true.
74  * The relation between the actual disparity and pixels and each value in
75  * this image is... ??????????? */
77 
78  /** Whether imageDisparity actually contains data (Default upon
79  * construction: false) */
80  bool hasImageDisparity{false};
81  /** Whether imageRight actually contains data (Default upon construction:
82  * true) */
83  bool hasImageRight{false};
84 
85  /** Parameters for the left/right cameras: individual intrinsic and
86  * distortion parameters of the cameras.
87  * See the <a href="http://www.mrpt.org/Camera_Parameters" >tutorial</a>
88  * for a discussion of these parameters.
89  * \sa areImagesRectified(), getStereoCameraParams()
90  */
92 
93  /** The pose of the LEFT camera, relative to the robot. */
95 
96  /** The pose of the right camera, relative to the left one:
97  * Note that using the conventional reference coordinates for the left
98  * camera (x points to the right, y down), the "right" camera is situated
99  * at position (BL, 0, 0) with yaw=pitch=roll=0, where BL is the
100  * BASELINE.
101  */
103 
104  /** Populates a TStereoCamera structure with the parameters in \a
105  * leftCamera, \a rightCamera and \a rightCameraPose \sa
106  * areImagesRectified() */
107  void getStereoCameraParams(mrpt::img::TStereoCamera& out_params) const;
108 
109  /** Sets \a leftCamera, \a rightCamera and \a rightCameraPose from a
110  * TStereoCamera structure */
111  void setStereoCameraParams(const mrpt::img::TStereoCamera& in_params);
112 
113  /** This method only checks whether ALL the distortion parameters in \a
114  * leftCamera are set to zero, which is
115  * the convention in MRPT to denote that this pair of stereo images has
116  * been rectified.
117  */
118  bool areImagesRectified() const;
119 
120  /** @} */
121 
122  // See base class docs
123  void getSensorPose(mrpt::poses::CPose3D& out_sensorPose) const override
124  {
125  out_sensorPose = mrpt::poses::CPose3D(cameraPose);
126  }
127  void setSensorPose(const mrpt::poses::CPose3D& newSensorPose) override
128  {
129  cameraPose = mrpt::poses::CPose3DQuat(newSensorPose);
130  }
131  void getDescriptionAsText(std::ostream& o) const override;
132 
133  /** Do an efficient swap of all data members of this object with "o". */
135 
136 }; // End of class def.
137 
138 }
139 // Add for declaration of mexplus::from template specialization
141 
142 #endif
143 
144 
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)
bool areImagesRectified() const
This method only checks whether ALL the distortion parameters in leftCamera are set to zero...
#define DECLARE_MEXPLUS_FROM(complete_type)
This must be inserted if a custom conversion method for MEX API is implemented in the class...
void setSensorPose(const mrpt::poses::CPose3D &newSensorPose) override
A general method to change the sensor pose on the robot.
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 getDescriptionAsText(std::ostream &o) const override
Build a detailed, multi-line textual description of the observation contents and dump it to the outpu...
mrpt::poses::CPose3DQuat cameraPose
The pose of the LEFT camera, relative to the robot.
void getSensorPose(mrpt::poses::CPose3D &out_sensorPose) const override
A general method to retrieve the sensor pose on the robot.
#define DECLARE_MEX_CONVERSION
This must be inserted if a custom conversion method for MEX API is implemented in the class...
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.
Structure to hold the parameters of a pinhole camera model.
Definition: TCamera.h:27
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
Definition: CPose3DQuat.h:46
void setStereoCameraParams(const mrpt::img::TStereoCamera &in_params)
Sets leftCamera, rightCamera and rightCameraPose from a TStereoCamera structure.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:86
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:43
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...
mrpt::img::TCamera leftCamera
Parameters for the left/right cameras: individual intrinsic and distortion parameters of the cameras...
Structure to hold the parameters of a pinhole stereo camera model.
Definition: TStereoCamera.h:23
mrpt::img::CImage imageRight
Image from the right camera, only contains a valid image if hasImageRight == true.
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020