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