MRPT  1.9.9
CImageGrabber_dc1394.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/config.h>
12 
15 #include <list>
16 
17 namespace mrpt::hwdrivers
18 {
19 typedef enum
20 {
30 
31 typedef enum
32 {
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 {
49  TCaptureOptions_dc1394() = default;
50 
51  /** Capture resolution (Default: 640x480) */
52  int frame_width{640}, frame_height{480};
55 
56  /** -1: Normal mode, i>=0: use MODE7_i, then frame_width/height and
57  * color_coding are ignored. */
58  int mode7{-1};
59 
60  /** Shutter, -1=default:Do not change */
61  int shutter{-1};
62  /** Gain, -1=default:Do not change */
63  int gain{-1};
64  /** Gamma, -1=default:Do not change */
65  int gamma{-1};
66  /** Brightness, -1=default:Do not change */
67  int brightness{-1};
68  /** Exposure, -1=default:Do not change */
69  int exposure{-1};
70  /** Sharpness, -1=default:Do not change */
71  int sharpness{-1};
72  /** White balance, -1=default:Do not change */
73  int white_balance{-1};
74  /** Shutter mode, -1=default:Do not change */
75  int shutter_mode{-1};
76  /** Gain mode, -1=default:Do not change */
77  int gain_mode{-1};
78  /** Gamma mode, -1=default:Do not change */
79  int gamma_mode{-1};
80  /** Brightness mode, -1=default:Do not change */
81  int brightness_mode{-1};
82  /** Exposure mode, -1=default:Do not change */
83  int exposure_mode{-1};
84  /** Sharpness mode, -1=default:Do not change */
85  int sharpness_mode{-1};
86  /** White balance mode, -1=default:Do not change */
88  /** For stereo cameras (eg PR Bumblebee) */
89  bool deinterlace_stereo{false};
90  int trigger_power{-1};
91  int trigger_mode{-1};
92  int trigger_source{-1};
94  /** Size of the libdc1394 ring buffer */
96 };
97 
98 /** A class for grabing images from a IEEE1394 (Firewire) camera using the
99  * libdc1394-2 library.
100  * See the constructor for the options when opening the camera. Notice that
101  * you may have
102  * to carefully set the resolution, framerate and color_mode. See the
103  * verbose parameter of
104  * the constructor, which can display a list of supported modes in your
105  * camera.
106  *
107  * This class is able to manage any Firewire cameras, including Stereo or
108  * multi-cameras in general,
109  * so this can be used to open the Bumblebee camera (not tested yet).
110  *
111  * A static method (CImageGrabber_dc1394::enumerateCameras) is provided to
112  * enumerate all existing cameras and their properties. It can be used
113  * to find the GUID of the desired camera, then open it at the constructor.
114  *
115  * \note This class requires MRPT compiled with "libdc1394-2" (Only works under
116  * Linux for now) and "opencv".
117  * \note In Linux you may need to execute "chmod 666 /dev/video1394/ * " and
118  * "chmod 666 /dev/raw1394" for allowing any user R/W access to firewire
119  * cameras.
120  * \note [New in MRPT 1.3.0] Length of ring buffer is now configurable via
121  * TCaptureOptions_dc1394::ring_buffer_size
122  * \sa The most generic camera grabber in MRPT: mrpt::hwdrivers::CCameraSensor
123  * \ingroup mrpt_hwdrivers_grp
124  */
126 {
127  protected:
128  /** Set to false if we could not initialize the camera.
129  */
130  bool m_bInitialized{false};
131 
132  /** Internal use: */
133  void /* dc1394_t * */* m_dc1394_lib_context{nullptr};
134  void /* dc1394camera_t* */* m_dc1394camera{nullptr};
136 
138 
139  public:
140  /** Constructor: open an ieee1394 camera.
141  * \param cameraGUID Set the camera GUID to open, or 0 to open the first
142  * found camera.
143  * \param cameraUnit (Ignored if cameraGUID=0). The number of camera to open
144  * within the device with the given GUID: In a stereo camera this may be 0
145  * or 1. Normally this is 0.
146  * \param options Capture options, defined in
147  * mrpt::hwdrivers::TCaptureOptions_dc1394.
148  * \param verbose Displays a lot of information about the camera to be open
149  * and its valid video modes.
150  */
152  uint64_t cameraGUID = 0, uint16_t cameraUnit = 0,
154  bool verbose = false);
155 
156  /** Destructor
157  */
158  virtual ~CImageGrabber_dc1394();
159 
160  /** Check whether the camera has been open successfully. */
161  bool isOpen() const { return m_bInitialized; }
162  /** Changes the capture properties (brightness, gain, shutter, etc)
163  * The frame size, framerate, and color_coding fields in options are
164  * ignored since they can be only set at construction time.
165  * \return false on error
166  */
167  bool changeCaptureOptions(const TCaptureOptions_dc1394& options);
168 
169  /** Grab an image from the opened camera (for monocular cameras).
170  * \param out_observation The object to be filled with sensed data.
171  * \note This may be blocking when using software trigger and no frame is
172  * available yet. Ensure trigger before getObservation() or take into
173  * account that this call may block.
174  * \return false on any error, true if all go fine.
175  */
176  bool getObservation(mrpt::obs::CObservationImage& out_observation);
177 
178  /** Grab an image from the opened camera (for stereo cameras).
179  * \param out_observation The object to be filled with sensed data.
180  *
181  * \return false on any error, true if all go fine.
182  */
184 
185  /** Changes the boolean level associated to Software Trigger (ON/OFF)
186  * Can be used to control camera triggering trough software
187  * \return false on error
188  */
189  bool setSoftwareTriggerLevel(bool level);
190 
191  /** Used in enumerateCameras */
192  struct TCameraInfo
193  {
195  int unit;
196  uint32_t unit_spec_ID;
197  uint32_t unit_sw_version;
200  uint32_t unit_directory;
210  uint32_t vendor_id;
211  uint32_t model_id;
219  };
220 
221  using TCameraInfoList = std::list<TCameraInfo>;
222 
223  /** Generates a list with the information on all the existing (Firewire)
224  * cameras in the system.
225  * \exception std::runtime_error On any error calling libdc1394.
226  */
227  static void enumerateCameras(TCameraInfoList& out_list);
228 
229 }; // End of class
230 
231 } // namespace mrpt::hwdrivers
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.
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:4116
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.
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.
unsigned __int64 uint64_t
Definition: glext.h:3457
int brightness
Brightness, -1=default:Do not change.
int ring_buffer_size
Size of the libdc1394 ring buffer.
GLint level
Definition: glext.h:3606
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.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 31e853f50 Thu Nov 21 23:57:32 2019 +0100 at vie nov 22 00:00:11 CET 2019