Main MRPT website > C++ reference
MRPT logo
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-2014, 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 shutter_auto; //!< (default=true)
53  float shutter_time_ms; //!< (default=4.0) Shutter time, if shutter_auto=false
54 
55  bool stereo_mode; //!< (default=false) Obtain images as stereo pairs with Flycapture2
56  bool get_rectified; //!< (default=false) Rectify stereo images (needs Triclops installed)
57  unsigned int rect_width; //!< (default=640) Width for output rectified images
58  unsigned int rect_height; //!< (default=480) Height for output rectified images
59  /** @} */
60 
61  /** Loads all the options from a config file.
62  * Expected format:
63  *
64  * \code
65  * [sectionName]
66  * # Camera selection:
67  * camera_index = 0 // (Default=0) If open_by_guid==false, will open the i'th camera based on this 0-based index.
68  * open_by_guid = false // (Default=false) Set to true to force opening a camera by its GUID, in \a camera_guid
69  * camera_guid = 11223344-55667788-99AABBCC-DDEEFF00 // GUID of the camera to open, only when open_by_guid==true. Hexadecimal blocks separated by dashes ("-")
70  *
71  * # Camera settings:
72  * 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.
73  * 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.
74  * 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/)
75  * numBuffers = 30 // (Default=30) Number of images that can be stored in the buffer, if enabled with grabMode.
76  * grabTimeout = 5000 // (Default=5000) Time in milliseconds that RetrieveBuffer() and WaitForBufferEvent() will wait for an image before timing out and returning.
77  *
78  * trigger_enabled = false // (default=false) Enable non-free-running mode, only capturing when a given input trigger signal is detected. Refer to PGR docs.
79  * #trigger_polarity = 0 // (default=0) Refer to PGR docs.
80  * #trigger_source = 0 // (default=0) Refer to PGR docs.
81  * #trigger_mode = 0 // (default=0) Refer to PGR docs.
82  *
83  * strobe_enabled = false // (default=false) Enable the generation of a strobe signal in GPIO. Refer to PGR docs.
84  * #strobe_source = 1 // (default=0) Refer to PGR docs.
85  * #strobe_polarity = 0 // (default=0) Refer to PGR docs.
86  * #strobe_delay = 0.0 // (default=0.0) Delay in ms. Refer to PGR docs.
87  * #strobe_duration = 1.0 // (default=1.0) Pulse durationin ms. Refer to PGR docs.
88  *
89  *
90  * #shutter_auto = false // (default=true)
91  * #shutter_time_ms = 4.0 // (default=4.0) Shutter time, if shutter_auto=false
92  *
93  * \endcode
94  * \note All parameter names may have an optional prefix, set with the "prefix" parameter.
95  * For example, if prefix="LEFT_", the expected variable name "camera_index" in the config section will be "LEFT_camera_index", and so on.
96  */
97  void loadOptionsFrom(
98  const mrpt::utils::CConfigFileBase & configSource,
99  const std::string & sectionName,
100  const std::string & prefix = std::string() );
101 
102  };
103 
104  /** A wrapper for Point Gray Research (PGR) FlyCapture2 API for capturing images from Firewire, USB3 or GigaE cameras.
105  * This class is only available when compiling MRPT with "MRPT_HAS_PGR_FLYCAPTURE2".
106  *
107  * \sa See the most generic camera grabber in MRPT: mrpt::hwdrivers::CCameraSensor
108  * \sa See example code in [samples]/captureVideoFlyCapture2 and [samples]/captureVideoFlyCapture2_stereo.
109  * \ingroup mrpt_hwdrivers_grp
110  */
112  {
113  protected:
114  void *m_camera; //!< Opaque pointer to the FlyCapture2::Camera object. NULL if no camera is grabbing.
115  void *m_camera_info; //!< Opaque pointer to the FlyCapture2::CameraInfo object. NULL if no camera is grabbing.
116  void *m_img_buffer; //!< Opaque pointer to the FlyCapture2::Image, used as a temporary buffer and to avoid mem alloc/reallocs.
117  void *m_triclops; //!< Opaque pointer to the TriclopsContext objetc. NULL if no context is active.
118 
119  // Camera intrinsic calibration
120  float m_baseline; //!< Camera baseline (only for stereo cameras)
121  float m_focalLength; //!< Camera focal length
122  float m_centerCol, m_centerRow; //!< Camera center coordinates
123 
124  TCaptureOptions_FlyCapture2 m_options; //!< Camera options
125 
126  public:
127  /** Constructor that does not open a camera. \sa open() */
129 
130  /** Constructor: tries to open the camera with the given options. Raises an exception on error. \sa open() */
131  CImageGrabber_FlyCapture2( const TCaptureOptions_FlyCapture2 &options);
132 
133  /** Destructor */
134  virtual ~CImageGrabber_FlyCapture2();
135 
136  /** Returns the current settings of the camera */
137  const TCaptureOptions_FlyCapture2 & getCameraOptions() const { return m_options; }
138 
139  /** Tries to open the camera with the given options, and starts capture. Raises an exception on error.
140  * \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.
141  * \sa close(), startCapture()
142  */
143  void open( const TCaptureOptions_FlyCapture2 &options, const bool startCapture = true );
144 
145  /** Start the actual image capture of the camera. Must be called after open(), only when "startCapture" was set to false.
146  * \sa startSyncCapture
147  */
148  void startCapture();
149 
150  /** Starts a synchronous capture of several cameras, which must have been already opened.
151  * NOTE: This method only works with Firewire cameras, not with USB3 or GigaE ones (as confirmed by PGR support service).
152  * \sa startCapture
153  */
154  static void startSyncCapture( int numCameras, const CImageGrabber_FlyCapture2 **cameras_array );
155 
156  /** Stop capture. */
157  void stopCapture();
158 
159  /** Stop capture and closes the opened camera, if any. Called automatically on object destruction. */
160  void close();
161 
162  /** Returns the PGR FlyCapture2 library version */
163  static std::string getFC2version();
164 
165  /** Grab mono image from the camera. This method blocks until the next frame is captured.
166  * \return false on any error. */
167  bool getObservation( mrpt::slam::CObservationImage &out_observation );
168 
169  /** Grab stereo image from the camera. This method blocks until the next frame is captured.
170  * \return false on any error. */
171  bool getObservation( mrpt::slam::CObservationStereoImages &out_observation );
172 
173  /** Returns if current configuration is stereo or not */
174  inline bool isStereo(){ return m_options.stereo_mode; }
175 
176  }; // End of class
177 
178  } // End of NS
179 } // End of NS
180 
181 
182 #endif
float strobe_delay
(default=0.0) Delay in ms. Refer to PGR docs.
bool strobe_enabled
(default=false) Enable the generation of a strobe signal in GPIO. Refer to PGR docs.
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.
const TCaptureOptions_FlyCapture2 & getCameraOptions() const
Returns the current settings of the camera.
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:...
Options used when creating a camera capture object of type CImageGrabber_FlyCapture2.
unsigned int rect_height
(default=480) Height for output rectified images
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
Declares a class derived from "CObservation" that encapsules an image from a camera, whose relative pose to robot is also stored.
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.
Observation class for either a pair of left+right or left+disparity images from a stereo camera...
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.
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::...
bool get_rectified
(default=false) Rectify stereo images (needs Triclops installed)
unsigned int camera_index
(Default=0) If open_by_guid==false, will open the i'th camera based on this 0-based index...
#define HWDRIVERS_IMPEXP
unsigned int trigger_polarity
(default=0) Refer to PGR docs.
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.8 for MRPT 1.2.2 SVN:Unversioned directory at Tue Oct 14 02:14:08 UTC 2014