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