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



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019