Main MRPT website > C++ reference for MRPT 1.5.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 
18 
19 namespace mrpt
20 {
21  namespace hwdrivers
22  {
23 
24  typedef enum {
34 
35  typedef enum {
43 
44  /** Options used when creating an dc1394 capture object
45  * All but the frame size, framerate, and color_coding can be changed dynamically by CImageGrabber_dc1394::changeCaptureOptions
46  * \sa CImageGrabber_dc1394
47  * \ingroup mrpt_hwdrivers_grp
48  */
50  {
52  frame_width (640),
53  frame_height (480),
54  framerate (FRAMERATE_15),
55  color_coding (COLOR_CODING_YUV422),
56  mode7 (-1),
57  shutter (-1),
58  gain (-1),
59  gamma (-1),
60  brightness (-1),
61  exposure (-1),
62  sharpness (-1),
63  white_balance (-1),
64  shutter_mode (-1),
65  gain_mode (-1),
66  gamma_mode (-1),
67  brightness_mode (-1),
68  exposure_mode (-1),
69  sharpness_mode (-1),
70  white_balance_mode(-1),
71  deinterlace_stereo(false),
72  trigger_power (-1),
73  trigger_mode (-1),
74  trigger_source (-1),
75  trigger_polarity(-1),
76  ring_buffer_size(15)
77  {}
78 
79  int frame_width,frame_height; //!< Capture resolution (Default: 640x480)
82 
83  int mode7; //!< -1: Normal mode, i>=0: use MODE7_i, then frame_width/height and color_coding are ignored.
84 
85  int shutter; //!< Shutter, -1=default:Do not change
86  int gain; //!< Gain, -1=default:Do not change
87  int gamma; //!< Gamma, -1=default:Do not change
88  int brightness; //!< Brightness, -1=default:Do not change
89  int exposure; //!< Exposure, -1=default:Do not change
90  int sharpness; //!< Sharpness, -1=default:Do not change
91  int white_balance; //!< White balance, -1=default:Do not change
92  int shutter_mode; //!< Shutter mode, -1=default:Do not change
93  int gain_mode; //!< Gain mode, -1=default:Do not change
94  int gamma_mode; //!< Gamma mode, -1=default:Do not change
95  int brightness_mode; //!< Brightness mode, -1=default:Do not change
96  int exposure_mode; //!< Exposure mode, -1=default:Do not change
97  int sharpness_mode; //!< Sharpness mode, -1=default:Do not change
98  int white_balance_mode; //!< White balance mode, -1=default:Do not change
99  bool deinterlace_stereo; //!< For stereo cameras (eg PR Bumblebee)
104  int ring_buffer_size; //!< Size of the libdc1394 ring buffer
105  };
106 
107  /** A class for grabing images from a IEEE1394 (Firewire) camera using the libdc1394-2 library.
108  * See the constructor for the options when opening the camera. Notice that you may have
109  * to carefully set the resolution, framerate and color_mode. See the verbose parameter of
110  * the constructor, which can display a list of supported modes in your camera.
111  *
112  * This class is able to manage any Firewire cameras, including Stereo or multi-cameras in general,
113  * so this can be used to open the Bumblebee camera (not tested yet).
114  *
115  * A static method (CImageGrabber_dc1394::enumerateCameras) is provided to enumerate all existing cameras and their properties. It can be used
116  * to find the GUID of the desired camera, then open it at the constructor.
117  *
118  * \note This class requires MRPT compiled with "libdc1394-2" (Only works under Linux for now) and "opencv".
119  * \note In Linux you may need to execute "chmod 666 /dev/video1394/ * " and "chmod 666 /dev/raw1394" for allowing any user R/W access to firewire cameras.
120  * \note [New in MRPT 1.3.0] Length of ring buffer is now configurable via TCaptureOptions_dc1394::ring_buffer_size
121  * \sa The most generic camera grabber in MRPT: mrpt::hwdrivers::CCameraSensor
122  * \ingroup mrpt_hwdrivers_grp
123  */
125  {
126  protected:
127  /** Set to false if we could not initialize the camera.
128  */
130 
131  /** Internal use: */
132  void /* dc1394_t * */ *m_dc1394_lib_context;
133  void /* dc1394camera_t* */ *m_dc1394camera;
135 
137 
138  public:
139  /** Constructor: open an ieee1394 camera.
140  * \param cameraGUID Set the camera GUID to open, or 0 to open the first found camera.
141  * \param cameraUnit (Ignored if cameraGUID=0). The number of camera to open within the device with the given GUID: In a stereo camera this may be 0 or 1. Normally this is 0.
142  * \param options Capture options, defined in mrpt::hwdrivers::TCaptureOptions_dc1394.
143  * \param verbose Displays a lot of information about the camera to be open and its valid video modes.
144  */
146  uint64_t cameraGUID = 0,
147  uint16_t cameraUnit = 0,
149  bool verbose = false
150  );
151 
152  /** Destructor
153  */
154  virtual ~CImageGrabber_dc1394( );
155 
156  /** Check whether the camera has been open successfully. */
157  bool isOpen() const
158  {
159  return m_bInitialized;
160  }
161 
162  /** Changes the capture properties (brightness, gain, shutter, etc)
163  * The frame size, framerate, and color_coding fields in options are ignored since they can be only set at construction time.
164  * \return false on error
165  */
166  bool changeCaptureOptions( const TCaptureOptions_dc1394 &options );
167 
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 available yet. Ensure trigger before getObservation() or take into account that this call may block.
172  * \return false on any error, true if all go fine.
173  */
174  bool getObservation( mrpt::obs::CObservationImage &out_observation);
175 
176  /** Grab an image from the opened camera (for stereo cameras).
177  * \param out_observation The object to be filled with sensed data.
178  *
179  * \return false on any error, true if all go fine.
180  */
181  bool getObservation( mrpt::obs::CObservationStereoImages &out_observation);
182 
183  /** Changes the boolean level associated to Software Trigger (ON/OFF)
184  * Can be used to control camera triggering trough software
185  * \return false on error
186  */
187  bool setSoftwareTriggerLevel( bool level );
188 
189  /** Used in enumerateCameras */
190  struct TCameraInfo
191  {
193  int unit;
204  uint64_t format7_csr[16];
217  };
218 
219  typedef std::list<TCameraInfo> TCameraInfoList;
220 
221  /** Generates a list with the information on all the existing (Firewire) cameras in the system.
222  * \exception std::runtime_error On any error calling libdc1394.
223  */
224  static void enumerateCameras( TCameraInfoList &out_list );
225 
226 
227  }; // End of class
228 
229  } // End of NS
230 } // End of NS
231 
232 
233 #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:46
OBSERVATION_T::Ptr getObservation(mrpt::obs::CSensoryFramePtr &observations, mrpt::obs::CObservationPtr &observation, bool priority_to_sf=true)
Given an mrpt::obs::CSensoryFrame and a mrpt::obs::CObservation pointer if a OBSERVATION_T type obser...
Definition: obs_utils.h:32
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.
int brightness_mode
Brightness mode, -1=default:Do not change.
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.
GLsizei const GLchar ** string
Definition: glext.h:3919
grabber_dc1394_color_coding_t color_coding
unsigned __int64 uint64_t
Definition: rptypes.h:52
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:3545
bool m_bInitialized
Set to false if we could not initialize the camera.
int gamma_mode
Gamma mode, -1=default:Do not change.
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:49



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020