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-2017, 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::utils::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 getRowCount() const { return m_rows; }
164  /** Get the col count in the camera images, loaded automatically upon camera
165  * open(). */
166  size_t getColCount() 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::utils::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
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::utils::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.
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)
This class allows loading and storing values and vectors of different types from a configuration text...
mrpt::gui::CDisplayWindow::Ptr m_win_range
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)
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...
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
std::shared_ptr< CDisplayWindow > Ptr
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...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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:88
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 getColCount() const
Get the col count in the camera images, loaded automatically upon camera open().
void * m_cam
opaque handler to SRCAM.
Structure to hold the parameters of a pinhole camera model.
Definition: TCamera.h:32
size_t getRowCount() const
Get the row count in the camera images, loaded automatically upon camera open().
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: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019