Main MRPT website > C++ reference
MRPT logo
CDUO3DCamera.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-2014, 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 
10 #ifndef CDUO3DCamera_H
11 #define CDUO3DCamera_H
12 
16 
18 #include <mrpt/utils/CUncopiable.h>
19 
21 
22 namespace mrpt
23 {
24  namespace hwdrivers
25  {
26  /** Options used when creating a camera capture object of type CImageGrabber_FlyCapture2 \ingroup mrpt_hwdrivers_grp */
28  {
29  enum TYMLReadResult {yrr_NAME_NON_CONSISTENT,yrr_EMPTY,yrr_OK};
30 
32 
33  /** @name Image settings
34  * @{ */
35  int m_img_width; //!< (Default = 640) Width of the captured image.
36  int m_img_height; //!< (Default = 480) Height of the captured image.
37  float m_fps; //!< (Default = 30) Frames per second <= 30.
38  float m_exposure; //!< (Default = 50) Exposure value.
39  float m_led; //!< (Default = 25) Led intensity (some device models).
40  float m_gain; //!< (Default = 10) Camera gain.
41  /** @} */
42 
43  /** @name Behaviour selection
44  * @{ */
45  bool m_capture_imu; //!< (Default = false) Capture IMU data.
46  bool m_capture_rectified; //!< (Default = true) Rectify images. Rectification map must be provided \sa m_rectify_map_filename.
47  bool m_calibration_from_file;//!< (Default = true) Get calibration information from files provided by DUO3D Calibration App.
48  /** @} */
49 
50  /** @name Files specification
51  * @{ */
52  std::string m_rectify_map_filename; //!< Rectification map file provided by DUO3D Calibration App (YML format).
53  std::string m_intrinsic_filename; //!< Intrinsic parameters file provided by DUO3D Calibration App (YML format).
54  std::string m_extrinsic_filename; //!< Extrinsic parameters file provided by DUO3D Calibration App (YML format).
55  /** @} */
56 
57  /** @name Others
58  * @{ */
60 #if MRPT_HAS_OPENCV
61  cv::Mat m_rectify_map_left_x;
62  cv::Mat m_rectify_map_left_y;
63  cv::Mat m_rectify_map_right_x;
64  cv::Mat m_rectify_map_right_y;
65 #endif
66  /** @} */
67 
68  /** Loads all the options from a config file.
69  * Expected format:
70  *
71  * \code
72  * [sectionName]
73  * image_width = 640 // [int] x Resolution
74  * image_height = 480 // [int] y Resolution
75  * fps = 30 // [int] Frames per second (<= 30)
76  * exposure = 50 // [int] Exposure value (1..100)
77  * led = 0 // [int] Led intensity (only for some device models) (1..100).
78  * gain = 50 // [int] Camera gain (1..100)
79  * capture_rectified = false // [bool] Rectify captured images
80  * capture_imu = true // [bool] Capture IMU data from DUO3D device (if available)
81  * calibration_from_file = true // [bool] Use YML calibration files provided by calibration application supplied with DUO3D device
82  * intrinsic_filename = "" // [string] Intrinsic parameters file. This filename should contain a substring _RWWWxHHH_ with WWW being the image width and HHH the image height, as provided by the calibration application.
83  * extrinsic_filename = "" // [string] Extrinsic parameters file. This filename should contain a substring _RWWWxHHH_ with WWW being the image width and HHH the image height, as provided by the calibration application.
84  * rectify_map_filename = "" // [string] Rectification map file. This filename should contain a substring _RWWWxHHH_ with WWW being the image width and HHH the image height, as provided by the calibration application.
85  *
86  * \endcode
87  * \note All parameter names may have an optional prefix, set with the "prefix" parameter.
88  * For example, if prefix="LEFT_", the expected variable name "camera_index" in the config section will be "LEFT_camera_index", and so on.
89  */
90  void loadOptionsFrom(
91  const mrpt::utils::CConfigFileBase & configSource,
92  const std::string & sectionName,
93  const std::string & prefix = std::string() );
94 
95  TYMLReadResult m_camera_int_params_from_yml( const std::string & _file_name = std::string() );
96  TYMLReadResult m_camera_ext_params_from_yml( const std::string & _file_name = std::string() );
97  TYMLReadResult m_rectify_map_from_yml( const std::string & _file_name = std::string() );
98 
99  }; // end-TCaptureOptions_DUO3D
100 
101  /** This "software driver" implements the communication protocol for interfacing a DUO3D Stereo Camera
102  *
103  * See also the example configuration file for rawlog-grabber in "share/mrpt/config_files/rawlog-grabber".
104  *
105  * \code
106  * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
107  * -------------------------------------------------------
108  * [supplied_section_name]
109  * image_width = 640 // [int] x Resolution
110  * image_height = 480 // [int] y Resolution
111  * fps = 30 // [int] Frames per second (<= 30)
112  * exposure = 50 // [int] Exposure value (1..100)
113  * led = 0 // [int] Led intensity (only for some device models) (1..100).
114  * gain = 50 // [int] Camera gain (1..100)
115  * capture_rectified = false // [bool] Rectify captured images
116  * capture_imu = true // [bool] Capture IMU data from DUO3D device (if available)
117  * calibration_from_file = true // [bool] Use YML calibration files provided by calibration application supplied with DUO3D device
118  * intrinsic_filename = "" // [string] Intrinsic parameters file. This filename should contain a substring _RWWWxHHH_ with WWW being the image width and HHH the image height, as provided by the calibration application.
119  * extrinsic_filename = "" // [string] Extrinsic parameters file. This filename should contain a substring _RWWWxHHH_ with WWW being the image width and HHH the image height, as provided by the calibration application.
120  * rectify_map_filename = "" // [string] Rectification map file. This filename should contain a substring _RWWWxHHH_ with WWW being the image width and HHH the image height, as provided by the calibration application.
121  *
122  * pose_x=0.21 // camera 3D position in the robot (meters)
123  * pose_y=0
124  * pose_z=0.34
125  * pose_yaw=0 // Angles in degrees
126  * pose_pitch=0
127  * pose_roll=0
128  * \endcode
129  *
130  * \ingroup mrpt_hwdrivers_grp
131  */
133  {
134 
135  protected:
136  // members
137  // [USER-DEFINED]
139 
140  // [INTERNAL]
142 
143  void * m_duo; //!< Opaque pointer to DUO's DUOInstance
144  void * m_pframe_data; //!< Pointer, to be reinterpreted as "PDUOFrame"
145  void * m_evFrame; //!< DUO's HANDLE
146 
147  public:
148  /** Default Constructor (does not open the camera) */
149  CDUO3DCamera();
150 
151  /** Constructor: tries to open the camera with the given options. Raises an exception on error. \sa open() */
152  CDUO3DCamera( const TCaptureOptions_DUO3D & options );
153 
154  /** Destructor */
155  virtual ~CDUO3DCamera();
156 
157  /** Returns the current settings of the camera */
158  const TCaptureOptions_DUO3D & getCameraOptions() const { return m_options; }
159 
160  /** Tries to open the camera with the given options, and starts capturing. Raises an exception on error.
161  * \param[in] startCapture If set to false, the camera is only opened and configured, but a posterior call to startCapture() is required to start grabbing data.
162  * \sa close(), startCapture()
163  */
164  void open( const TCaptureOptions_DUO3D & options, const bool startCapture = true );
165 
166  /** Start the actual data capture of the camera. Must be called after open(), only when "startCapture" was set to false.
167  */
168  void startCapture();
169 
170  /** Stop capture. */
171  void stopCapture();
172 
173  /** Stop capture and closes the opened camera, if any. Called automatically on object destruction. */
174  void close();
175 
176  /** Specific laser scanner "software drivers" must process here new data from the I/O stream, and, if a whole scan has arrived, return it.
177  * This method will be typically called in a different thread than other methods, and will be called in a timely fashion.
178  */
179  void getObservations(
180  mrpt::slam::CObservationStereoImages & outObservation_img,
181  mrpt::slam::CObservationIMU & outObservation_imu,
182  bool & there_is_img,
183  bool & there_is_imu );
184 
185  /** Indicates if the camera is grabbing IMU data */
186  inline bool captureIMUIsSet() { return m_options.m_capture_imu; }
187 
188  /** Returned pointer to be reinterpreted as DUO3D's "HANDLE" */
189  inline void* getEvent() { return this->m_evFrame; }
190 
191  /** frame is a reinterpreted PDUOFrame */
192  inline void setDataFrame( void* frame ) { this->m_pframe_data = frame; }
193 
194  protected:
195  /** Queries the DUO3D Camera firmware version */
196  bool queryVersion(std::string version, bool printOutVersion = false);
197 
198  /** Gets a stereo frame from the DUO3D Camera (void* to be reinterpreted as PDUOFrame) */
199  void * m_get_duo_frame();
200 
201  /** Opens DUO3D camera */
202  bool m_open_duo_camera(int width, int height, float fps);
203 
204  /** Closes DUO3D camera */
205  void m_close_duo_camera();
206 
207  /** Sets DUO3D camera Exposure setting */
208  void m_set_exposure(float value);
209 
210  /** Sets DUO3D camera Gain setting */
211  void m_set_gain(float value);
212 
213  /** Sets DUO3D camera LED setting */
214  void m_set_led(float value);
215  }; // End of class
216  } // End of namespace
217 } // End of namespace
218 #endif
const TCaptureOptions_DUO3D & getCameraOptions() const
Returns the current settings of the camera.
Definition: CDUO3DCamera.h:158
float m_fps
(Default = 30) Frames per second <= 30.
Definition: CDUO3DCamera.h:37
std::string m_intrinsic_filename
Intrinsic parameters file provided by DUO3D Calibration App (YML format).
Definition: CDUO3DCamera.h:53
This "software driver" implements the communication protocol for interfacing a DUO3D Stereo Camera...
Definition: CDUO3DCamera.h:132
float m_exposure
(Default = 50) Exposure value.
Definition: CDUO3DCamera.h:38
void * getEvent()
Returned pointer to be reinterpreted as DUO3D's "HANDLE".
Definition: CDUO3DCamera.h:189
bool m_calibration_from_file
(Default = true) Get calibration information from files provided by DUO3D Calibration App...
Definition: CDUO3DCamera.h:47
bool m_capture_imu
(Default = false) Capture IMU data.
Definition: CDUO3DCamera.h:45
void * m_pframe_data
Pointer, to be reinterpreted as "PDUOFrame".
Definition: CDUO3DCamera.h:144
std::string m_rectify_map_filename
Rectification map file provided by DUO3D Calibration App (YML format).
Definition: CDUO3DCamera.h:52
int m_img_width
(Default = 640) Width of the captured image.
Definition: CDUO3DCamera.h:35
bool captureIMUIsSet()
Indicates if the camera is grabbing IMU data.
Definition: CDUO3DCamera.h:186
Structure to hold the parameters of a pinhole stereo camera model.
Definition: TStereoCamera.h:25
This class allows loading and storing values and vectors of different types from a configuration text...
float m_led
(Default = 25) Led intensity (some device models).
Definition: CDUO3DCamera.h:39
int m_img_height
(Default = 480) Height of the captured image.
Definition: CDUO3DCamera.h:36
float m_gain
(Default = 10) Camera gain.
Definition: CDUO3DCamera.h:40
Use this class to rectify stereo images if the same distortion maps are reused over and over again...
The base class of classes that cannot be copied: compile-time errors will be issued on any copy opera...
Definition: CUncopiable.h:30
Options used when creating a camera capture object of type CImageGrabber_FlyCapture2.
Definition: CDUO3DCamera.h:27
void * m_evFrame
DUO's HANDLE.
Definition: CDUO3DCamera.h:145
TCaptureOptions_DUO3D m_options
Definition: CDUO3DCamera.h:138
Observation class for either a pair of left+right or left+disparity images from a stereo camera...
void * m_duo
Opaque pointer to DUO's DUOInstance.
Definition: CDUO3DCamera.h:143
mrpt::utils::TStereoCamera m_stereo_camera
Definition: CDUO3DCamera.h:59
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
This class stores measurements from an Inertial Measurement Unit (IMU) (attitude estimation, raw gyroscope and accelerometer values), altimeters or magnetometers.
std::string m_extrinsic_filename
Extrinsic parameters file provided by DUO3D Calibration App (YML format).
Definition: CDUO3DCamera.h:54
#define HWDRIVERS_IMPEXP
mrpt::vision::CStereoRectifyMap m_rectify_map
Definition: CDUO3DCamera.h:141
void setDataFrame(void *frame)
frame is a reinterpreted PDUOFrame
Definition: CDUO3DCamera.h:192
bool m_capture_rectified
(Default = true) Rectify images. Rectification map must be provided
Definition: CDUO3DCamera.h:46



Page generated by Doxygen 1.8.8 for MRPT 1.2.2 SVN:Unversioned directory at Tue Oct 14 02:14:08 UTC 2014