Main MRPT website > C++ reference
MRPT logo
obs/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-2015, 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/utils/CImage.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
21 {
22 namespace obs
23 {
24  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CObservationStereoImages , CObservation,OBS_IMPEXP )
25 
26  /** Observation class for either a pair of left+right or left+disparity images from a stereo camera.
27  *
28  * To find whether the observation contains a right image and/or a disparity image, see the
29  * fields hasImageDisparity and hasImageRight, respectively.
30  *
31  * This figure illustrates the coordinate frames involved in this class:
32  *
33  * <center>
34  * <img src="CObservationStereoImages_figRefSystem.png">
35  * </center>
36  *
37  * \note The images stored in this class can be raw or undistorted images. In the latter case, the "distortion" params of the corresponding "leftCamera" and "rightCamera" fields should be all zeros.
38  * \sa CObservation
39  * \ingroup mrpt_obs_grp
40  */
42  {
43  // This must be added to any CSerializable derived class:
45 
46  public:
47  /** Default Constructor */
49 
50  /** Constructor from "IplImage*" images, which could be NULL.
51  * The fields hasImageDisparity and hasImageRight will be set to true/false depending on them being !=NULL.
52  * Note that the IplImage's will be COPIED, so it's still the caller's reponsibility to free the original images,
53  * unless ownMemory is set to true: in that case the IplImage pointers are copied and those IplImage's will be automatically freed by this object.
54  *
55  */
56  CObservationStereoImages( void *iplImageLeft, void *iplImageRight, void *iplImageDisparity = NULL, bool ownMemory = false );
57 
58  /** Destructor
59  */
60  ~CObservationStereoImages( );
61 
62 
63  /** @name Main observation data members
64  @{ */
65 
66  /** Image from the left camera (this image will be ALWAYS present) \sa areImagesRectified() */
67  mrpt::utils::CImage imageLeft;
68 
69  /** Image from the right camera, only contains a valid image if hasImageRight == true. \sa areImagesRectified() */
70  mrpt::utils::CImage imageRight;
71 
72  /** Disparity image, only contains a valid image if hasImageDisparity == true.
73  * The relation between the actual disparity and pixels and each value in this image is... ??????????? */
74  mrpt::utils::CImage imageDisparity;
75 
76  bool hasImageDisparity; //!< Whether imageDisparity actually contains data (Default upon construction: false)
77  bool hasImageRight; //!< Whether imageRight actually contains data (Default upon construction: true)
78 
79  /** Parameters for the left/right cameras: individual intrinsic and distortion parameters of the cameras.
80  * See the <a href="http://www.mrpt.org/Camera_Parameters" >tutorial</a> for a discussion of these parameters.
81  * \sa areImagesRectified(), getStereoCameraParams()
82  */
83  mrpt::utils::TCamera leftCamera, rightCamera;
84 
85  mrpt::poses::CPose3DQuat cameraPose; //!< The pose of the LEFT camera, relative to the robot.
86 
87  /** The pose of the right camera, relative to the left one:
88  * Note that using the conventional reference coordinates for the left
89  * camera (x points to the right, y down), the "right" camera is situated
90  * at position (BL, 0, 0) with yaw=pitch=roll=0, where BL is the BASELINE.
91  */
92  mrpt::poses::CPose3DQuat rightCameraPose;
93 
94  /** Populates a TStereoCamera structure with the parameters in \a leftCamera, \a rightCamera and \a rightCameraPose \sa areImagesRectified() */
95  void getStereoCameraParams(mrpt::utils::TStereoCamera &out_params) const;
96 
97  /** Sets \a leftCamera, \a rightCamera and \a rightCameraPose from a TStereoCamera structure */
98  void setStereoCameraParams(const mrpt::utils::TStereoCamera &in_params);
99 
100  /** This method only checks whether ALL the distortion parameters in \a leftCamera are set to zero, which is
101  * the convention in MRPT to denote that this pair of stereo images has been rectified.
102  */
103  bool areImagesRectified() const;
104 
105  /** @} */
106 
107 
108  // See base class docs
109  void getSensorPose( mrpt::poses::CPose3D &out_sensorPose ) const { out_sensorPose = cameraPose; }
110  // See base class docs
111  void setSensorPose( const mrpt::poses::CPose3D &newSensorPose ) { cameraPose = mrpt::poses::CPose3DQuat(newSensorPose); }
112  // See base class docs
113  virtual void getDescriptionAsText(std::ostream &o) const;
114 
115  void swap( CObservationStereoImages &o); //!< Do an efficient swap of all data members of this object with "o".
116 
117  }; // End of class def.
118  DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE( CObservationStereoImages , CObservation,OBS_IMPEXP )
119 
120  } // End of namespace
121 } // End of namespace
122 
123 #endif
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
Observation class for either a pair of left+right or left+disparity images from a stereo camera...
class BASE_IMPEXP CPose3DQuat
Definition: CPose3D.h:20
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#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:69
Declares a class that represents any robot's observation.
void setSensorPose(const mrpt::poses::CPose3D &newSensorPose)
A general method to change the sensor pose on the robot.
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)



Page generated by Doxygen 1.8.9.1 for MRPT 1.3.0 SVN: at Sun Sep 13 03:55:12 UTC 2015