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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020