00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2009 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 00033 #include <mrpt/slam/CObservationImage.h> 00034 #include <mrpt/utils/safe_pointers.h> 00035 00036 00037 namespace mrpt 00038 { 00039 namespace vision 00040 { 00041 /** These capture types are like their OpenCV equivalents. */ 00042 enum TCameraType 00043 { 00044 CAMERA_CV_AUTODETECT = 0, 00045 CAMERA_CV_DC1394, 00046 CAMERA_CV_VFL, 00047 CAMERA_CV_VFW, 00048 CAMERA_CV_MIL, 00049 CAMERA_CV_DSHOW //!< Valid only with OpenCV >= 1.1.0 00050 }; 00051 00052 /** Options used when creating an OpenCV capture object 00053 * Some options apply to IEEE1394 cameras only. 00054 * \sa CImageGrabber_OpenCV 00055 */ 00056 struct TCaptureCVOptions 00057 { 00058 TCaptureCVOptions() : 00059 frame_width(0), frame_height(0), 00060 gain(0), 00061 ieee1394_fps(0), 00062 ieee1394_grayscale(false) 00063 {} 00064 00065 int frame_width,frame_height; //!< (All cameras) Capture resolution (0: Leave the default) 00066 double gain; //!< (All cameras) Camera gain (0: Leave the default) 00067 double ieee1394_fps; //!< (IEEE1394 cameras) Frame rate for the capture (0: Leave the default). 00068 bool ieee1394_grayscale; //!< (IEEE1394 cameras) Whether to grab grayscale images (Default=false). 00069 }; 00070 00071 /** A class for grabing images from a "OpenCV"-compatible camera, or from an AVI video file. 00072 * See the constructor for the options when opening the camera. 00073 * 00074 * Unless input from AVI files is required, it is recommended to use the more generic class 00075 * mrpt::hwdrivers::CCameraSensor. 00076 * 00077 * \note This class is only available when compiling MRPT with the flag "MRPT_HAS_OPENCV" defined. 00078 * \note Some code is based on the class CaptureCamera from the Orocos project. 00079 * \sa mrpt::hwdrivers::CCameraSensor, CImageGrabber_dc1394 00080 * \sa The most generic camera grabber in MRPT: mrpt::hwdrivers::CCameraSensor 00081 */ 00082 class MRPTDLLIMPEXP CImageGrabber_OpenCV 00083 { 00084 protected: 00085 /** Set to false if we could not initialize the camera. 00086 */ 00087 bool m_bInitialized; 00088 00089 /** Internal use: 00090 */ 00091 mrpt::utils::void_ptr_noncopy /*CvCapture*/ m_capture; 00092 00093 public: 00094 /** Constructor for cameras: 00095 * \param cameraIndex Set the camera index, or -1 if it does not matter and you select AUTODETECT as cameraType. 00096 * \param cameraType Can be any value of TCameraType, or CAMERA_CV_AUTODETECT if there is only one camera. 00097 * \param options Capture options, defined in mrpt::vision::TCaptureCVOptions. If not provided, all the default options will be used. 00098 */ 00099 CImageGrabber_OpenCV( 00100 int cameraIndex = -1, 00101 TCameraType cameraType = CAMERA_CV_AUTODETECT, 00102 const TCaptureCVOptions &options = TCaptureCVOptions() 00103 ); 00104 00105 /** Constructor for AVI files: 00106 */ 00107 CImageGrabber_OpenCV( const std::string &AVI_fileName ); 00108 00109 /** Destructor 00110 */ 00111 virtual ~CImageGrabber_OpenCV( ); 00112 00113 /** Check whether the camera has been open succesfully. */ 00114 bool isOpen() const 00115 { 00116 return m_bInitialized; 00117 } 00118 00119 /** Grab an image from the opened camera. 00120 * \param out_observation The object to be filled with sensed data. 00121 * 00122 * \return false on any error, true if all go fine. 00123 */ 00124 bool getObservation( mrpt::slam::CObservationImage &out_observation); 00125 00126 00127 }; // End of class 00128 00129 } // End of NS 00130 } // End of NS 00131 00132 00133 #endif
Page generated by Doxygen 1.5.9 for MRPT 0.7.1 SVN: at Mon Aug 17 22:32:05 EDT 2009 |