MRPT  1.9.9
CImageGrabber_FlyCapture2.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 CImageGrabber_FlyCapture2_H
10 #define CImageGrabber_FlyCapture2_H
11 
14 
15 namespace mrpt::hwdrivers
16 {
17 /** Options used when creating a camera capture object of type
18  * CImageGrabber_FlyCapture2 \ingroup mrpt_hwdrivers_grp */
20 {
22 
23  /** @name Camera to open
24  * @{ */
25  /** (Default=0) If open_by_guid==false, will open the i'th camera based on
26  * this 0-based index. */
27  unsigned int camera_index;
28  /** (Default=false) Set to true to force opening a camera by its GUID, in \a
29  * camera_guid */
31  /** GUID of the camera to open, only when open_by_guid==true. */
32  unsigned int camera_guid[4];
33  /** @} */
34 
35  /** @name Camera settings
36  * @{ */
37  /** (Default="", which means default) A string with a video mode, from the
38  * list available in
39  * [FlyCapture2::VideoMode](http://www.ptgrey.com/support/downloads/documents/flycapture/Doxygen/html/),
40  * eg. "VIDEOMODE_640x480Y8", etc. */
42  /** (Default="", which means default) A string with a framerate, from the
43  * list available in
44  * [FlyCapture2::FrameRate](http://www.ptgrey.com/support/downloads/documents/flycapture/Doxygen/html/),
45  * eg. "FRAMERATE_30", etc. */
47  /** (Default="BUFFER_FRAMES") A string with a grab mode, from the list
48  * available in
49  * [FlyCapture2::GrabMode](http://www.ptgrey.com/support/downloads/documents/flycapture/Doxygen/html/)
50  */
52  /** (Default=30) Number of images that can be stored in the buffer, if
53  * enabled with grabMode. */
54  unsigned int numBuffers;
55  /** (Default=5000) Time in milliseconds that RetrieveBuffer() and
56  * WaitForBufferEvent() will wait for an image before timing out and
57  * returning. */
59 
60  /** (default=false) Enable non-free-running mode, only capturing when a
61  * given input trigger signal is detected. Refer to PGR docs. */
63  /** (default=0) Refer to PGR docs. */
64  unsigned int trigger_polarity;
65  /** (default=0) Refer to PGR docs. */
66  unsigned int trigger_source;
67  /** (default=0) Refer to PGR docs. */
68  unsigned int trigger_mode;
69 
70  /** (default=false) Enable the generation of a strobe signal in GPIO. Refer
71  * to PGR docs. */
73  /** (default=0) Refer to PGR docs. */
74  unsigned int strobe_source;
75  /** (default=0) Refer to PGR docs. */
76  unsigned int strobe_polarity;
77  /** (default=0.0) Delay in ms. Refer to PGR docs. */
78  float strobe_delay;
79  /** (default=1.0) Pulse durationin ms. Refer to PGR docs. */
81 
82  /** (default=true) */
84  /** (default=true) Activate this feature */
86  /** (default=true) Numeric mode (absolute or integer values) */
88  /** (default=0.0) Exposure Value, if autoexposure_auto=false */
90  /** (default=true) */
92  /** (default=true) Numeric mode (absolute or integer values) */
94  /** (default=4.0) Shutter time, if shutter_auto=false */
96  /** (default=true) */
97  bool gain_auto;
98  /** (default=true) Numeric mode (absolute or integer values) */
99  bool gain_abs;
100  /** (default=0.0) Sensor gain, if gain_auto=false */
101  float gain_dB;
102 
103  /** (default=false) Obtain images as stereo pairs with Flycapture2 */
105  /** (default=false) Rectify stereo images (needs Triclops installed) */
107  /** (default=640) Width for output rectified images */
108  unsigned int rect_width;
109  /** (default=480) Height for output rectified images */
110  unsigned int rect_height;
111  /** @} */
112 
113  // clang-format off
114  /** Loads all the options from a config file.
115  * Expected format:
116  *
117  * \code
118  * [sectionName]
119  * # Camera selection:
120  * camera_index = 0 // (Default=0) If open_by_guid==false, will open the i'th camera based on this 0-based index.
121  * open_by_guid = false // (Default=false) Set to true to force opening a camera by its GUID, in \a camera_guid
122  * camera_guid = 11223344-55667788-99AABBCC-DDEEFF00 // GUID of the camera to open, only when open_by_guid==true. Hexadecimal blocks separated by dashes ("-")
123  *
124  * # Camera settings:
125  * videomode = VIDEOMODE_640x480Y8 // (Default="", which means default) A string with a video mode, from the list available in [FlyCapture2::VideoMode](http://www.ptgrey.com/support/downloads/documents/flycapture/Doxygen/html/), eg. "VIDEOMODE_640x480Y8", etc.
126  * framerate = FRAMERATE_30 // (Default="", which means default) A string with a framerate, from the list available in [FlyCapture2::FrameRate](http://www.ptgrey.com/support/downloads/documents/flycapture/Doxygen/html/), eg. "FRAMERATE_30", etc.
127  * grabmode = BUFFER_FRAMES // (Default="BUFFER_FRAMES") A string with a grab mode, from the list available in
128  * [FlyCapture2::GrabMode](http://www.ptgrey.com/support/downloads/documents/flycapture/Doxygen/html/)
129  * numBuffers = 30 // (Default=30) Number of images that
130  * can be stored in the buffer, if enabled with grabMode.
131  * grabTimeout = 5000 // (Default=5000) Time in milliseconds that RetrieveBuffer() and WaitForBufferEvent() will wait for an image before timing out and returning.
132  *
133  * trigger_enabled = false // (default=false) Enable non-free-running mode, only capturing when a given input trigger signal is detected. Refer to PGR docs.
134  * #trigger_polarity = 0 // (default=0) Refer to PGR docs.
135  * #trigger_source = 0 // (default=0) Refer to PGR docs.
136  * #trigger_mode = 0 // (default=0) Refer to PGR docs.
137  *
138  * strobe_enabled = false // (default=false) Enable the generation of a strobe signal in GPIO. Refer to PGR docs.
139  * #strobe_source = 1 // (default=0) Refer to PGR docs.
140  * #strobe_polarity = 0 // (default=0) Refer to PGR docs.
141  * #strobe_delay = 0.0 // (default=0.0) Delay in ms. Refer to PGR docs.
142  * #strobe_duration = 1.0 // (default=1.0) Pulse durationin ms. Refer to PGR docs.
143  *
144  * #autoexposure_auto; //!< (default=true)
145  * #autoexposure_abs; //!< (default=true) Numeric mode (absolute or integer values)
146  * #autoexposure_onoff;//!< (default=true) Activate this feature
147  * #autoexposure_EV; //!< (default=0.0) Exposure Value, if autoexposure_auto=false
148  * #shutter_auto = false // (default=true)
149  * #shutter_abs; //!< (default=true) Numeric mode (absolute or integer values)
150  * #shutter_time_ms = 4.0 // (default=4.0) Shutter time, if shutter_auto=false
151  * #gain_auto; //!< (default=true)
152  * #gain_abs; //!< (default=true) Numeric mode (absolute or integer values)
153  * #gain_dB; //!< (default=0.0) Sensor gain, if gain_auto=false
154  *
155  * flycap_stereo_mode = 1 // (default=0) Obtain images as stereo pairs with Flycapture2
156  * flycap_get_rectified = 1 // (default=0) Rectify stereo images (needs Triclops installed)
157  * flycap_rect_width = 320 // (default=640) Width for output rectified images
158  * flycap_rect_height = 240 // (default=480) Height for output rectified images
159  *
160  * \endcode
161  * \note All parameter names may have an optional prefix, set with the
162  * "prefix" parameter.
163  * For example, if prefix="LEFT_", the expected variable name
164  * "camera_index" in the config section will be "LEFT_camera_index", and so
165  * on.
166  */
167  void loadOptionsFrom(
168  const mrpt::config::CConfigFileBase& configSource,
169  const std::string& sectionName,
170  const std::string& prefix = std::string());
171  // clang-format on
172 };
173 
174 /** A wrapper for Point Gray Research (PGR) FlyCapture2 API for capturing images
175  * from Firewire, USB3 or GigaE cameras and stereo cameras.
176  * This class is only available when compiling MRPT with
177  * "MRPT_HAS_PGR_FLYCAPTURE2".
178  *
179  * \sa See the most generic camera grabber in MRPT:
180  * mrpt::hwdrivers::CCameraSensor
181  * \sa See example code in [samples]/captureVideoFlyCapture2 and
182  * [samples]/captureVideoFlyCapture2_stereo.
183  * \ingroup mrpt_hwdrivers_grp
184  */
186 {
187  protected:
188  /** Opaque pointer to the FlyCapture2::Camera object. nullptr if no camera
189  * is grabbing. */
190  void* m_camera;
191  /** Opaque pointer to the FlyCapture2::CameraInfo object. nullptr if no
192  * camera is grabbing. */
194  /** Opaque pointer to the FlyCapture2::Image, used as a temporary buffer and
195  * to avoid mem alloc/reallocs. */
197  /** Opaque pointer to the TriclopsContext objetc. nullptr if no context is
198  * active. */
199  void* m_triclops;
200 
201  // Camera intrinsic calibration
202  /** Camera baseline (only for stereo cameras) */
203  float m_baseline;
204  /** Camera focal length */
206  /** Camera center coordinates */
208 
209  /** Camera options */
211 
212  public:
213  /** Constructor that does not open a camera. \sa open() */
215 
218  delete;
219 
220  /** Constructor: tries to open the camera with the given options. Raises an
221  * exception on error. \sa open() */
223 
224  /** Destructor */
225  virtual ~CImageGrabber_FlyCapture2();
226 
227  /** Returns the current settings of the camera */
229  {
230  return m_options;
231  }
232 
233  /** Tries to open the camera with the given options, and starts capture.
234  * Raises an exception on error.
235  * \param[in] startCapture If set to false, the camera is only opened and
236  * configured, but a posterior call to startCapture() is required to start
237  * grabbing images.
238  * \sa close(), startCapture()
239  */
240  void open(
241  const TCaptureOptions_FlyCapture2& options,
242  const bool startCapture = true);
243 
244  /** Start the actual image capture of the camera. Must be called after
245  * open(), only when "startCapture" was set to false.
246  * \sa startSyncCapture
247  */
248  void startCapture();
249 
250  /** Starts a synchronous capture of several cameras, which must have been
251  * already opened.
252  * NOTE: This method only works with Firewire cameras, not with USB3 or
253  * GigaE ones (as confirmed by PGR support service).
254  * \sa startCapture
255  */
256  static void startSyncCapture(
257  int numCameras, const CImageGrabber_FlyCapture2** cameras_array);
258 
259  /** Stop capture. */
260  void stopCapture();
261 
262  /** Stop capture and closes the opened camera, if any. Called automatically
263  * on object destruction. */
264  void close();
265 
266  /** Returns the PGR FlyCapture2 library version */
267  static std::string getFC2version();
268 
269  /** Grab mono image from the camera. This method blocks until the next frame
270  * is captured.
271  * \return false on any error. */
272  bool getObservation(mrpt::obs::CObservationImage& out_observation);
273 
274  /** Grab stereo image from the camera. This method blocks until the next
275  * frame is captured.
276  * \return false on any error. */
278 
279  /** Returns if current configuration is stereo or not */
280  inline bool isStereo() { return m_options.stereo_mode; }
281 }; // End of class
282 static_assert(
285  "Copy Check");
286 }
287 #endif
288 
289 
void close()
Stop capture and closes the opened camera, if any.
bool getObservation(mrpt::obs::CObservationImage &out_observation)
Grab mono image from the camera.
Declares a class derived from "CObservation" that encapsules an image from a camera, whose relative pose to robot is also stored.
bool strobe_enabled
(default=false) Enable the generation of a strobe signal in GPIO.
bool gain_abs
(default=true) Numeric mode (absolute or integer values)
float autoexposure_EV
(default=0.0) Exposure Value, if autoexposure_auto=false
void * m_img_buffer
Opaque pointer to the FlyCapture2::Image, used as a temporary buffer and to avoid mem alloc/reallocs...
A wrapper for Point Gray Research (PGR) FlyCapture2 API for capturing images from Firewire...
float m_baseline
Camera baseline (only for stereo cameras)
float strobe_duration
(default=1.0) Pulse durationin ms.
Contains classes for various device interfaces.
std::string grabmode
(Default="BUFFER_FRAMES") A string with a grab mode, from the list available in FlyCapture2::GrabMode...
void startCapture()
Start the actual image capture of the camera.
CImageGrabber_FlyCapture2()
Constructor that does not open a camera.
int grabTimeout
(Default=5000) Time in milliseconds that RetrieveBuffer() and WaitForBufferEvent() will wait for an i...
TCaptureOptions_FlyCapture2 m_options
Camera options.
This class allows loading and storing values and vectors of different types from a configuration text...
void * m_triclops
Opaque pointer to the TriclopsContext objetc.
unsigned int trigger_source
(default=0) Refer to PGR docs.
unsigned int strobe_source
(default=0) Refer to PGR docs.
unsigned int rect_width
(default=640) Width for output rectified images
void * m_camera_info
Opaque pointer to the FlyCapture2::CameraInfo object.
std::string videomode
(Default="", which means default) A string with a video mode, from the list available in FlyCapture2:...
Observation class for either a pair of left+right or left+disparity images from a stereo camera...
Options used when creating a camera capture object of type CImageGrabber_FlyCapture2.
unsigned int rect_height
(default=480) Height for output rectified images
bool autoexposure_abs
(default=true) Numeric mode (absolute or integer values)
bool stereo_mode
(default=false) Obtain images as stereo pairs with Flycapture2
GLsizei const GLchar ** string
Definition: glext.h:4101
bool trigger_enabled
(default=false) Enable non-free-running mode, only capturing when a given input trigger signal is det...
bool isStereo()
Returns if current configuration is stereo or not.
static void startSyncCapture(int numCameras, const CImageGrabber_FlyCapture2 **cameras_array)
Starts a synchronous capture of several cameras, which must have been already opened.
float shutter_time_ms
(default=4.0) Shutter time, if shutter_auto=false
bool shutter_abs
(default=true) Numeric mode (absolute or integer values)
void * m_camera
Opaque pointer to the FlyCapture2::Camera object.
static std::string getFC2version()
Returns the PGR FlyCapture2 library version.
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.
unsigned int trigger_mode
(default=0) Refer to PGR docs.
std::string framerate
(Default="", which means default) A string with a framerate, from the list available in FlyCapture2::...
float gain_dB
(default=0.0) Sensor gain, if gain_auto=false
bool get_rectified
(default=false) Rectify stereo images (needs Triclops installed)
const TCaptureOptions_FlyCapture2 & getCameraOptions() const
Returns the current settings of the camera.
unsigned int camera_index
(Default=0) If open_by_guid==false, will open the i&#39;th camera based on this 0-based index...
CImageGrabber_FlyCapture2 & operator=(const CImageGrabber_FlyCapture2 &)=delete
unsigned int trigger_polarity
(default=0) Refer to PGR docs.
GLsizei const GLfloat * value
Definition: glext.h:4117
bool autoexposure_onOff
(default=true) Activate this feature
unsigned int camera_guid[4]
GUID of the camera to open, only when open_by_guid==true.
unsigned int strobe_polarity
(default=0) Refer to PGR docs.
void open(const TCaptureOptions_FlyCapture2 &options, const bool startCapture=true)
Tries to open the camera with the given options, and starts capture.
unsigned int numBuffers
(Default=30) Number of images that can be stored in the buffer, if enabled with grabMode.
bool open_by_guid
(Default=false) Set to true to force opening a camera by its GUID, in camera_guid ...



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