00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2011 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 #ifndef CImageGrabber_OpenCV_H 00029 #define CImageGrabber_OpenCV_H 00030 00031 #include <mrpt/config.h> 00032 #include <mrpt/hwdrivers/link_pragmas.h> 00033 00034 #include <mrpt/slam/CObservationImage.h> 00035 #include <mrpt/utils/safe_pointers.h> 00036 00037 00038 namespace mrpt 00039 { 00040 namespace hwdrivers 00041 { 00042 /** These capture types are like their OpenCV equivalents. */ 00043 enum TCameraType 00044 { 00045 CAMERA_CV_AUTODETECT = 0, 00046 CAMERA_CV_DC1394, 00047 CAMERA_CV_VFL, 00048 CAMERA_CV_VFW, 00049 CAMERA_CV_MIL, 00050 CAMERA_CV_DSHOW //!< Valid only with OpenCV >= 1.1.0 00051 }; 00052 00053 /** Options used when creating an OpenCV capture object 00054 * Some options apply to IEEE1394 cameras only. 00055 * \sa CImageGrabber_OpenCV 00056 */ 00057 struct TCaptureCVOptions 00058 { 00059 TCaptureCVOptions() : 00060 frame_width(0), frame_height(0), 00061 gain(0), 00062 ieee1394_fps(0), 00063 ieee1394_grayscale(false) 00064 {} 00065 00066 int frame_width,frame_height; //!< (All cameras) Capture resolution (0: Leave the default) 00067 double gain; //!< (All cameras) Camera gain (0: Leave the default) 00068 double ieee1394_fps; //!< (IEEE1394 cameras) Frame rate for the capture (0: Leave the default). 00069 bool ieee1394_grayscale; //!< (IEEE1394 cameras) Whether to grab grayscale images (Default=false). 00070 }; 00071 00072 /** A class for grabing images from a "OpenCV"-compatible camera, or from an AVI video file. 00073 * See the constructor for the options when opening the camera. 00074 * 00075 * Unless input from AVI files is required, it is recommended to use the more generic class 00076 * mrpt::hwdrivers::CCameraSensor. 00077 * 00078 * \note This class is only available when compiling MRPT with the flag "MRPT_HAS_OPENCV" defined. 00079 * \note Some code is based on the class CaptureCamera from the Orocos project. 00080 * \sa mrpt::hwdrivers::CCameraSensor, CImageGrabber_dc1394 00081 * \sa The most generic camera grabber in MRPT: mrpt::hwdrivers::CCameraSensor 00082 */ 00083 class HWDRIVERS_IMPEXP CImageGrabber_OpenCV 00084 { 00085 protected: 00086 /** Set to false if we could not initialize the camera. 00087 */ 00088 bool m_bInitialized; 00089 00090 /** Internal use: 00091 */ 00092 mrpt::utils::void_ptr_noncopy /*CvCapture*/ m_capture; 00093 00094 public: 00095 /** Constructor for cameras: 00096 * \param cameraIndex Set the camera index, or -1 if it does not matter and you select AUTODETECT as cameraType. 00097 * \param cameraType Can be any value of TCameraType, or CAMERA_CV_AUTODETECT if there is only one camera. 00098 * \param options Capture options, defined in mrpt::hwdrivers::TCaptureCVOptions. If not provided, all the default options will be used. 00099 */ 00100 CImageGrabber_OpenCV( 00101 int cameraIndex = -1, 00102 TCameraType cameraType = CAMERA_CV_AUTODETECT, 00103 const TCaptureCVOptions &options = TCaptureCVOptions() 00104 ); 00105 00106 /** Constructor for AVI files: 00107 */ 00108 CImageGrabber_OpenCV( const std::string &AVI_fileName ); 00109 00110 /** Destructor 00111 */ 00112 virtual ~CImageGrabber_OpenCV( ); 00113 00114 /** Check whether the camera has been open successfully. */ 00115 bool isOpen() const 00116 { 00117 return m_bInitialized; 00118 } 00119 00120 /** Grab an image from the opened camera. 00121 * \param out_observation The object to be filled with sensed data. 00122 * 00123 * \return false on any error, true if all go fine. 00124 */ 00125 bool getObservation( mrpt::slam::CObservationImage &out_observation); 00126 00127 00128 }; // End of class 00129 00130 } // End of NS 00131 } // End of NS 00132 00133 00134 #endif
Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN:exported at Tue Jan 25 21:56:31 UTC 2011 |