Main MRPT website > C++ reference for MRPT 1.5.7
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-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 CImageGrabber_FlyCapture2_H
10 #define CImageGrabber_FlyCapture2_H
11 
15 #include <mrpt/utils/CUncopiable.h>
16 
17 namespace mrpt
18 {
19  namespace hwdrivers
20  {
21  /** Options used when creating a camera capture object of type CImageGrabber_FlyCapture2 \ingroup mrpt_hwdrivers_grp */
23  {
25 
26  /** @name Camera to open
27  * @{ */
28  unsigned int camera_index; //!< (Default=0) If open_by_guid==false, will open the i'th camera based on this 0-based index.
29  bool open_by_guid; //!< (Default=false) Set to true to force opening a camera by its GUID, in \a camera_guid
30  unsigned int camera_guid[4]; //!< GUID of the camera to open, only when open_by_guid==true.
31  /** @} */
32 
33  /** @name Camera settings
34  * @{ */
35  std::string videomode; //!< (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.
36  std::string framerate; //!< (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.
37  std::string grabmode; //!< (Default="BUFFER_FRAMES") A string with a grab mode, from the list available in [FlyCapture2::GrabMode](http://www.ptgrey.com/support/downloads/documents/flycapture/Doxygen/html/)
38  unsigned int numBuffers; //!< (Default=30) Number of images that can be stored in the buffer, if enabled with grabMode.
39  int grabTimeout; //!< (Default=5000) Time in milliseconds that RetrieveBuffer() and WaitForBufferEvent() will wait for an image before timing out and returning.
40 
41  bool trigger_enabled; //!< (default=false) Enable non-free-running mode, only capturing when a given input trigger signal is detected. Refer to PGR docs.
42  unsigned int trigger_polarity; //!< (default=0) Refer to PGR docs.
43  unsigned int trigger_source; //!< (default=0) Refer to PGR docs.
44  unsigned int trigger_mode; //!< (default=0) Refer to PGR docs.
45 
46  bool strobe_enabled; //!< (default=false) Enable the generation of a strobe signal in GPIO. Refer to PGR docs.
47  unsigned int strobe_source; //!< (default=0) Refer to PGR docs.
48  unsigned int strobe_polarity; //!< (default=0) Refer to PGR docs.
49  float strobe_delay; //!< (default=0.0) Delay in ms. Refer to PGR docs.
50  float strobe_duration; //!< (default=1.0) Pulse durationin ms. Refer to PGR docs.
51 
52  bool autoexposure_auto; //!< (default=true)
53  bool autoexposure_onOff;//!< (default=true) Activate this feature
54  bool autoexposure_abs; //!< (default=true) Numeric mode (absolute or integer values)
55  float autoexposure_EV; //!< (default=0.0) Exposure Value, if autoexposure_auto=false
56  bool shutter_auto; //!< (default=true)
57  bool shutter_abs; //!< (default=true) Numeric mode (absolute or integer values)
58  float shutter_time_ms; //!< (default=4.0) Shutter time, if shutter_auto=false
59  bool gain_auto; //!< (default=true)
60  bool gain_abs; //!< (default=true) Numeric mode (absolute or integer values)
61  float gain_dB; //!< (default=0.0) Sensor gain, if gain_auto=false
62 
63  bool stereo_mode; //!< (default=false) Obtain images as stereo pairs with Flycapture2
64  bool get_rectified; //!< (default=false) Rectify stereo images (needs Triclops installed)
65  unsigned int rect_width; //!< (default=640) Width for output rectified images
66  unsigned int rect_height; //!< (default=480) Height for output rectified images
67  /** @} */
68 
69  /** Loads all the options from a config file.
70  * Expected format:
71  *
72  * \code
73  * [sectionName]
74  * # Camera selection:
75  * camera_index = 0 // (Default=0) If open_by_guid==false, will open the i'th camera based on this 0-based index.
76  * open_by_guid = false // (Default=false) Set to true to force opening a camera by its GUID, in \a camera_guid
77  * camera_guid = 11223344-55667788-99AABBCC-DDEEFF00 // GUID of the camera to open, only when open_by_guid==true. Hexadecimal blocks separated by dashes ("-")
78  *
79  * # Camera settings:
80  * 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.
81  * 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.
82  * grabmode = BUFFER_FRAMES // (Default="BUFFER_FRAMES") A string with a grab mode, from the list available in [FlyCapture2::GrabMode](http://www.ptgrey.com/support/downloads/documents/flycapture/Doxygen/html/)
83  * numBuffers = 30 // (Default=30) Number of images that can be stored in the buffer, if enabled with grabMode.
84  * grabTimeout = 5000 // (Default=5000) Time in milliseconds that RetrieveBuffer() and WaitForBufferEvent() will wait for an image before timing out and returning.
85  *
86  * trigger_enabled = false // (default=false) Enable non-free-running mode, only capturing when a given input trigger signal is detected. Refer to PGR docs.
87  * #trigger_polarity = 0 // (default=0) Refer to PGR docs.
88  * #trigger_source = 0 // (default=0) Refer to PGR docs.
89  * #trigger_mode = 0 // (default=0) Refer to PGR docs.
90  *
91  * strobe_enabled = false // (default=false) Enable the generation of a strobe signal in GPIO. Refer to PGR docs.
92  * #strobe_source = 1 // (default=0) Refer to PGR docs.
93  * #strobe_polarity = 0 // (default=0) Refer to PGR docs.
94  * #strobe_delay = 0.0 // (default=0.0) Delay in ms. Refer to PGR docs.
95  * #strobe_duration = 1.0 // (default=1.0) Pulse durationin ms. Refer to PGR docs.
96  *
97  * #autoexposure_auto; //!< (default=true)
98  * #autoexposure_abs; //!< (default=true) Numeric mode (absolute or integer values)
99  * #autoexposure_onoff;//!< (default=true) Activate this feature
100  * #autoexposure_EV; //!< (default=0.0) Exposure Value, if autoexposure_auto=false
101  * #shutter_auto = false // (default=true)
102  * #shutter_abs; //!< (default=true) Numeric mode (absolute or integer values)
103  * #shutter_time_ms = 4.0 // (default=4.0) Shutter time, if shutter_auto=false
104  * #gain_auto; //!< (default=true)
105  * #gain_abs; //!< (default=true) Numeric mode (absolute or integer values)
106  * #gain_dB; //!< (default=0.0) Sensor gain, if gain_auto=false
107  *
108  * flycap_stereo_mode = 1 // (default=0) Obtain images as stereo pairs with Flycapture2
109  * flycap_get_rectified = 1 // (default=0) Rectify stereo images (needs Triclops installed)
110  * flycap_rect_width = 320 // (default=640) Width for output rectified images
111  * flycap_rect_height = 240 // (default=480) Height for output rectified images
112  *
113  * \endcode
114  * \note All parameter names may have an optional prefix, set with the "prefix" parameter.
115  * For example, if prefix="LEFT_", the expected variable name "camera_index" in the config section will be "LEFT_camera_index", and so on.
116  */
117  void loadOptionsFrom(
118  const mrpt::utils::CConfigFileBase & configSource,
119  const std::string & sectionName,
120  const std::string & prefix = std::string() );
121 
122  };
123 
124  /** A wrapper for Point Gray Research (PGR) FlyCapture2 API for capturing images from Firewire, USB3 or GigaE cameras and stereo cameras.
125  * This class is only available when compiling MRPT with "MRPT_HAS_PGR_FLYCAPTURE2".
126  *
127  * \sa See the most generic camera grabber in MRPT: mrpt::hwdrivers::CCameraSensor
128  * \sa See example code in [samples]/captureVideoFlyCapture2 and [samples]/captureVideoFlyCapture2_stereo.
129  * \ingroup mrpt_hwdrivers_grp
130  */
132  {
133  protected:
134  void *m_camera; //!< Opaque pointer to the FlyCapture2::Camera object. NULL if no camera is grabbing.
135  void *m_camera_info; //!< Opaque pointer to the FlyCapture2::CameraInfo object. NULL if no camera is grabbing.
136  void *m_img_buffer; //!< Opaque pointer to the FlyCapture2::Image, used as a temporary buffer and to avoid mem alloc/reallocs.
137  void *m_triclops; //!< Opaque pointer to the TriclopsContext objetc. NULL if no context is active.
138 
139  // Camera intrinsic calibration
140  float m_baseline; //!< Camera baseline (only for stereo cameras)
141  float m_focalLength; //!< Camera focal length
142  float m_centerCol, m_centerRow; //!< Camera center coordinates
143 
145 
146  public:
147  /** Constructor that does not open a camera. \sa open() */
149 
150  /** Constructor: tries to open the camera with the given options. Raises an exception on error. \sa open() */
152 
153  /** Destructor */
154  virtual ~CImageGrabber_FlyCapture2();
155 
156  /** Returns the current settings of the camera */
157  const TCaptureOptions_FlyCapture2 & getCameraOptions() const { return m_options; }
158 
159  /** Tries to open the camera with the given options, and starts capture. Raises an exception on error.
160  * \param[in] startCapture If set to false, the camera is only opened and configured, but a posterior call to startCapture() is required to start grabbing images.
161  * \sa close(), startCapture()
162  */
163  void open( const TCaptureOptions_FlyCapture2 &options, const bool startCapture = true );
164 
165  /** Start the actual image capture of the camera. Must be called after open(), only when "startCapture" was set to false.
166  * \sa startSyncCapture
167  */
168  void startCapture();
169 
170  /** Starts a synchronous capture of several cameras, which must have been already opened.
171  * NOTE: This method only works with Firewire cameras, not with USB3 or GigaE ones (as confirmed by PGR support service).
172  * \sa startCapture
173  */
174  static void startSyncCapture( int numCameras, const CImageGrabber_FlyCapture2 **cameras_array );
175 
176  /** Stop capture. */
177  void stopCapture();
178 
179  /** Stop capture and closes the opened camera, if any. Called automatically on object destruction. */
180  void close();
181 
182  /** Returns the PGR FlyCapture2 library version */
183  static std::string getFC2version();
184 
185  /** Grab mono image from the camera. This method blocks until the next frame is captured.
186  * \return false on any error. */
187  bool getObservation( mrpt::obs::CObservationImage &out_observation );
188 
189  /** Grab stereo image from the camera. This method blocks until the next frame is captured.
190  * \return false on any error. */
191  bool getObservation( mrpt::obs::CObservationStereoImages &out_observation );
192 
193  /** Returns if current configuration is stereo or not */
194  inline bool isStereo(){ return m_options.stereo_mode; }
195 
196  }; // End of class
197 
198  } // End of NS
199 } // End of NS
200 
201 
202 #endif
float strobe_delay
(default=0.0) Delay in ms. Refer to PGR docs.
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. Refer to PGR docs.
bool gain_abs
(default=true) Numeric mode (absolute or integer values)
float autoexposure_EV
(default=0.0) Exposure Value, if autoexposure_auto=false
OBSERVATION_T::Ptr getObservation(mrpt::obs::CSensoryFramePtr &observations, mrpt::obs::CObservationPtr &observation, bool priority_to_sf=true)
Given an mrpt::obs::CSensoryFrame and a mrpt::obs::CObservation pointer if a OBSERVATION_T type obser...
Definition: obs_utils.h:32
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. Refer to PGR docs.
std::string grabmode
(Default="BUFFER_FRAMES") A string with a grab mode, from the list available in FlyCapture2::GrabMode...
This class allows loading and storing values and vectors of different types from a configuration text...
int grabTimeout
(Default=5000) Time in milliseconds that RetrieveBuffer() and WaitForBufferEvent() will wait for an i...
TCaptureOptions_FlyCapture2 m_options
Camera options.
void * m_triclops
Opaque pointer to the TriclopsContext objetc. NULL if no context is active.
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. NULL if no camera is grabbing.
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)
The base class of classes that cannot be copied: compile-time errors will be issued on any copy opera...
Definition: CUncopiable.h:30
bool stereo_mode
(default=false) Obtain images as stereo pairs with Flycapture2
GLsizei const GLchar ** string
Definition: glext.h:3919
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.
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. NULL if no camera is grabbing.
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...
unsigned int trigger_polarity
(default=0) Refer to PGR docs.
bool autoexposure_onOff
(default=true) Activate this feature
unsigned int strobe_polarity
(default=0) Refer to PGR docs.
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.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019