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
mrpt::hwdrivers::TCaptureOptions_dc1394::TCaptureOptions_dc1394
TCaptureOptions_dc1394()
Definition: CImageGrabber_dc1394.h:50
mrpt::hwdrivers::CImageGrabber_dc1394::enumerateCameras
static void enumerateCameras(TCameraInfoList &out_list)
Generates a list with the information on all the existing (Firewire) cameras in the system.
Definition: CImageGrabber_dc1394.cpp:778
mrpt::hwdrivers::CImageGrabber_dc1394::m_dc1394camera
void * m_dc1394camera
Definition: CImageGrabber_dc1394.h:162
mrpt::hwdrivers::CImageGrabber_dc1394::isOpen
bool isOpen() const
Check whether the camera has been open successfully.
Definition: CImageGrabber_dc1394.h:189
uint16_t
unsigned __int16 uint16_t
Definition: rptypes.h:44
mrpt::hwdrivers::TCaptureOptions_dc1394::trigger_polarity
int trigger_polarity
Definition: CImageGrabber_dc1394.h:121
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::has_feature_error_status
bool has_feature_error_status
Definition: CImageGrabber_dc1394.h:245
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::unit
int unit
Definition: CImageGrabber_dc1394.h:223
mrpt::hwdrivers::COLOR_CODING_YUV422
@ COLOR_CODING_YUV422
Definition: CImageGrabber_dc1394.h:36
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::unit_spec_ID
uint32_t unit_spec_ID
Definition: CImageGrabber_dc1394.h:224
mrpt::hwdrivers::FRAMERATE_240
@ FRAMERATE_240
Definition: CImageGrabber_dc1394.h:30
mrpt::hwdrivers::FRAMERATE_60
@ FRAMERATE_60
Definition: CImageGrabber_dc1394.h:28
mrpt::hwdrivers::COLOR_CODING_YUV444
@ COLOR_CODING_YUV444
Definition: CImageGrabber_dc1394.h:37
mrpt::hwdrivers::COLOR_CODING_MONO16
@ COLOR_CODING_MONO16
Definition: CImageGrabber_dc1394.h:39
mrpt::hwdrivers::COLOR_CODING_RGB8
@ COLOR_CODING_RGB8
Definition: CImageGrabber_dc1394.h:38
mrpt::hwdrivers::FRAMERATE_15
@ FRAMERATE_15
Definition: CImageGrabber_dc1394.h:26
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::unit_dependent_directory
uint32_t unit_dependent_directory
Definition: CImageGrabber_dc1394.h:229
mrpt::hwdrivers::CImageGrabber_dc1394::setSoftwareTriggerLevel
bool setSoftwareTriggerLevel(bool level)
Changes the boolean level associated to Software Trigger (ON/OFF) Can be used to control camera trigg...
Definition: CImageGrabber_dc1394.cpp:753
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::vendor
std::string vendor
Definition: CImageGrabber_dc1394.h:236
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::hwdrivers::CImageGrabber_dc1394
A class for grabing images from a IEEE1394 (Firewire) camera using the libdc1394-2 library.
Definition: CImageGrabber_dc1394.h:153
mrpt::hwdrivers::TCaptureOptions_dc1394::deinterlace_stereo
bool deinterlace_stereo
For stereo cameras (eg PR Bumblebee)
Definition: CImageGrabber_dc1394.h:117
mrpt::hwdrivers::CImageGrabber_dc1394::~CImageGrabber_dc1394
virtual ~CImageGrabber_dc1394()
Destructor.
Definition: CImageGrabber_dc1394.cpp:463
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::SIO_control_csr
uint64_t SIO_control_csr
Definition: CImageGrabber_dc1394.h:232
level
GLint level
Definition: glext.h:3600
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::guid
uint64_t guid
Definition: CImageGrabber_dc1394.h:222
CObservationStereoImages.h
mrpt::hwdrivers::TCaptureOptions_dc1394::frame_height
int frame_height
Definition: CImageGrabber_dc1394.h:80
mrpt::hwdrivers::FRAMERATE_1_875
@ FRAMERATE_1_875
Definition: CImageGrabber_dc1394.h:23
mrpt::hwdrivers::TCaptureOptions_dc1394::frame_width
int frame_width
Capture resolution (Default: 640x480)
Definition: CImageGrabber_dc1394.h:80
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::command_registers_base
uint32_t command_registers_base
Definition: CImageGrabber_dc1394.h:227
mrpt::hwdrivers::TCaptureOptions_dc1394::brightness_mode
int brightness_mode
Brightness mode, -1=default:Do not change.
Definition: CImageGrabber_dc1394.h:109
mrpt::hwdrivers::TCaptureOptions_dc1394::white_balance_mode
int white_balance_mode
White balance mode, -1=default:Do not change.
Definition: CImageGrabber_dc1394.h:115
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::unit_directory
uint32_t unit_directory
Definition: CImageGrabber_dc1394.h:228
mrpt::hwdrivers::TCaptureOptions_dc1394::gamma_mode
int gamma_mode
Gamma mode, -1=default:Do not change.
Definition: CImageGrabber_dc1394.h:107
mrpt::hwdrivers::TCaptureOptions_dc1394::white_balance
int white_balance
White balance, -1=default:Do not change.
Definition: CImageGrabber_dc1394.h:101
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::model
std::string model
Definition: CImageGrabber_dc1394.h:237
mrpt::hwdrivers::TCaptureOptions_dc1394::sharpness
int sharpness
Sharpness, -1=default:Do not change.
Definition: CImageGrabber_dc1394.h:99
mrpt::hwdrivers::COLOR_CODING_YUV411
@ COLOR_CODING_YUV411
Definition: CImageGrabber_dc1394.h:35
mrpt::hwdrivers::FRAMERATE_3_75
@ FRAMERATE_3_75
Definition: CImageGrabber_dc1394.h:24
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::advanced_features_csr
uint64_t advanced_features_csr
Definition: CImageGrabber_dc1394.h:230
mrpt::hwdrivers::CImageGrabber_dc1394::CImageGrabber_dc1394
CImageGrabber_dc1394(uint64_t cameraGUID=0, uint16_t cameraUnit=0, const TCaptureOptions_dc1394 &options=TCaptureOptions_dc1394(), bool verbose=false)
Constructor: open an ieee1394 camera.
Definition: CImageGrabber_dc1394.cpp:33
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::vendor_id
uint32_t vendor_id
Definition: CImageGrabber_dc1394.h:238
mrpt::hwdrivers::CImageGrabber_dc1394::m_bInitialized
bool m_bInitialized
Set to false if we could not initialize the camera.
Definition: CImageGrabber_dc1394.h:158
mrpt::hwdrivers::grabber_dc1394_color_coding_t
grabber_dc1394_color_coding_t
Definition: CImageGrabber_dc1394.h:33
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::one_shot_capable
bool one_shot_capable
Definition: CImageGrabber_dc1394.h:241
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::format7_csr
uint64_t format7_csr[16]
Definition: CImageGrabber_dc1394.h:234
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::max_mem_channel
int max_mem_channel
Definition: CImageGrabber_dc1394.h:246
mrpt::hwdrivers::TCaptureOptions_dc1394::shutter_mode
int shutter_mode
Shutter mode, -1=default:Do not change.
Definition: CImageGrabber_dc1394.h:103
mrpt::hwdrivers::TCaptureOptions_dc1394::ring_buffer_size
int ring_buffer_size
Size of the libdc1394 ring buffer.
Definition: CImageGrabber_dc1394.h:123
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::model_id
uint32_t model_id
Definition: CImageGrabber_dc1394.h:239
mrpt::hwdrivers::grabber_dc1394_framerate_t
grabber_dc1394_framerate_t
Definition: CImageGrabber_dc1394.h:22
mrpt::hwdrivers::TCaptureOptions_dc1394::brightness
int brightness
Brightness, -1=default:Do not change.
Definition: CImageGrabber_dc1394.h:95
uint64_t
unsigned __int64 uint64_t
Definition: rptypes.h:50
mrpt::hwdrivers::TCaptureOptions_dc1394::exposure
int exposure
Exposure, -1=default:Do not change.
Definition: CImageGrabber_dc1394.h:97
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::PIO_control_csr
uint64_t PIO_control_csr
Definition: CImageGrabber_dc1394.h:231
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::iidc_version
int iidc_version
Definition: CImageGrabber_dc1394.h:235
mrpt::hwdrivers::CImageGrabber_dc1394::changeCaptureOptions
bool changeCaptureOptions(const TCaptureOptions_dc1394 &options)
Changes the capture properties (brightness, gain, shutter, etc) The frame size, framerate,...
Definition: CImageGrabber_dc1394.cpp:692
mrpt::hwdrivers::COLOR_CODING_MONO8
@ COLOR_CODING_MONO8
Definition: CImageGrabber_dc1394.h:34
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::strobe_control_csr
uint64_t strobe_control_csr
Definition: CImageGrabber_dc1394.h:233
mrpt::hwdrivers::TCaptureOptions_dc1394::sharpness_mode
int sharpness_mode
Sharpness mode, -1=default:Do not change.
Definition: CImageGrabber_dc1394.h:113
mrpt::hwdrivers::TCaptureOptions_dc1394
Options used when creating an dc1394 capture object All but the frame size, framerate,...
Definition: CImageGrabber_dc1394.h:48
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::multi_shot_capable
bool multi_shot_capable
Definition: CImageGrabber_dc1394.h:242
mrpt::hwdrivers::FRAMERATE_7_5
@ FRAMERATE_7_5
Definition: CImageGrabber_dc1394.h:25
mrpt::hwdrivers::FRAMERATE_120
@ FRAMERATE_120
Definition: CImageGrabber_dc1394.h:29
mrpt::hwdrivers::TCaptureOptions_dc1394::mode7
int mode7
-1: Normal mode, i>=0: use MODE7_i, then frame_width/height and color_coding are ignored.
Definition: CImageGrabber_dc1394.h:86
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::has_vmode_error_status
bool has_vmode_error_status
Definition: CImageGrabber_dc1394.h:244
mrpt::hwdrivers::CImageGrabber_dc1394::getObservation
bool getObservation(mrpt::obs::CObservationImage &out_observation)
Grab an image from the opened camera (for monocular cameras).
Definition: CImageGrabber_dc1394.cpp:493
mrpt::hwdrivers::TCaptureOptions_dc1394::color_coding
grabber_dc1394_color_coding_t color_coding
Definition: CImageGrabber_dc1394.h:82
mrpt::hwdrivers::CImageGrabber_dc1394::m_options
TCaptureOptions_dc1394 m_options
Definition: CImageGrabber_dc1394.h:165
mrpt::hwdrivers::TCaptureOptions_dc1394::trigger_mode
int trigger_mode
Definition: CImageGrabber_dc1394.h:119
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::can_switch_on_off
bool can_switch_on_off
Definition: CImageGrabber_dc1394.h:243
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfoList
std::list< TCameraInfo > TCameraInfoList
Definition: CImageGrabber_dc1394.h:249
mrpt::hwdrivers::TCaptureOptions_dc1394::gamma
int gamma
Gamma, -1=default:Do not change.
Definition: CImageGrabber_dc1394.h:93
mrpt::hwdrivers::TCaptureOptions_dc1394::trigger_source
int trigger_source
Definition: CImageGrabber_dc1394.h:120
mrpt::hwdrivers::TCaptureOptions_dc1394::exposure_mode
int exposure_mode
Exposure mode, -1=default:Do not change.
Definition: CImageGrabber_dc1394.h:111
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::bmode_capable
bool bmode_capable
Definition: CImageGrabber_dc1394.h:240
mrpt::hwdrivers::CImageGrabber_dc1394::m_dc1394_lib_context
void * m_dc1394_lib_context
Internal use:
Definition: CImageGrabber_dc1394.h:161
CObservationImage.h
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::unit_sw_version
uint32_t unit_sw_version
Definition: CImageGrabber_dc1394.h:225
mrpt::hwdrivers::TCaptureOptions_dc1394::gain_mode
int gain_mode
Gain mode, -1=default:Do not change.
Definition: CImageGrabber_dc1394.h:105
mrpt::hwdrivers::CImageGrabber_dc1394::m_desired_mode
int m_desired_mode
Definition: CImageGrabber_dc1394.h:163
mrpt::hwdrivers::TCaptureOptions_dc1394::shutter
int shutter
Shutter, -1=default:Do not change.
Definition: CImageGrabber_dc1394.h:89
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo::unit_sub_sw_version
uint32_t unit_sub_sw_version
Definition: CImageGrabber_dc1394.h:226
mrpt::hwdrivers::FRAMERATE_30
@ FRAMERATE_30
Definition: CImageGrabber_dc1394.h:27
mrpt::hwdrivers::TCaptureOptions_dc1394::trigger_power
int trigger_power
Definition: CImageGrabber_dc1394.h:118
mrpt::hwdrivers::CImageGrabber_dc1394::TCameraInfo
Used in enumerateCameras.
Definition: CImageGrabber_dc1394.h:220
mrpt::obs::CObservationImage
Declares a class derived from "CObservation" that encapsules an image from a camera,...
Definition: CObservationImage.h:35
uint32_t
unsigned __int32 uint32_t
Definition: rptypes.h:47
mrpt::obs::CObservationStereoImages
Observation class for either a pair of left+right or left+disparity images from a stereo camera.
Definition: CObservationStereoImages.h:41
mrpt::hwdrivers::TCaptureOptions_dc1394::framerate
grabber_dc1394_framerate_t framerate
Definition: CImageGrabber_dc1394.h:81
mrpt::hwdrivers::TCaptureOptions_dc1394::gain
int gain
Gain, -1=default:Do not change.
Definition: CImageGrabber_dc1394.h:91



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST