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-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
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::config::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
mrpt::hwdrivers::TCaptureOptions_DUO3D::m_intrinsic_filename
std::string m_intrinsic_filename
Intrinsic parameters file provided by DUO3D Calibration App (YML format).
Definition: CDUO3DCamera.h:70
mrpt::hwdrivers::TCaptureOptions_DUO3D::m_stereo_camera
mrpt::img::TStereoCamera m_stereo_camera
Definition: CDUO3DCamera.h:78
mrpt::hwdrivers::TCaptureOptions_DUO3D::m_extrinsic_filename
std::string m_extrinsic_filename
Extrinsic parameters file provided by DUO3D Calibration App (YML format).
Definition: CDUO3DCamera.h:73
mrpt::hwdrivers::TCaptureOptions_DUO3D::yrr_NAME_NON_CONSISTENT
@ yrr_NAME_NON_CONSISTENT
Definition: CDUO3DCamera.h:27
mrpt::hwdrivers::CDUO3DCamera::getEvent
void * getEvent()
Returned pointer to be reinterpreted as DUO3D's "HANDLE".
Definition: CDUO3DCamera.h:224
mrpt::hwdrivers::CDUO3DCamera::m_set_exposure
void m_set_exposure(float value)
Sets DUO3D camera Exposure setting.
Definition: CDUO3DCamera.cpp:583
mrpt::hwdrivers::CDUO3DCamera
This "software driver" implements the communication protocol for interfacing a DUO3D Stereo Camera.
Definition: CDUO3DCamera.h:156
mrpt::hwdrivers::TCaptureOptions_DUO3D::m_fps
float m_fps
(Default = 30) Frames per second <= 30.
Definition: CDUO3DCamera.h:42
mrpt::hwdrivers::CDUO3DCamera::setDataFrame
void setDataFrame(void *frame)
frame is a reinterpreted PDUOFrame
Definition: CDUO3DCamera.h:226
mrpt::hwdrivers::CDUO3DCamera::close
void close()
Stop capture and closes the opened camera, if any.
Definition: CDUO3DCamera.cpp:559
mrpt::hwdrivers::CDUO3DCamera::stopCapture
void stopCapture()
Stop capture.
mrpt::hwdrivers::CDUO3DCamera::m_options
TCaptureOptions_DUO3D m_options
Definition: CDUO3DCamera.h:161
mrpt::hwdrivers::TCaptureOptions_DUO3D::~TCaptureOptions_DUO3D
~TCaptureOptions_DUO3D()
Definition: CDUO3DCamera.cpp:73
mrpt::hwdrivers::CDUO3DCamera::m_pframe_data
void * m_pframe_data
Pointer, to be reinterpreted as "PDUOFrame".
Definition: CDUO3DCamera.h:169
mrpt::hwdrivers::TCaptureOptions_DUO3D::m_rectify_map_filename
std::string m_rectify_map_filename
Rectification map file provided by DUO3D Calibration App (YML format).
Definition: CDUO3DCamera.h:67
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::hwdrivers::TCaptureOptions_DUO3D::m_img_height
int m_img_height
(Default = 480) Height of the captured image.
Definition: CDUO3DCamera.h:40
mrpt::hwdrivers::TCaptureOptions_DUO3D
Options used when creating a camera capture object of type CImageGrabber_FlyCapture2.
Definition: CDUO3DCamera.h:23
mrpt::hwdrivers::TCaptureOptions_DUO3D::TYMLReadResult
TYMLReadResult
Definition: CDUO3DCamera.h:25
mrpt::hwdrivers::CDUO3DCamera::m_duo
void * m_duo
Opaque pointer to DUO's DUOInstance.
Definition: CDUO3DCamera.h:167
mrpt::obs::CObservationIMU
This class stores measurements from an Inertial Measurement Unit (IMU) (attitude estimation,...
Definition: CObservationIMU.h:108
mrpt::hwdrivers::TCaptureOptions_DUO3D::loadOptionsFrom
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.
Definition: CDUO3DCamera.cpp:252
mrpt::vision::CStereoRectifyMap
Use this class to rectify stereo images if the same distortion maps are reused over and over again.
Definition: CStereoRectifyMap.h:77
CObservationStereoImages.h
mrpt::hwdrivers::CDUO3DCamera::captureIMUIsSet
bool captureIMUIsSet()
Indicates if the camera is grabbing IMU data.
Definition: CDUO3DCamera.h:222
mrpt::hwdrivers::CDUO3DCamera::getCameraOptions
const TCaptureOptions_DUO3D & getCameraOptions() const
Returns the current settings of the camera.
Definition: CDUO3DCamera.h:188
CStereoRectifyMap.h
mrpt::hwdrivers::TCaptureOptions_DUO3D::m_camera_ext_params_from_yml
TYMLReadResult m_camera_ext_params_from_yml(const std::string &_file_name=std::string())
Definition: CDUO3DCamera.cpp:116
mrpt::hwdrivers::CDUO3DCamera::m_close_duo_camera
void m_close_duo_camera()
Closes DUO3D camera.
mrpt::hwdrivers::TCaptureOptions_DUO3D::m_capture_imu
bool m_capture_imu
(Default = false) Capture IMU data.
Definition: CDUO3DCamera.h:54
mrpt::hwdrivers::TCaptureOptions_DUO3D::m_img_width
int m_img_width
(Default = 640) Width of the captured image.
Definition: CDUO3DCamera.h:38
mrpt::img::TStereoCamera
Structure to hold the parameters of a pinhole stereo camera model.
Definition: TStereoCamera.h:25
mrpt::config::CConfigFileBase
This class allows loading and storing values and vectors of different types from a configuration text...
Definition: config/CConfigFileBase.h:44
mrpt::hwdrivers::TCaptureOptions_DUO3D::m_led
float m_led
(Default = 25) Led intensity (some device models).
Definition: CDUO3DCamera.h:46
mrpt::hwdrivers::CDUO3DCamera::operator=
CDUO3DCamera & operator=(const CDUO3DCamera &)=delete
mrpt::hwdrivers::CDUO3DCamera::m_set_gain
void m_set_gain(float value)
Sets DUO3D camera Gain setting
Definition: CDUO3DCamera.cpp:591
mrpt::hwdrivers::TCaptureOptions_DUO3D::TCaptureOptions_DUO3D
TCaptureOptions_DUO3D()
Definition: CDUO3DCamera.cpp:55
mrpt::hwdrivers::TCaptureOptions_DUO3D::m_camera_int_params_from_yml
TYMLReadResult m_camera_int_params_from_yml(const std::string &_file_name=std::string())
Definition: CDUO3DCamera.cpp:178
mrpt::hwdrivers::TCaptureOptions_DUO3D::yrr_EMPTY
@ yrr_EMPTY
Definition: CDUO3DCamera.h:28
mrpt::hwdrivers::CDUO3DCamera::queryVersion
bool queryVersion(std::string version, bool printOutVersion=false)
Queries the DUO3D Camera firmware version.
Definition: CDUO3DCamera.cpp:608
height
GLenum GLsizei GLsizei height
Definition: glext.h:3554
mrpt::hwdrivers::TCaptureOptions_DUO3D::yrr_OK
@ yrr_OK
Definition: CDUO3DCamera.h:29
mrpt::hwdrivers::TCaptureOptions_DUO3D::m_gain
float m_gain
(Default = 10) Camera gain.
Definition: CDUO3DCamera.h:48
CObservationIMU.h
mrpt::hwdrivers::TCaptureOptions_DUO3D::m_exposure
float m_exposure
(Default = 50) Exposure value.
Definition: CDUO3DCamera.h:44
mrpt::hwdrivers::CDUO3DCamera::~CDUO3DCamera
virtual ~CDUO3DCamera()
Destructor
Definition: CDUO3DCamera.cpp:338
mrpt::hwdrivers::TCaptureOptions_DUO3D::m_rectify_map_from_yml
TYMLReadResult m_rectify_map_from_yml(const std::string &_file_name=std::string())
Definition: CDUO3DCamera.cpp:79
value
GLsizei const GLfloat * value
Definition: glext.h:4117
width
GLenum GLsizei width
Definition: glext.h:3531
mrpt::hwdrivers::TCaptureOptions_DUO3D::m_calibration_from_file
bool m_calibration_from_file
(Default = true) Get calibration information from files provided by DUO3D Calibration App.
Definition: CDUO3DCamera.h:60
MRPT_MAKE_ALIGNED_OPERATOR_NEW
#define MRPT_MAKE_ALIGNED_OPERATOR_NEW
Put this macro inside any class with members that require {16,32,64}-byte memory alignment (e....
Definition: aligned_allocator.h:90
mrpt::hwdrivers::CDUO3DCamera::m_open_duo_camera
bool m_open_duo_camera(int width, int height, float fps)
Opens DUO3D camera.
mrpt::hwdrivers::CDUO3DCamera::m_set_led
void m_set_led(float value)
Sets DUO3D camera LED setting
Definition: CDUO3DCamera.cpp:599
mrpt::hwdrivers::CDUO3DCamera::m_get_duo_frame
void * m_get_duo_frame()
Gets a stereo frame from the DUO3D Camera (void* to be reinterpreted as PDUOFrame)
Definition: CDUO3DCamera.cpp:570
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::hwdrivers::CDUO3DCamera::startCapture
void startCapture()
Start the actual data capture of the camera.
mrpt::hwdrivers::CDUO3DCamera::CDUO3DCamera
CDUO3DCamera()
Default Constructor (does not open the camera)
Definition: CDUO3DCamera.cpp:303
mrpt::hwdrivers::TCaptureOptions_DUO3D::m_capture_rectified
bool m_capture_rectified
(Default = true) Rectify images.
Definition: CDUO3DCamera.h:57
mrpt::hwdrivers::CDUO3DCamera::open
void open(const TCaptureOptions_DUO3D &options, const bool startCapture=true)
Tries to open the camera with the given options, and starts capturing.
Definition: CDUO3DCamera.cpp:352
mrpt::hwdrivers::CDUO3DCamera::m_evFrame
void * m_evFrame
DUO's HANDLE.
Definition: CDUO3DCamera.h:171
mrpt::hwdrivers::CDUO3DCamera::getObservations
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,...
Definition: CDUO3DCamera.cpp:495
mrpt::obs::CObservationStereoImages
Observation class for either a pair of left+right or left+disparity images from a stereo camera.
Definition: CObservationStereoImages.h:41
mrpt::hwdrivers::CDUO3DCamera::m_rectify_map
mrpt::vision::CStereoRectifyMap m_rectify_map
Definition: CDUO3DCamera.h:164



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST