Main MRPT website > C++ reference
MRPT logo
CImageGrabber_dc1394.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef CCImageGrabber_dc1394
29 #define CCImageGrabber_dc1394
30 
31 #include <mrpt/config.h>
32 
35 
37 
38 namespace mrpt
39 {
40  namespace hwdrivers
41  {
42 
43  typedef enum {
53 
54  typedef enum {
62 
63 
64  /** Options used when creating an dc1394 capture object
65  * All but the frame size, framerate, and color_coding can be changed dynamically by CImageGrabber_dc1394::changeCaptureOptions
66  * \sa CImageGrabber_dc1394
67  * \ingroup mrpt_hwdrivers_grp
68  */
70  {
72  frame_width (640),
73  frame_height (480),
76  mode7 (-1),
77  shutter (-1),
78  gain (-1),
79  gamma (-1),
80  brightness (-1),
81  exposure (-1),
82  sharpness (-1),
83  white_balance (-1),
84  deinterlace_stereo(false)
85  {}
86 
87  int frame_width,frame_height; //!< Capture resolution (Default: 640x480)
90 
91  int mode7; //!< -1: Normal mode, i>=0: use MODE7_i, then frame_width/height and color_coding are ignored.
92 
93  int shutter; //!< Shutter, -1=default:Do not change
94  int gain; //!< Gain, -1=default:Do not change
95  int gamma; //!< Gamma, -1=default:Do not change
96  int brightness; //!< Brightness, -1=default:Do not change
97  int exposure; //!< Exposure, -1=default:Do not change
98  int sharpness; //!< Sharpness, -1=default:Do not change
99  int white_balance; //!< White balance, -1=default:Do not change
100  bool deinterlace_stereo; //!< For stereo cameras (eg PR Bumblebee)
101  };
102 
103  /** A class for grabing images from a IEEE1394 (Firewire) camera using the libdc1394-2 library.
104  * See the constructor for the options when opening the camera. Notice that you may have
105  * to carefully set the resolution, framerate and color_mode. See the verbose parameter of
106  * the constructor, which can display a list of supported modes in your camera.
107  *
108  * This class is able to manage any Firewire cameras, including Stereo or 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 enumerate all existing cameras and their properties. It can be used
112  * to find the GUID of the desired camera, then open it at the constructor.
113  *
114  * \note This class requires MRPT compiled with "libdc1394-2" (Only works under Linux for now) and "opencv".
115  * \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.
116  * \sa The most generic camera grabber in MRPT: mrpt::hwdrivers::CCameraSensor
117  * \ingroup mrpt_hwdrivers_grp
118  */
120  {
121  protected:
122  /** Set to false if we could not initialize the camera.
123  */
125 
126  /** Internal use: */
127  void /* dc1394_t * */ *m_dc1394_lib_context;
128  void /* dc1394camera_t* */ *m_dc1394camera;
130 
131 
133 
134  public:
135  /** Constructor: open an ieee1394 camera.
136  * \param cameraGUID Set the camera GUID to open, or 0 to open the first found camera.
137  * \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.
138  * \param options Capture options, defined in mrpt::hwdrivers::TCaptureOptions_dc1394.
139  * \param verbose Displays a lot of information about the camera to be open and its valid video modes.
140  */
142  uint64_t cameraGUID = 0,
143  uint16_t cameraUnit = 0,
145  bool verbose = false
146  );
147 
148  /** Destructor
149  */
150  virtual ~CImageGrabber_dc1394( );
151 
152  /** Check whether the camera has been open successfully. */
153  bool isOpen() const
154  {
155  return m_bInitialized;
156  }
157 
158  /** Changes the capture properties (brightness, gain, shutter, etc)
159  * The frame size, framerate, and color_coding fields in options are ignored since they can be only set at construction time.
160  * \return false on error
161  */
162  bool changeCaptureOptions( const TCaptureOptions_dc1394 &options );
163 
164 
165  /** Grab an image from the opened camera (for monocular cameras).
166  * \param out_observation The object to be filled with sensed data.
167  *
168  * \return false on any error, true if all go fine.
169  */
170  bool getObservation( mrpt::slam::CObservationImage &out_observation);
171 
172  /** Grab an image from the opened camera (for stereo cameras).
173  * \param out_observation The object to be filled with sensed data.
174  *
175  * \return false on any error, true if all go fine.
176  */
177  bool getObservation( mrpt::slam::CObservationStereoImages &out_observation);
178 
179  /** Used in enumerateCameras */
180  struct TCameraInfo
181  {
182  uint64_t guid;
183  int unit;
184  uint32_t unit_spec_ID;
185  uint32_t unit_sw_version;
188  uint32_t unit_directory;
191  uint64_t PIO_control_csr;
192  uint64_t SIO_control_csr;
194  uint64_t format7_csr[16];
196  std::string vendor;
197  std::string model;
198  uint32_t vendor_id;
199  uint32_t model_id;
207  };
208 
209  typedef std::list<TCameraInfo> TCameraInfoList;
210 
211  /** Generates a list with the information on all the existing (Firewire) cameras in the system.
212  * \exception std::runtime_error On any error calling libdc1394.
213  */
214  static void enumerateCameras( TCameraInfoList &out_list );
215 
216 
217  }; // End of class
218 
219  } // End of NS
220 } // End of NS
221 
222 
223 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013