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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019