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 CCImageGrabber_dc1394 00029 #define CCImageGrabber_dc1394 00030 00031 #include <mrpt/config.h> 00032 00033 #include <mrpt/slam/CObservationImage.h> 00034 00035 00036 namespace mrpt 00037 { 00038 namespace vision 00039 { 00040 00041 typedef enum { 00042 FRAMERATE_1_875= 32, 00043 FRAMERATE_3_75, 00044 FRAMERATE_7_5, 00045 FRAMERATE_15, 00046 FRAMERATE_30, 00047 FRAMERATE_60, 00048 FRAMERATE_120, 00049 FRAMERATE_240 00050 } grabber_dc1394_framerate_t; 00051 00052 typedef enum { 00053 COLOR_CODING_MONO8= 352, 00054 COLOR_CODING_YUV411, 00055 COLOR_CODING_YUV422, 00056 COLOR_CODING_YUV444, 00057 COLOR_CODING_RGB8, 00058 COLOR_CODING_MONO16 00059 } grabber_dc1394_color_coding_t; 00060 00061 00062 /** Options used when creating an dc1394 capture object 00063 * All but the frame size, framerate, and color_coding can be changed dynamically by CImageGrabber_dc1394::changeCaptureOptions 00064 * \sa CImageGrabber_dc1394 00065 */ 00066 struct TCaptureOptions_dc1394 00067 { 00068 TCaptureOptions_dc1394() : 00069 frame_width (640), 00070 frame_height (480), 00071 framerate (FRAMERATE_15), 00072 color_coding (COLOR_CODING_YUV422), 00073 mode7 (-1), 00074 shutter (-1), 00075 gain (-1), 00076 gamma (-1), 00077 brightness (-1), 00078 exposure (-1), 00079 sharpness (-1), 00080 white_balance (-1) 00081 {} 00082 00083 int frame_width,frame_height; //!< Capture resolution (Default: 640x480) 00084 grabber_dc1394_framerate_t framerate; 00085 grabber_dc1394_color_coding_t color_coding; 00086 00087 int mode7; //!< -1: Normal mode, i>=0: use MODE7_i, then frame_width/height and color_coding are ignored. 00088 00089 int shutter; //!< Shutter, -1=default:Do not change 00090 int gain; //!< Gain, -1=default:Do not change 00091 int gamma; //!< Gamma, -1=default:Do not change 00092 int brightness; //!< Brightness, -1=default:Do not change 00093 int exposure; //!< Exposure, -1=default:Do not change 00094 int sharpness; //!< Sharpness, -1=default:Do not change 00095 int white_balance; //!< White balance, -1=default:Do not change 00096 }; 00097 00098 /** A class for grabing images from a IEEE1394 (Firewire) camera using the libdc1394-2 library. 00099 * See the constructor for the options when opening the camera. Notice that you may have 00100 * to carefully set the resolution, framerate and color_mode. See the verbose parameter of 00101 * the constructor, which can display a list of supported modes in your camera. 00102 * 00103 * This class is able to manage any Firewire cameras, including Stereo or multi-cameras in general, 00104 * so this can be used to open the Bumblebee camera (not tested yet). 00105 * 00106 * \note This class requires MRPT compiled with "libdc1394-2" (Only works under Linux for now) and "opencv". 00107 * \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. 00108 * \sa The most generic camera grabber in MRPT: mrpt::hwdrivers::CCameraSensor 00109 */ 00110 class MRPTDLLIMPEXP CImageGrabber_dc1394 00111 { 00112 protected: 00113 /** Set to false if we could not initialize the camera. 00114 */ 00115 bool m_bInitialized; 00116 00117 /** Internal use: */ 00118 void /* dc1394_t * */ *m_dc1394_lib_context; 00119 void /* dc1394camera_t* */ *m_dc1394camera; 00120 int m_desired_mode; 00121 00122 00123 TCaptureOptions_dc1394 m_options; 00124 00125 public: 00126 /** Constructor: open an ieee1394 camera. 00127 * \param cameraGUID Set the camera GUID to open, or 0 to open the first found camera. 00128 * \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. 00129 * \param options Capture options, defined in mrpt::vision::TCaptureOptions_dc1394. 00130 * \param verbose Displays a lot of information about the camera to be open and its valid video modes. 00131 */ 00132 CImageGrabber_dc1394( 00133 uint64_t cameraGUID = 0, 00134 uint16_t cameraUnit = 0, 00135 const TCaptureOptions_dc1394 &options = TCaptureOptions_dc1394(), 00136 bool verbose = false 00137 ); 00138 00139 /** Destructor 00140 */ 00141 virtual ~CImageGrabber_dc1394( ); 00142 00143 /** Check whether the camera has been open succesfully. */ 00144 bool isOpen() const 00145 { 00146 return m_bInitialized; 00147 } 00148 00149 /** Changes the capture properties (brightness, gain, shutter, etc) 00150 * The frame size, framerate, and color_coding fields in options are ignored since they can be only set at construction time. 00151 * \return false on error 00152 */ 00153 bool changeCaptureOptions( const TCaptureOptions_dc1394 &options ); 00154 00155 00156 /** Grab an image from the opened camera. 00157 * \param out_observation The object to be filled with sensed data. 00158 * 00159 * \return false on any error, true if all go fine. 00160 */ 00161 bool getObservation( mrpt::slam::CObservationImage &out_observation); 00162 00163 00164 }; // End of class 00165 00166 } // End of NS 00167 } // End of NS 00168 00169 00170 #endif
Page generated by Doxygen 1.5.7.1 for MRPT 0.7.1 SVN: at Mon Aug 17 22:58:25 EDT 2009 |