Main MRPT website > C++ reference
MRPT logo
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-2014, 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),
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),
71  deinterlace_stereo(false),
72  trigger_power (-1),
73  trigger_mode (-1),
74  trigger_source (-1),
76  {}
77 
78  int frame_width,frame_height; //!< Capture resolution (Default: 640x480)
81 
82  int mode7; //!< -1: Normal mode, i>=0: use MODE7_i, then frame_width/height and color_coding are ignored.
83 
84  int shutter; //!< Shutter, -1=default:Do not change
85  int gain; //!< Gain, -1=default:Do not change
86  int gamma; //!< Gamma, -1=default:Do not change
87  int brightness; //!< Brightness, -1=default:Do not change
88  int exposure; //!< Exposure, -1=default:Do not change
89  int sharpness; //!< Sharpness, -1=default:Do not change
90  int white_balance; //!< White balance, -1=default:Do not change
91  int shutter_mode; //!< Shutter mode, -1=default:Do not change
92  int gain_mode; //!< Gain mode, -1=default:Do not change
93  int gamma_mode; //!< Gamma mode, -1=default:Do not change
94  int brightness_mode; //!< Brightness mode, -1=default:Do not change
95  int exposure_mode; //!< Exposure mode, -1=default:Do not change
96  int sharpness_mode; //!< Sharpness mode, -1=default:Do not change
97  int white_balance_mode; //!< White balance mode, -1=default:Do not change
98  bool deinterlace_stereo; //!< For stereo cameras (eg PR Bumblebee)
103  };
104 
105  /** A class for grabing images from a IEEE1394 (Firewire) camera using the libdc1394-2 library.
106  * See the constructor for the options when opening the camera. Notice that you may have
107  * to carefully set the resolution, framerate and color_mode. See the verbose parameter of
108  * the constructor, which can display a list of supported modes in your camera.
109  *
110  * This class is able to manage any Firewire cameras, including Stereo or multi-cameras in general,
111  * so this can be used to open the Bumblebee camera (not tested yet).
112  *
113  * A static method (CImageGrabber_dc1394::enumerateCameras) is provided to enumerate all existing cameras and their properties. It can be used
114  * to find the GUID of the desired camera, then open it at the constructor.
115  *
116  * \note This class requires MRPT compiled with "libdc1394-2" (Only works under Linux for now) and "opencv".
117  * \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.
118  * \sa The most generic camera grabber in MRPT: mrpt::hwdrivers::CCameraSensor
119  * \ingroup mrpt_hwdrivers_grp
120  */
122  {
123  protected:
124  /** Set to false if we could not initialize the camera.
125  */
127 
128  /** Internal use: */
129  void /* dc1394_t * */ *m_dc1394_lib_context;
130  void /* dc1394camera_t* */ *m_dc1394camera;
132 
133 
135 
136  public:
137  /** Constructor: open an ieee1394 camera.
138  * \param cameraGUID Set the camera GUID to open, or 0 to open the first found camera.
139  * \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.
140  * \param options Capture options, defined in mrpt::hwdrivers::TCaptureOptions_dc1394.
141  * \param verbose Displays a lot of information about the camera to be open and its valid video modes.
142  */
144  uint64_t cameraGUID = 0,
145  uint16_t cameraUnit = 0,
147  bool verbose = false
148  );
149 
150  /** Destructor
151  */
152  virtual ~CImageGrabber_dc1394( );
153 
154  /** Check whether the camera has been open successfully. */
155  bool isOpen() const
156  {
157  return m_bInitialized;
158  }
159 
160  /** Changes the capture properties (brightness, gain, shutter, etc)
161  * The frame size, framerate, and color_coding fields in options are ignored since they can be only set at construction time.
162  * \return false on error
163  */
164  bool changeCaptureOptions( const TCaptureOptions_dc1394 &options );
165 
166 
167  /** Grab an image from the opened camera (for monocular cameras).
168  * \param out_observation The object to be filled with sensed data.
169  *
170  * \return false on any error, true if all go fine.
171  */
172  bool getObservation( mrpt::slam::CObservationImage &out_observation);
173 
174  /** Grab an image from the opened camera (for stereo cameras).
175  * \param out_observation The object to be filled with sensed data.
176  *
177  * \return false on any error, true if all go fine.
178  */
179  bool getObservation( mrpt::slam::CObservationStereoImages &out_observation);
180 
181  /** Changes the boolean level associated to Software Trigger (ON/OFF)
182  * Can be used to control camera triggering trough software
183  * \return false on error
184  */
185  bool setSoftwareTriggerLevel( bool level );
186 
187  /** Used in enumerateCameras */
188  struct TCameraInfo
189  {
190  uint64_t guid;
191  int unit;
192  uint32_t unit_spec_ID;
193  uint32_t unit_sw_version;
196  uint32_t unit_directory;
199  uint64_t PIO_control_csr;
200  uint64_t SIO_control_csr;
202  uint64_t format7_csr[16];
204  std::string vendor;
205  std::string model;
206  uint32_t vendor_id;
207  uint32_t model_id;
215  };
216 
217  typedef std::list<TCameraInfo> TCameraInfoList;
218 
219  /** Generates a list with the information on all the existing (Firewire) cameras in the system.
220  * \exception std::runtime_error On any error calling libdc1394.
221  */
222  static void enumerateCameras( TCameraInfoList &out_list );
223 
224 
225  }; // End of class
226 
227  } // End of NS
228 } // End of NS
229 
230 
231 #endif
int gamma
Gamma, -1=default:Do not change.
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.
int gain
Gain, -1=default:Do not change.
bool deinterlace_stereo
For stereo cameras (eg PR Bumblebee)
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...
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.
Declares a class derived from "CObservation" that encapsules an image from a camera, whose relative pose to robot is also stored.
grabber_dc1394_color_coding_t color_coding
Observation class for either a pair of left+right or left+disparity images from a stereo camera...
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 frame_height
Capture resolution (Default: 640x480)
int brightness
Brightness, -1=default:Do not change.
bool m_bInitialized
Set to false if we could not initialize the camera.
int gamma_mode
Gamma mode, -1=default:Do not change.
#define HWDRIVERS_IMPEXP
bool isOpen() const
Check whether the camera has been open successfully.
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.8 for MRPT 1.2.2 SVN:Unversioned directory at Tue Oct 14 02:14:08 UTC 2014