Main MRPT website > C++ reference
MRPT logo
CObservationStereoImages.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef CObservationStereoImages_H
29 #define CObservationStereoImages_H
30 
32 #include <mrpt/utils/CImage.h>
34 #include <mrpt/slam/CObservation.h>
35 #include <mrpt/poses/CPose3D.h>
36 #include <mrpt/poses/CPose3DQuat.h>
37 #include <mrpt/poses/CPose2D.h>
38 
39 namespace mrpt
40 {
41 namespace slam
42 {
43  using namespace mrpt::utils;
44 
46 
47  /** Observation class for either a pair of left+right or left+disparity images from a stereo camera.
48  *
49  * To find whether the observation contains a right image and/or a disparity image, see the
50  * fields hasImageDisparity and hasImageRight, respectively.
51  *
52  * This figure illustrates the coordinate frames involved in this class:
53  *
54  * <center>
55  * <img src="CObservationStereoImages_figRefSystem.png">
56  * </center>
57  *
58  * \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.
59  * \sa CObservation
60  * \ingroup mrpt_obs_grp
61  */
63  {
64  // This must be added to any CSerializable derived class:
66 
67  public:
68  /** Default Constructor */
70 
71  /** Constructor from "IplImage*" images, which could be NULL.
72  * The fields hasImageDisparity and hasImageRight will be set to true/false depending on them being !=NULL.
73  * Note that the IplImage's will be COPIED, so it's still the caller's reponsibility to free the original images,
74  * 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.
75  *
76  */
77  CObservationStereoImages( void *iplImageLeft, void *iplImageRight, void *iplImageDisparity = NULL, bool ownMemory = false );
78 
79  /** Destructor
80  */
81  ~CObservationStereoImages( );
82 
83 
84  /** @name Main observation data members
85  @{ */
86 
87  /** Image from the left camera (this image will be ALWAYS present) \sa areImagesRectified() */
88  mrpt::utils::CImage imageLeft;
89 
90  /** Image from the right camera, only contains a valid image if hasImageRight == true. \sa areImagesRectified() */
91  mrpt::utils::CImage imageRight;
92 
93  /** Disparity image, only contains a valid image if hasImageDisparity == true.
94  * The relation between the actual disparity and pixels and each value in this image is... ??????????? */
95  mrpt::utils::CImage imageDisparity;
96 
97  bool hasImageDisparity; //!< Whether imageDisparity actually contains data (Default upon construction: false)
98  bool hasImageRight; //!< Whether imageRight actually contains data (Default upon construction: true)
99 
100  /** Parameters for the left/right cameras: individual intrinsic and distortion parameters of the cameras.
101  * See the <a href="http://www.mrpt.org/Camera_Parameters" >tutorial</a> for a discussion of these parameters.
102  * \sa areImagesRectified(), getStereoCameraParams()
103  */
104  TCamera leftCamera, rightCamera;
105 
106  CPose3DQuat cameraPose; //!< The pose of the LEFT camera, relative to the robot.
107 
108  /** The pose of the right camera, relative to the left one:
109  * Note that using the conventional reference coordinates for the left
110  * camera (x points to the right, y down), the "right" camera is situated
111  * at position (BL, 0, 0) with yaw=pitch=roll=0, where BL is the BASELINE.
112  */
113  CPose3DQuat rightCameraPose;
114 
115  /** Populates a TStereoCamera structure with the parameters in \a leftCamera, \a rightCamera and \a rightCameraPose \sa areImagesRectified() */
116  void getStereoCameraParams(mrpt::utils::TStereoCamera &out_params) const;
117 
118  /** Sets \a leftCamera, \a rightCamera and \a rightCameraPose from a TStereoCamera structure */
119  void setStereoCameraParams(const mrpt::utils::TStereoCamera &in_params);
120 
121  /** This method only checks whether ALL the distortion parameters in \a leftCamera are set to zero, which is
122  * the convention in MRPT to denote that this pair of stereo images has been rectified.
123  */
124  bool areImagesRectified() const;
125 
126  /** @} */
127 
128 
129  /** A general method to retrieve the sensor pose on the robot.
130  * Note that most sensors will return a full (6D) CPose3D, but see the derived classes for more details or special cases.
131  * \sa setSensorPose
132  */
133  void getSensorPose( CPose3D &out_sensorPose ) const { out_sensorPose = cameraPose; }
134 
135 
136  /** A general method to change the sensor pose on the robot.
137  * Note that most sensors will use the full (6D) CPose3D, but see the derived classes for more details or special cases.
138  * \sa getSensorPose
139  */
140  void setSensorPose( const CPose3D &newSensorPose ) { cameraPose = CPose3DQuat(newSensorPose); }
141 
142  void swap( CObservationStereoImages &o); //!< Do an efficient swap of all data members of this object with "o".
143 
144  }; // End of class def.
145 
146  } // End of namespace
147 } // End of namespace
148 
149 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013