Main MRPT website > C++ reference for MRPT 1.9.9
CSwissRanger3DCamera.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 #ifndef CSwissRanger3DCamera_H
10 #define CSwissRanger3DCamera_H
11 
15 
17 
18 namespace mrpt
19 {
20 namespace hwdrivers
21 {
22 /** A class for grabing "range images" from a MESA imaging SwissRanger 3D
23  *cameras (SR-2, SR-3000, SR-4k).
24  *
25  * NOTES:
26  * - This class requires a vendor specific driver installed in the system
27  *in
28  *order to build MRPT with support for this sensor. Download and install the
29  *driver from: http://www.mesa-imaging.ch/drivers.php
30  * - The intensity channel (grayscale image) is converted from 16bit to
31  *standard 8bit-per-pixel using a logarithmic, modified A-law compression. This
32  *allows exploiting the full dynamic range of the sensor and provides quite
33  *good results.
34  *
35  * As with any other CGenericSensor class, the normal sequence of methods to be
36  *called is:
37  * - loadConfig() - Or calls to the individual setXXX() to configure the
38  *camera parameters.
39  * - initialize() - to init the comms with the camera
40  * - call getNextObservation() for getting the frames.
41  *
42  * This sensor can be also used from within rawlog-grabber.
43  *
44  * \code
45  * PARAMETERS IN THE ".INI"-LIKE CONFIGURATION STRINGS:
46  * -------------------------------------------------------
47  * [supplied_section_name]
48  * sensorLabel = CAM3D // A text description
49  * preview_window = true // Show a window with a preview of the
50  *grabbed data in real-time
51  *
52  * open_USB = true // false means ethernet (default: true)
53  * USB_serial = 0x4000002f // only for open_USB=true. If not set, the
54  *first camera will be open. Serial is the last part of S/N (e.g. for the
55  *camera SN: 00-00-40-00-00-2F).
56  * IP_address = 192.168.2.14 // only for open_USB=false. The IP of the
57  *camera.
58  *
59  * // Options for the data to save in each CObservation3DRangeScan
60  * save_3d = true // Save the 3D point cloud (default:
61  *true)
62  * save_range_img = true // Save the 2D range image (default:
63  *true)
64  * save_intensity_img = true // Save the 2D intensity image
65  *(default:
66  *true)
67  * save_confidence = true // Save the estimated confidence 2D
68  *image
69  *(default: false)
70  *
71  * enable_img_hist_equal = false // Enable intensity image histogram
72  *equalization (default: false)
73  * enable_median_filter = true // Enable median filter in range
74  *data
75  *(default: true)
76  * enable_mediancross_filter = false // Enable median cross-filter
77  *(default:
78  *false)
79  * enable_conv_gray = false // Enable intensity image scale with
80  *range
81  *(default: false)
82  * enable_denoise_anf = true // Enable this noise filter
83  *(default:
84  *true)
85  *
86  * // Camera calibration parameters: See mrpt::img::TCamera
87  * // If not provided, a set of default parameters for a SR4000 camera will
88  *be loaded.
89  * resolution = [176 144]
90  * cx = 87.99958
91  * cy = 68.99957
92  * fx = 262.9201
93  * fy = 262.9218
94  * dist = [-8.258543e-01 6.561022e-01 2.699818e-06 -3.263559e-05 0]
95  *
96  * // For externaly stored images, the format of image files (default=jpg)
97  * //external_images_format = jpg
98  * // (Only when external_images_format=jpg): Optional parameter to set the
99  *JPEG compression quality:
100  * //external_images_jpeg_quality = 95 // [1-100]. Default: 95
101  *
102  * pose_x=0.21 // Camera position in the robot (meters)
103  * pose_y=0
104  * pose_z=0.34
105  * pose_yaw=0 // Angles in degrees
106  * pose_pitch=0
107  * pose_roll=0
108  *
109  * \endcode
110  * \ingroup mrpt_hwdrivers_grp
111  */
113 {
115 
116  public:
117  /** Default ctor */
119  /** Default ctor */
121 
122  /** Initializes the 3D camera - should be invoked after calling loadConfig()
123  * \exception This method must throw an exception with a descriptive
124  * message if some critical error is found.
125  */
126  virtual void initialize();
127 
128  /** To be called at a high rate (>XX Hz), this method populates the
129  * internal buffer of received observations.
130  * This method is mainly intended for usage within rawlog-grabber or
131  * similar programs.
132  * For an alternative, see getNextObservation()
133  * \exception This method must throw an exception with a descriptive
134  * message if some critical error is found.
135  * \sa getNextObservation
136  */
137  virtual void doProcess();
138 
139  /** The main data retrieving function, to be called after calling
140  * loadConfig() and initialize().
141  * \param out_obs The output retrieved observation (only if
142  * there_is_obs=true).
143  * \param there_is_obs If set to false, there was no new observation.
144  * \param hardware_error True on hardware/comms error.
145  *
146  * \sa doProcess
147  */
148  void getNextObservation(
149  mrpt::obs::CObservation3DRangeScan& out_obs, bool& there_is_obs,
150  bool& hardware_error);
151 
152  /** return false on error - Called automatically from initialize(), no need
153  * normally for the user to call this. */
154  bool open();
155  void close();
156 
157  /** whether the camera is open and comms work ok. To be called after
158  * initialize() */
159  bool isOpen() const;
160 
161  /** Get the row count in the camera images, loaded automatically upon camera
162  * open(). */
163  size_t rows() const { return m_rows; }
164  /** Get the col count in the camera images, loaded automatically upon camera
165  * open(). */
166  size_t cols() const { return m_cols; }
167  /** Get the camera serial number, loaded automatically upon camera open().
168  */
169  unsigned int getCameraSerialNumber() const { return m_cam_serial_num; }
170  /** Returns the maximum camera range, as deduced from its operating
171  * frequency. */
172  double getMaxRange() const { return m_maxRange; }
173  /** Set the path where to save off-rawlog image files (this class DOES take
174  * into account this path).
175  * An empty string (the default value at construction) means to save
176  * images embedded in the rawlog, instead of on separate files.
177  * \exception std::exception If the directory doesn't exists and cannot be
178  * created.
179  */
180  virtual void setPathForExternalImages(const std::string& directory);
181 
182  /** @name Capture configuration methods (apart from loadConfig)
183  @{ */
184 
185  /** true: open from USB, false: open from ethernet. */
186  inline void setOpenFromUSB(bool USB) { m_open_from_usb = USB; }
187  inline bool getOpenFromUSBMode() const { return m_open_from_usb; }
188  inline void setOpenIPAddress(const std::string& IP) { m_ip_address = IP; }
189  inline std::string getOpenIPAddress() const { return m_ip_address; }
190  inline void setSave3D(bool save) { m_save_3d = save; }
191  inline void setSaveRangeImage(bool save) { m_save_range_img = save; }
192  inline void setSaveIntensityImage(bool save)
193  {
194  m_save_intensity_img = save;
195  }
196  inline void setSaveConfidenceImage(bool save) { m_save_confidence = save; }
197  inline void enableImageHistEqualization(bool enable)
198  {
199  m_enable_img_hist_equal = enable;
200  }
201  inline bool isEnabledImageHistEqualization() const
202  {
204  }
205 
206  inline void enableMedianFilter(bool enable)
207  {
208  m_enable_median_filter = enable;
210  }
211  inline bool isEnabledMedianFilter() const { return m_enable_median_filter; }
212  inline void enableMedianCrossFilter(bool enable)
213  {
216  }
217  inline bool isEnabledMedianCrossFilter() const
218  {
220  }
221 
222  inline void enableConvGray(bool enable)
223  {
224  m_enable_conv_gray = enable;
226  }
227  inline bool isEnabledConvGray() const { return m_enable_conv_gray; }
228  inline void enableDenoiseANF(bool enable)
229  {
230  m_enable_denoise_anf = enable;
232  }
233  inline bool isEnabledDenoiseANF() const { return m_enable_denoise_anf; }
234  inline void enablePreviewWindow(bool enable = true)
235  {
236  m_preview_window = enable;
237  }
238  inline bool isEnabledPreviewWindow() const { return m_preview_window; }
239  /** @} */
240 
241  // List of small functions to be implemented differently in Win/Lin.
242 
243  /** Get the version of the MESA library.
244  * \return false on error
245  */
246  bool getMesaLibVersion(std::string& out_version) const;
247 
248  protected:
249  /** See the class documentation at the top for expected parameters */
250  virtual void loadConfig_sensorSpecific(
251  const mrpt::config::CConfigFileBase& configSource,
252  const std::string& section);
253 
254  void internal_resendParamsToCamera() const;
255 
257 
258  /** Save the 3D point cloud (default: true) */
259  bool m_save_3d;
260  /** Save the 2D range image (default: true) */
262  /** Save the 2D intensity image (default: true) */
264  /** Save the estimated confidence 2D image (default: false) */
266 
272 
273  /** true: USB, false: ETH */
275  size_t m_usb_serial;
277 
278  /** Size of camera images, set on open() */
279  size_t m_rows, m_cols;
280  /** Serial number of the camera, set on open() */
281  unsigned int m_cam_serial_num;
282  /** Max range, as deducted from the camera frequency. */
283  double m_maxRange;
284 
285  /** Show preview window while grabbing */
288 
289  /** opaque handler to SRCAM. nullptr means it's not open yet. */
290  void* m_cam;
291 
293 
294  private:
295 }; // End of class
296 
297 } // End of NS
298 } // End of NS
299 
300 #endif
mrpt::hwdrivers::CSwissRanger3DCamera::m_enable_conv_gray
bool m_enable_conv_gray
Definition: CSwissRanger3DCamera.h:270
mrpt::hwdrivers::CSwissRanger3DCamera::isEnabledImageHistEqualization
bool isEnabledImageHistEqualization() const
Definition: CSwissRanger3DCamera.h:201
mrpt::hwdrivers::CSwissRanger3DCamera::loadConfig_sensorSpecific
virtual void loadConfig_sensorSpecific(const mrpt::config::CConfigFileBase &configSource, const std::string &section)
See the class documentation at the top for expected parameters.
Definition: CSwissRanger3DCamera.cpp:175
mrpt::hwdrivers::CSwissRanger3DCamera::m_win_int
mrpt::gui::CDisplayWindow::Ptr m_win_int
Definition: CSwissRanger3DCamera.h:287
mrpt::hwdrivers::CSwissRanger3DCamera::m_cam
void * m_cam
opaque handler to SRCAM.
Definition: CSwissRanger3DCamera.h:290
mrpt::hwdrivers::CSwissRanger3DCamera::~CSwissRanger3DCamera
~CSwissRanger3DCamera()
Default ctor.
Definition: CSwissRanger3DCamera.cpp:93
mrpt::hwdrivers::CSwissRanger3DCamera::m_usb_serial
size_t m_usb_serial
Definition: CSwissRanger3DCamera.h:275
mrpt::hwdrivers::CSwissRanger3DCamera::isEnabledMedianCrossFilter
bool isEnabledMedianCrossFilter() const
Definition: CSwissRanger3DCamera.h:217
mrpt::hwdrivers::CSwissRanger3DCamera::m_rows
size_t m_rows
Size of camera images, set on open()
Definition: CSwissRanger3DCamera.h:279
mrpt::hwdrivers::CSwissRanger3DCamera::setSave3D
void setSave3D(bool save)
Definition: CSwissRanger3DCamera.h:190
mrpt::hwdrivers::CSwissRanger3DCamera::isEnabledMedianFilter
bool isEnabledMedianFilter() const
Definition: CSwissRanger3DCamera.h:211
mrpt::hwdrivers::CSwissRanger3DCamera::m_enable_mediancross_filter
bool m_enable_mediancross_filter
Definition: CSwissRanger3DCamera.h:269
mrpt::hwdrivers::CSwissRanger3DCamera::enableConvGray
void enableConvGray(bool enable)
Definition: CSwissRanger3DCamera.h:222
mrpt::hwdrivers::CSwissRanger3DCamera::enableMedianCrossFilter
void enableMedianCrossFilter(bool enable)
Definition: CSwissRanger3DCamera.h:212
mrpt::hwdrivers::CSwissRanger3DCamera::m_win_range
mrpt::gui::CDisplayWindow::Ptr m_win_range
Definition: CSwissRanger3DCamera.h:287
mrpt::hwdrivers::CSwissRanger3DCamera::m_cols
size_t m_cols
Definition: CSwissRanger3DCamera.h:279
mrpt::hwdrivers::CSwissRanger3DCamera::getMesaLibVersion
bool getMesaLibVersion(std::string &out_version) const
Get the version of the MESA library.
Definition: CSwissRanger3DCamera.cpp:235
mrpt::hwdrivers::CSwissRanger3DCamera::getMaxRange
double getMaxRange() const
Returns the maximum camera range, as deduced from its operating frequency.
Definition: CSwissRanger3DCamera.h:172
mrpt::hwdrivers::CSwissRanger3DCamera::setOpenFromUSB
void setOpenFromUSB(bool USB)
true: open from USB, false: open from ethernet.
Definition: CSwissRanger3DCamera.h:186
mrpt::hwdrivers::CSwissRanger3DCamera::m_sensorPoseOnRobot
mrpt::poses::CPose3D m_sensorPoseOnRobot
Definition: CSwissRanger3DCamera.h:256
CObservation3DRangeScan.h
mrpt::hwdrivers::CSwissRanger3DCamera::m_cameraParams
mrpt::img::TCamera m_cameraParams
Definition: CSwissRanger3DCamera.h:292
mrpt::hwdrivers::CSwissRanger3DCamera::rows
size_t rows() const
Get the row count in the camera images, loaded automatically upon camera open().
Definition: CSwissRanger3DCamera.h:163
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::hwdrivers::CSwissRanger3DCamera::m_save_intensity_img
bool m_save_intensity_img
Save the 2D intensity image (default: true)
Definition: CSwissRanger3DCamera.h:263
DEFINE_GENERIC_SENSOR
#define DEFINE_GENERIC_SENSOR(class_name)
This declaration must be inserted in all CGenericSensor classes definition, within the class declarat...
Definition: CGenericSensor.h:314
mrpt::hwdrivers::CSwissRanger3DCamera::initialize
virtual void initialize()
Initializes the 3D camera - should be invoked after calling loadConfig()
Definition: CSwissRanger3DCamera.cpp:135
mrpt::hwdrivers::CSwissRanger3DCamera::m_ip_address
std::string m_ip_address
Definition: CSwissRanger3DCamera.h:276
mrpt::hwdrivers::CSwissRanger3DCamera::m_save_confidence
bool m_save_confidence
Save the estimated confidence 2D image (default: false)
Definition: CSwissRanger3DCamera.h:265
mrpt::hwdrivers::CSwissRanger3DCamera::setSaveIntensityImage
void setSaveIntensityImage(bool save)
Definition: CSwissRanger3DCamera.h:192
mrpt::gui::CDisplayWindow::Ptr
std::shared_ptr< CDisplayWindow > Ptr
Definition: CDisplayWindow.h:33
mrpt::hwdrivers::CSwissRanger3DCamera::m_enable_img_hist_equal
bool m_enable_img_hist_equal
Definition: CSwissRanger3DCamera.h:267
mrpt::hwdrivers::CSwissRanger3DCamera::m_save_3d
bool m_save_3d
Save the 3D point cloud (default: true)
Definition: CSwissRanger3DCamera.h:259
mrpt::hwdrivers::CSwissRanger3DCamera::m_enable_median_filter
bool m_enable_median_filter
Definition: CSwissRanger3DCamera.h:268
mrpt::hwdrivers::CSwissRanger3DCamera::enablePreviewWindow
void enablePreviewWindow(bool enable=true)
Definition: CSwissRanger3DCamera.h:234
mrpt::obs::CObservation3DRangeScan
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement,...
Definition: CObservation3DRangeScan.h:224
mrpt::hwdrivers::CSwissRanger3DCamera::enableDenoiseANF
void enableDenoiseANF(bool enable)
Definition: CSwissRanger3DCamera.h:228
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::CSwissRanger3DCamera::m_preview_window
bool m_preview_window
Show preview window while grabbing.
Definition: CSwissRanger3DCamera.h:286
mrpt::hwdrivers::CSwissRanger3DCamera::isOpen
bool isOpen() const
whether the camera is open and comms work ok.
Definition: CSwissRanger3DCamera.cpp:250
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
CGenericSensor.h
mrpt::hwdrivers::CSwissRanger3DCamera::m_open_from_usb
bool m_open_from_usb
true: USB, false: ETH
Definition: CSwissRanger3DCamera.h:274
mrpt::hwdrivers::CSwissRanger3DCamera::enableMedianFilter
void enableMedianFilter(bool enable)
Definition: CSwissRanger3DCamera.h:206
mrpt::hwdrivers::CSwissRanger3DCamera::m_save_range_img
bool m_save_range_img
Save the 2D range image (default: true)
Definition: CSwissRanger3DCamera.h:261
mrpt::hwdrivers::CSwissRanger3DCamera::setSaveConfidenceImage
void setSaveConfidenceImage(bool save)
Definition: CSwissRanger3DCamera.h:196
mrpt::hwdrivers::CSwissRanger3DCamera::m_maxRange
double m_maxRange
Max range, as deducted from the camera frequency.
Definition: CSwissRanger3DCamera.h:283
mrpt::img::TCamera
Structure to hold the parameters of a pinhole camera model.
Definition: TCamera.h:29
mrpt::hwdrivers::CSwissRanger3DCamera::isEnabledConvGray
bool isEnabledConvGray() const
Definition: CSwissRanger3DCamera.h:227
mrpt::hwdrivers::CSwissRanger3DCamera::getOpenFromUSBMode
bool getOpenFromUSBMode() const
Definition: CSwissRanger3DCamera.h:187
mrpt::hwdrivers::CSwissRanger3DCamera::isEnabledPreviewWindow
bool isEnabledPreviewWindow() const
Definition: CSwissRanger3DCamera.h:238
mrpt::hwdrivers::CSwissRanger3DCamera::CSwissRanger3DCamera
CSwissRanger3DCamera()
Default ctor.
Definition: CSwissRanger3DCamera.cpp:45
mrpt::hwdrivers::CGenericSensor
A generic interface for a wide-variety of sensors designed to be used in the application RawLogGrabbe...
Definition: CGenericSensor.h:70
mrpt::hwdrivers::CSwissRanger3DCamera::isEnabledDenoiseANF
bool isEnabledDenoiseANF() const
Definition: CSwissRanger3DCamera.h:233
mrpt::hwdrivers::CSwissRanger3DCamera::setOpenIPAddress
void setOpenIPAddress(const std::string &IP)
Definition: CSwissRanger3DCamera.h:188
mrpt::hwdrivers::CSwissRanger3DCamera::doProcess
virtual void doProcess()
To be called at a high rate (>XX Hz), this method populates the internal buffer of received observati...
Definition: CSwissRanger3DCamera.cpp:144
mrpt::hwdrivers::CSwissRanger3DCamera::getCameraSerialNumber
unsigned int getCameraSerialNumber() const
Get the camera serial number, loaded automatically upon camera open().
Definition: CSwissRanger3DCamera.h:169
mrpt::hwdrivers::CSwissRanger3DCamera::enableImageHistEqualization
void enableImageHistEqualization(bool enable)
Definition: CSwissRanger3DCamera.h:197
mrpt::hwdrivers::CSwissRanger3DCamera::setSaveRangeImage
void setSaveRangeImage(bool save)
Definition: CSwissRanger3DCamera.h:191
mrpt::hwdrivers::CSwissRanger3DCamera::cols
size_t cols() const
Get the col count in the camera images, loaded automatically upon camera open().
Definition: CSwissRanger3DCamera.h:166
mrpt::hwdrivers::CSwissRanger3DCamera
A class for grabing "range images" from a MESA imaging SwissRanger 3D cameras (SR-2,...
Definition: CSwissRanger3DCamera.h:112
mrpt::hwdrivers::CSwissRanger3DCamera::setPathForExternalImages
virtual void setPathForExternalImages(const std::string &directory)
Set the path where to save off-rawlog image files (this class DOES take into account this path).
Definition: CSwissRanger3DCamera.cpp:612
mrpt::hwdrivers::CSwissRanger3DCamera::getNextObservation
void getNextObservation(mrpt::obs::CObservation3DRangeScan &out_obs, bool &there_is_obs, bool &hardware_error)
The main data retrieving function, to be called after calling loadConfig() and initialize().
Definition: CSwissRanger3DCamera.cpp:364
mrpt::hwdrivers::CSwissRanger3DCamera::open
bool open()
return false on error - Called automatically from initialize(), no need normally for the user to call...
Definition: CSwissRanger3DCamera.cpp:251
CObservationImage.h
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::hwdrivers::CSwissRanger3DCamera::m_cam_serial_num
unsigned int m_cam_serial_num
Serial number of the camera, set on open()
Definition: CSwissRanger3DCamera.h:281
mrpt::hwdrivers::CSwissRanger3DCamera::close
void close()
Definition: CSwissRanger3DCamera.cpp:329
CDisplayWindow.h
mrpt::hwdrivers::CSwissRanger3DCamera::internal_resendParamsToCamera
void internal_resendParamsToCamera() const
Definition: CSwissRanger3DCamera.cpp:337
mrpt::hwdrivers::CSwissRanger3DCamera::m_enable_denoise_anf
bool m_enable_denoise_anf
Definition: CSwissRanger3DCamera.h:271
mrpt::hwdrivers::CSwissRanger3DCamera::getOpenIPAddress
std::string getOpenIPAddress() const
Definition: CSwissRanger3DCamera.h:189



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