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



Page generated by Doxygen 1.8.14 for MRPT 2.0.2 Git: 9b4fd2465 Mon May 4 16:59:08 2020 +0200 at lun may 4 17:26:07 CEST 2020