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



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019