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



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