Main MRPT website > C++ reference for MRPT 1.9.9
CImageGrabber_dc1394.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 CCImageGrabber_dc1394
10 #define CCImageGrabber_dc1394
11 
12 #include <mrpt/config.h>
13 
16 #include <list>
17 
18 namespace mrpt
19 {
20 namespace hwdrivers
21 {
22 typedef enum {
32 
33 typedef enum {
41 
42 /** Options used when creating an dc1394 capture object
43  * All but the frame size, framerate, and color_coding can be changed
44  * dynamically by CImageGrabber_dc1394::changeCaptureOptions
45  * \sa CImageGrabber_dc1394
46  * \ingroup mrpt_hwdrivers_grp
47  */
49 {
51  : frame_width(640),
52  frame_height(480),
55  mode7(-1),
56  shutter(-1),
57  gain(-1),
58  gamma(-1),
59  brightness(-1),
60  exposure(-1),
61  sharpness(-1),
62  white_balance(-1),
63  shutter_mode(-1),
64  gain_mode(-1),
65  gamma_mode(-1),
66  brightness_mode(-1),
67  exposure_mode(-1),
68  sharpness_mode(-1),
70  deinterlace_stereo(false),
71  trigger_power(-1),
72  trigger_mode(-1),
73  trigger_source(-1),
74  trigger_polarity(-1),
76  {
77  }
78 
79  /** Capture resolution (Default: 640x480) */
83 
84  /** -1: Normal mode, i>=0: use MODE7_i, then frame_width/height and
85  * color_coding are ignored. */
86  int mode7;
87 
88  /** Shutter, -1=default:Do not change */
89  int shutter;
90  /** Gain, -1=default:Do not change */
91  int gain;
92  /** Gamma, -1=default:Do not change */
93  int gamma;
94  /** Brightness, -1=default:Do not change */
96  /** Exposure, -1=default:Do not change */
97  int exposure;
98  /** Sharpness, -1=default:Do not change */
99  int sharpness;
100  /** White balance, -1=default:Do not change */
102  /** Shutter mode, -1=default:Do not change */
104  /** Gain mode, -1=default:Do not change */
106  /** Gamma mode, -1=default:Do not change */
108  /** Brightness mode, -1=default:Do not change */
110  /** Exposure mode, -1=default:Do not change */
112  /** Sharpness mode, -1=default:Do not change */
114  /** White balance mode, -1=default:Do not change */
116  /** For stereo cameras (eg PR Bumblebee) */
122  /** Size of the libdc1394 ring buffer */
124 };
125 
126 /** A class for grabing images from a IEEE1394 (Firewire) camera using the
127  * libdc1394-2 library.
128  * See the constructor for the options when opening the camera. Notice that
129  * you may have
130  * to carefully set the resolution, framerate and color_mode. See the
131  * verbose parameter of
132  * the constructor, which can display a list of supported modes in your
133  * camera.
134  *
135  * This class is able to manage any Firewire cameras, including Stereo or
136  * multi-cameras in general,
137  * so this can be used to open the Bumblebee camera (not tested yet).
138  *
139  * A static method (CImageGrabber_dc1394::enumerateCameras) is provided to
140  * enumerate all existing cameras and their properties. It can be used
141  * to find the GUID of the desired camera, then open it at the constructor.
142  *
143  * \note This class requires MRPT compiled with "libdc1394-2" (Only works under
144  * Linux for now) and "opencv".
145  * \note In Linux you may need to execute "chmod 666 /dev/video1394/ * " and
146  * "chmod 666 /dev/raw1394" for allowing any user R/W access to firewire
147  * cameras.
148  * \note [New in MRPT 1.3.0] Length of ring buffer is now configurable via
149  * TCaptureOptions_dc1394::ring_buffer_size
150  * \sa The most generic camera grabber in MRPT: mrpt::hwdrivers::CCameraSensor
151  * \ingroup mrpt_hwdrivers_grp
152  */
154 {
155  protected:
156  /** Set to false if we could not initialize the camera.
157  */
159 
160  /** Internal use: */
161  void /* dc1394_t * */* m_dc1394_lib_context;
162  void /* dc1394camera_t* */* m_dc1394camera;
164 
166 
167  public:
168  /** Constructor: open an ieee1394 camera.
169  * \param cameraGUID Set the camera GUID to open, or 0 to open the first
170  * found camera.
171  * \param cameraUnit (Ignored if cameraGUID=0). The number of camera to open
172  * within the device with the given GUID: In a stereo camera this may be 0
173  * or 1. Normally this is 0.
174  * \param options Capture options, defined in
175  * mrpt::hwdrivers::TCaptureOptions_dc1394.
176  * \param verbose Displays a lot of information about the camera to be open
177  * and its valid video modes.
178  */
180  uint64_t cameraGUID = 0, uint16_t cameraUnit = 0,
182  bool verbose = false);
183 
184  /** Destructor
185  */
186  virtual ~CImageGrabber_dc1394();
187 
188  /** Check whether the camera has been open successfully. */
189  bool isOpen() const { return m_bInitialized; }
190  /** Changes the capture properties (brightness, gain, shutter, etc)
191  * The frame size, framerate, and color_coding fields in options are
192  * ignored since they can be only set at construction time.
193  * \return false on error
194  */
195  bool changeCaptureOptions(const TCaptureOptions_dc1394& options);
196 
197  /** Grab an image from the opened camera (for monocular cameras).
198  * \param out_observation The object to be filled with sensed data.
199  * \note This may be blocking when using software trigger and no frame is
200  * available yet. Ensure trigger before getObservation() or take into
201  * account that this call may block.
202  * \return false on any error, true if all go fine.
203  */
204  bool getObservation(mrpt::obs::CObservationImage& out_observation);
205 
206  /** Grab an image from the opened camera (for stereo cameras).
207  * \param out_observation The object to be filled with sensed data.
208  *
209  * \return false on any error, true if all go fine.
210  */
212 
213  /** Changes the boolean level associated to Software Trigger (ON/OFF)
214  * Can be used to control camera triggering trough software
215  * \return false on error
216  */
217  bool setSoftwareTriggerLevel(bool level);
218 
219  /** Used in enumerateCameras */
220  struct TCameraInfo
221  {
223  int unit;
247  };
248 
249  using TCameraInfoList = std::list<TCameraInfo>;
250 
251  /** Generates a list with the information on all the existing (Firewire)
252  * cameras in the system.
253  * \exception std::runtime_error On any error calling libdc1394.
254  */
255  static void enumerateCameras(TCameraInfoList& out_list);
256 
257 }; // End of class
258 
259 } // End of NS
260 } // End of NS
261 
262 #endif
int gamma
Gamma, -1=default:Do not change.
Declares a class derived from "CObservation" that encapsules an image from a camera, whose relative pose to robot is also stored.
Options used when creating an dc1394 capture object All but the frame size, framerate, and color_coding can be changed dynamically by CImageGrabber_dc1394::changeCaptureOptions.
int sharpness
Sharpness, -1=default:Do not change.
unsigned __int16 uint16_t
Definition: rptypes.h:44
static void enumerateCameras(TCameraInfoList &out_list)
Generates a list with the information on all the existing (Firewire) cameras in the system...
int gain
Gain, -1=default:Do not change.
bool deinterlace_stereo
For stereo cameras (eg PR Bumblebee)
bool isOpen() const
Check whether the camera has been open successfully.
int sharpness_mode
Sharpness mode, -1=default:Do not change.
bool getObservation(mrpt::obs::CObservationImage &out_observation)
Grab an image from the opened camera (for monocular cameras).
int brightness_mode
Brightness mode, -1=default:Do not change.
bool setSoftwareTriggerLevel(bool level)
Changes the boolean level associated to Software Trigger (ON/OFF) Can be used to control camera trigg...
A class for grabing images from a IEEE1394 (Firewire) camera using the libdc1394-2 library...
Observation class for either a pair of left+right or left+disparity images from a stereo camera...
int white_balance
White balance, -1=default:Do not change.
int exposure
Exposure, -1=default:Do not change.
int exposure_mode
Exposure mode, -1=default:Do not change.
int frame_width
Capture resolution (Default: 640x480)
GLsizei const GLchar ** string
Definition: glext.h:4101
grabber_dc1394_color_coding_t color_coding
bool changeCaptureOptions(const TCaptureOptions_dc1394 &options)
Changes the capture properties (brightness, gain, shutter, etc) The frame size, framerate, and color_coding fields in options are ignored since they can be only set at construction time.
unsigned __int64 uint64_t
Definition: rptypes.h:50
int gain_mode
Gain mode, -1=default:Do not change.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
int white_balance_mode
White balance mode, -1=default:Do not change.
int shutter
Shutter, -1=default:Do not change.
int brightness
Brightness, -1=default:Do not change.
int ring_buffer_size
Size of the libdc1394 ring buffer.
GLint level
Definition: glext.h:3600
bool m_bInitialized
Set to false if we could not initialize the camera.
int gamma_mode
Gamma mode, -1=default:Do not change.
CImageGrabber_dc1394(uint64_t cameraGUID=0, uint16_t cameraUnit=0, const TCaptureOptions_dc1394 &options=TCaptureOptions_dc1394(), bool verbose=false)
Constructor: open an ieee1394 camera.
int mode7
-1: Normal mode, i>=0: use MODE7_i, then frame_width/height and color_coding are ignored.
int shutter_mode
Shutter mode, -1=default:Do not change.
unsigned __int32 uint32_t
Definition: rptypes.h:47



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