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