![]() |
latest version v1.9 - last update 10 Apr 2010 |
![]() |
00001 /* 00002 * Copyright (C) 2003, 2004, 2005, 2006 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * This file is part of the LTI-Computer Vision Library (LTI-Lib) 00006 * 00007 * The LTI-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License (LGPL) 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * The LTI-Lib is distributed in the hope that it will be 00013 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00014 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with the LTI-Lib; see the file LICENSE. If 00019 * not, write to the Free Software Foundation, Inc., 59 Temple Place - 00020 * Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 00023 00024 /*-------------------------------------------------------------------- 00025 * project ....: LTI-Lib: Image Processing and Computer Vision Library 00026 * file .......: ltiCamera.h 00027 * authors ....: Claudia Goenner 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 28.8.2003 00030 * revisions ..: $Id: ltiCamera.h,v 1.6 2006/02/08 12:01:39 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_CAMERA_H_ 00034 #define _LTI_CAMERA_H_ 00035 00036 #include "ltiFunctor.h" 00037 00038 namespace lti { 00039 /** 00040 * Parent class for all cameras with control over the lens system, including 00041 * zooming. Cameras without zoom shall set the maxZoom parameter to 0. When 00042 * deriving a camera, please add all values (which can be set) as parameters 00043 * to allow construction with application specific settings. During operation 00044 * value setting by a specific method is more efficient as by setParameters. 00045 * Camera constants, e.g. the max. and min. focus, should be defined as constant 00046 * parameters. 00047 * 00048 * Please note that the camera may take a little while until a focus, zoom, etc. 00049 * position is reached. Thus the values in the parameters and those returned by 00050 * the get-methods may differ. 00051 * 00052 * The parameter functionality was reimplemented, following the functor's concept, 00053 * because of a problem with multiple inheritance, which occures when deriving 00054 * classed which are e.g. both a camera and a panTiltUnit. 00055 */ 00056 class camera : public virtual functor { 00057 public: 00058 /** 00059 * the parameters for the class camera 00060 */ 00061 class parameters : public virtual functor::parameters { 00062 public: 00063 /** 00064 * default constructor 00065 */ 00066 parameters(); 00067 00068 /** 00069 * copy constructor 00070 * @param other the parameters object to be copied 00071 */ 00072 parameters(const parameters& other); 00073 00074 /** 00075 * destructor 00076 */ 00077 ~parameters(); 00078 00079 /** 00080 * returns name of this type 00081 */ 00082 const char* getTypeName() const; 00083 00084 /** 00085 * copy the contents of a parameters object 00086 * @param other the parameters object to be copied 00087 * @return a reference to this parameters object 00088 */ 00089 parameters& copy(const parameters& other); 00090 00091 /** 00092 * copy the contents of a parameters object 00093 * @param other the parameters object to be copied 00094 * @return a reference to this parameters object 00095 */ 00096 parameters& operator=(const parameters& other); 00097 00098 00099 /** 00100 * returns a pointer to a clone of the parameters 00101 */ 00102 virtual functor::parameters* clone() const; 00103 00104 /** 00105 * write the parameters in the given ioHandler 00106 * @param handler the ioHandler to be used 00107 * @param complete if true (the default) the enclosing begin/end will 00108 * be also written, otherwise only the data block will be written. 00109 * @return true if write was successful 00110 */ 00111 virtual bool write(ioHandler& handler,const bool complete=true) const; 00112 00113 /** 00114 * read the parameters from the given ioHandler 00115 * @param handler the ioHandler to be used 00116 * @param complete if true (the default) the enclosing begin/end will 00117 * be also written, otherwise only the data block will be written. 00118 * @return true if write was successful 00119 */ 00120 virtual bool read(ioHandler& handler,const bool complete=true); 00121 00122 # ifdef _LTI_MSC_6 00123 /** 00124 * this function is required by MSVC only, as a workaround for a 00125 * very awful bug, which exists since MSVC V.4.0, and still by 00126 * V.6.0 with all bugfixes (so called "service packs") remains 00127 * there... This method is also public due to another bug, so please 00128 * NEVER EVER call this method directly: use read() instead 00129 */ 00130 bool readMS(ioHandler& handler,const bool complete=true); 00131 00132 /** 00133 * this function is required by MSVC only, as a workaround for a 00134 * very awful bug, which exists since MSVC V.4.0, and still by 00135 * V.6.0 with all bugfixes (so called "service packs") remains 00136 * there... This method is also public due to another bug, so please 00137 * NEVER EVER call this method directly: use write() instead 00138 */ 00139 bool writeMS(ioHandler& handler,const bool complete=true) const; 00140 # endif 00141 00142 // ------------------------------------------------ 00143 // the parameters 00144 // ------------------------------------------------ 00145 00146 /** 00147 * Mode of determing the whiteBalance. Default: Auto, i.e. true. 00148 * Derived classes may distinguish between more than two modes by 00149 * adding a whiteBalanceMode-parameter. If a class does not distinguish between 00150 * further modes false refers to manual white balance, i.e. direct control 00151 * by the red and blue gain values. Default: true. 00152 */ 00153 bool autoWhiteBalance; 00154 00155 /** 00156 * automatic determination of the global gain by the camera (true) or 00157 * manual setting by the user (false). Default: true. 00158 */ 00159 bool autoGain; 00160 00161 /** 00162 * the global gain in dB. Default: maxGain. 00163 */ 00164 float gain; 00165 00166 /** 00167 * the red gain in dB. Default: maxRBGain. 00168 */ 00169 float redGain; 00170 00171 /** 00172 * the green gain in dB. Default: maxRBGain. 00173 */ 00174 float blueGain; 00175 00176 /** 00177 * the min. possible gain in dB 00178 */ 00179 static const float minGain; 00180 00181 /** 00182 * the max. possible gain in dB 00183 */ 00184 static const float maxGain; 00185 00186 /** 00187 * the min. possible red or blue gain in dB 00188 */ 00189 static const float minRBGain; 00190 00191 /** 00192 * the max. possible red or blue gain in dB 00193 */ 00194 static const float maxRBGain; 00195 00196 /** 00197 * if true the shutter speed is set automatically, otherwise it is 00198 * controlled manually. Default: true. 00199 */ 00200 bool autoShutter; 00201 00202 /** 00203 * the shutter speed in 1/s. Default: minShutterSpeed. 00204 */ 00205 float shutterSpeed; 00206 00207 /** 00208 * the minimum shutter speed of the device 00209 */ 00210 static const float minShutterSpeed; 00211 00212 /** 00213 * the maximum shutter speed 00214 */ 00215 static const float maxShutterSpeed; 00216 00217 /** 00218 * auto focus (true) or manual focus (false). Default: true. 00219 */ 00220 bool autoFocus; 00221 00222 /** 00223 * focus value which the camera shall use in meter. Default: maxFocus. 00224 */ 00225 float focus; 00226 00227 /** 00228 * the minimum focus in meter 00229 */ 00230 static const float minFocus; 00231 00232 /** 00233 * the maximum focus in meter 00234 */ 00235 static const float maxFocus; 00236 00237 /** 00238 * Zoom value which the camera shall use. Default: 0. 00239 */ 00240 float zoom; 00241 00242 /** 00243 * The maximum possible zoom value. The zoom ranges from 0 (no zoom) to 00244 * max. zoom. 00245 */ 00246 static const float maxZoom; 00247 }; 00248 00249 /** 00250 * default constructor 00251 */ 00252 camera(); 00253 00254 /** 00255 * Construct a functor using the given parameters 00256 */ 00257 camera(const parameters& par); 00258 00259 /** 00260 * copy constructor 00261 * @param other the object to be copied 00262 */ 00263 camera(const camera& other); 00264 00265 /** 00266 * destructor 00267 */ 00268 virtual ~camera(); 00269 00270 /** 00271 * returns the name of this type ("camera") 00272 */ 00273 virtual const char* getTypeName() const; 00274 00275 /** 00276 * copy data of "other" functor. 00277 * @param other the functor to be copied 00278 * @return a reference to this functor object 00279 */ 00280 camera& copy(const camera& other); 00281 00282 /** 00283 * alias for copy member 00284 * @param other the functor to be copied 00285 * @return a reference to this functor object 00286 */ 00287 camera& operator=(const camera& other); 00288 00289 /** 00290 * returns a pointer to a clone of this functor. 00291 */ 00292 virtual functor* clone() const = 0; 00293 00294 /** 00295 * returns used parameters 00296 */ 00297 const parameters& getParameters() const; 00298 00299 //------------------------- 00300 // the camera functionality 00301 //------------------------- 00302 00303 /** 00304 * turn on automatic white balance 00305 * @return true on success 00306 */ 00307 virtual bool autoWhiteBalanceOn() = 0; 00308 00309 /** 00310 * turn on automatic gain 00311 * @return true on success 00312 */ 00313 virtual bool autoGainOn() = 0; 00314 00315 /** 00316 * set the global gain. Turns off automatic gain, 00317 * i.e. sets it to manual mode. 00318 * @param value the gain value 00319 * @return true on success 00320 */ 00321 virtual bool setGain(float value) = 0; 00322 00323 /** 00324 * set the red gain 00325 * @param value the red gain value 00326 * @return true on success 00327 */ 00328 virtual bool setRedGain(float value) = 0; 00329 00330 /** 00331 * set the blue gain 00332 * @param value the blue gain value 00333 * @return true on success 00334 */ 00335 virtual bool setBlueGain(float value) = 0; 00336 00337 /** 00338 * turn on automatic choice of the shutter speed 00339 * @return true on success 00340 */ 00341 virtual bool autoShutterSpeedOn() = 0; 00342 00343 /** 00344 * set the shutter speed. Turn off automatic shutter. 00345 * @param value the shutter speed 00346 * @return true on success 00347 */ 00348 virtual bool setShutterSpeed(float value) = 0; 00349 00350 /** 00351 * set the focus. Turns off autofocus. 00352 * @param value the focus value 00353 * @return true on success 00354 */ 00355 virtual bool setFocus(float value) = 0; 00356 00357 /** 00358 * set the focus to infiniy. Turns off autofocus. 00359 * @return true on success 00360 */ 00361 virtual bool setFocusToInfinity() = 0; 00362 00363 /** 00364 * turn on auto focus 00365 * @return true on success 00366 */ 00367 virtual bool autoFocusOn() = 0; 00368 00369 /** 00370 * @return the current focus 00371 */ 00372 virtual float getFocus() const = 0; 00373 00374 /** 00375 * set the zoom which the camera shall use next. 00376 * @param value the zoom value 00377 * @return true on success 00378 */ 00379 virtual bool setZoom(float value) = 0; 00380 00381 /** 00382 * @return the current zoom. 00383 */ 00384 virtual float getZoom() const = 0; 00385 00386 /** 00387 * Get the focus and zoom values from a single time instant. 00388 * @param focus the current focus value 00389 * @param zoom the current zoom value 00390 * @return true on success 00391 */ 00392 virtual bool getLensSetting(float& focus, float& zoom) const = 0; 00393 00394 }; 00395 } 00396 00397 #endif