Main MRPT website > C++ reference
MRPT logo
CImageGrabber_OpenCV.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 CImageGrabber_OpenCV_H
29 #define CImageGrabber_OpenCV_H
30 
31 #include <mrpt/config.h>
33 
36 
37 
38 namespace mrpt
39 {
40  namespace hwdrivers
41  {
42  /** These capture types are like their OpenCV equivalents. */
44  {
50  CAMERA_CV_DSHOW //!< Valid only with OpenCV >= 1.1.0
51  };
52 
53  /** Options used when creating an OpenCV capture object
54  * Some options apply to IEEE1394 cameras only.
55  * \sa CImageGrabber_OpenCV
56  * \ingroup mrpt_hwdrivers_grp
57  */
59  {
62  gain(0),
63  ieee1394_fps(0),
64  ieee1394_grayscale(false)
65  {}
66 
67  int frame_width,frame_height; //!< (All cameras) Capture resolution (0: Leave the default)
68  double gain; //!< (All cameras) Camera gain (0: Leave the default)
69  double ieee1394_fps; //!< (IEEE1394 cameras) Frame rate for the capture (0: Leave the default).
70  bool ieee1394_grayscale; //!< (IEEE1394 cameras) Whether to grab grayscale images (Default=false).
71  };
72 
73  /** A class for grabing images from a "OpenCV"-compatible camera, or from an AVI video file.
74  * See the constructor for the options when opening the camera.
75  *
76  * Unless input from AVI files is required, it is recommended to use the more generic class
77  * mrpt::hwdrivers::CCameraSensor.
78  *
79  * \note This class is only available when compiling MRPT with the flag "MRPT_HAS_OPENCV" defined.
80  * \note Some code is based on the class CaptureCamera from the Orocos project.
81  * \sa mrpt::hwdrivers::CCameraSensor, CImageGrabber_dc1394
82  * \sa The most generic camera grabber in MRPT: mrpt::hwdrivers::CCameraSensor
83  * \ingroup mrpt_hwdrivers_grp
84  */
86  {
87  protected:
88  /** Set to false if we could not initialize the camera.
89  */
91 
92  /** Internal use:
93  */
95 
96  public:
97  /** Constructor for cameras:
98  * \param cameraIndex Set the camera index, or -1 if it does not matter and you select AUTODETECT as cameraType.
99  * \param cameraType Can be any value of TCameraType, or CAMERA_CV_AUTODETECT if there is only one camera.
100  * \param options Capture options, defined in mrpt::hwdrivers::TCaptureCVOptions. If not provided, all the default options will be used.
101  */
103  int cameraIndex = -1,
104  TCameraType cameraType = CAMERA_CV_AUTODETECT,
105  const TCaptureCVOptions &options = TCaptureCVOptions()
106  );
107 
108  /** Constructor for AVI files:
109  */
110  CImageGrabber_OpenCV( const std::string &AVI_fileName );
111 
112  /** Destructor
113  */
114  virtual ~CImageGrabber_OpenCV( );
115 
116  /** Check whether the camera has been open successfully. */
117  bool isOpen() const
118  {
119  return m_bInitialized;
120  }
121 
122  /** Grab an image from the opened camera.
123  * \param out_observation The object to be filled with sensed data.
124  *
125  * \return false on any error, true if all go fine.
126  */
127  bool getObservation( mrpt::slam::CObservationImage &out_observation);
128 
129 
130  }; // End of class
131 
132  } // End of NS
133 } // End of NS
134 
135 
136 #endif



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