latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 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 .......: ltiFireWireDCAM.h 00027 * authors ....: Arnd Hannemann 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 21.10.2004 00030 * revisions ..: $Id: ltiFireWireDCAM.h,v 1.7 2008/08/17 22:20:12 alvarado Exp $ 00031 */ 00032 00033 #ifndef _LTI_FIRE_WIRE_D_C_A_M_H_ 00034 #define _LTI_FIRE_WIRE_D_C_A_M_H_ 00035 00036 #include "ltiHardwareConfig.h" 00037 00038 #ifdef _USE_FIRE_WIRE_DCAM 00039 00040 #include <libraw1394/raw1394.h> 00041 #include <libdc1394/dc1394_control.h> 00042 00043 #include <string> 00044 #include <vector> 00045 #include <set> 00046 #include <map> 00047 #include "ltiFrameGrabber.h" 00048 #include "ltiMergeYCbCrToImage.h" 00049 #include "ltiBayerDemosaicing.h" 00050 #include "ltiMutex.h" 00051 00052 00053 namespace lti { 00054 /** 00055 * Grab imags from FireWire Cameras. 00056 * 00057 * This functor permits to interact with standard FireWire DCAM cameras (aka 00058 * IIDC v1.3x). It is a wrapper of the libdc1394 library in (linux). You 00059 * may find the information of the IIDC standard useful, which can be found 00060 * on the net (for instance, in 00061 * http://damien.douxchamps.net/ieee1394/libdc1394/iidc_specifications.php ). 00062 * 00063 * System requirements: 00064 * - linux kernel modules ieee1394, ohci1394, raw1394 and video1394 00065 * - libdc1394 (>= 1.0.0, < 2.x) 00066 * - libraw1394 (>= 0.9.0) 00067 * Since the version 2.x of libdc1394 still is beta, no migration has been 00068 * done for it yet. Several changes are required, but the version control 00069 * of that library isn't supported yet. 00070 * 00071 * Installation: 00072 * -# compile or install above kernel modules for your kernel (usually 00073 * they are in most distributions ready) 00074 * -# create video devicefiles for video1394 00075 * (e.g. /dev/video1394). This is also usually automatically done. 00076 * -# compile or install libdc1394 and libraw1394. Most distributions 00077 * provide packages for them. Do not forget to install the "dev" or 00078 * "devel" packages of the library as well. 00079 * -# edit extrapaths.mk in the linux directory of your ltilib to permit 00080 * the use of this functor. 00081 * (example can be found in extrapaths_template.mk) 00082 * -# compile ltilib 00083 * -# all kernel modules must be loaded before running any code that uses 00084 * this class. 00085 * 00086 * Example: 00087 * \code 00088 * // viewer to display taken shot 00089 * viewer view("FireWireDCAM"); 00090 * 00091 * fireWireDCAM::parameters camPar; 00092 * fireWireDCAM cam; 00093 00094 * // will be preserved by init() 00095 * camPar.deviceFile = "/dev/video1394/0"; 00096 * camPar.oneShot = true; 00097 * camPar.brightness = 22; 00098 * 00099 * // as the camera is initialized now, the new parameters will be written 00100 * // into the camera 00101 * cam.setParameters(camPar); 00102 * // take picture 00103 * image img; 00104 * cam.apply(img); 00105 * 00106 * // show image 00107 * view.show(img); 00108 * 00109 * \endcode 00110 * 00111 * Not yet implemented: 00112 * - format7 (scalable image) 00113 * - color modes: Mono16, RGB, YUV444 00114 * - camera features: (see fireWireDCAM::parameters) 00115 * 00116 * Other things to do: 00117 * - get feature constraints 00118 * - it would be much better to use a wrapper class instead of including 00119 * raw1394.h and dc1394_control.h directly (namespace) 00120 * - better error handling (e.g. remember setup_capture failures etc..) 00121 * 00122 * \warning Even if some code has been developed for support of 00123 * one-push and format7 features, we haven't got a camera that 00124 * supports them and therefore that code may not work. Please 00125 * report any problems, or even better, submit a patch with fixes if 00126 * they are necessary. 00127 */ 00128 class fireWireDCAM : public frameGrabber { 00129 public: 00130 // ------------------------------------------------ 00131 // enumerations 00132 // ------------------------------------------------ 00133 00134 /** 00135 * Auto correction modes for parameters 00136 * 00137 * While setting the parameters for a camera, you can decide how to behave 00138 * on invalid parameters. 00139 */ 00140 enum eFixMode { 00141 NoFix, /**< Use the parameters as they are given, and if something is 00142 invalid, return an error */ 00143 AutoFix, /**< Try to use the parameters as they are given, but is 00144 something is invalid or not supported by the active camera, 00145 change it to a valid configuration */ 00146 Upload /**< Ignore the parameters given, and simply upload the values 00147 in use in the camera indicated by the parameters set, which 00148 is set as active. */ 00149 }; 00150 00151 /** 00152 * Feature state 00153 * 00154 * Most features, following the IIDC standard, can be used in one of the 00155 * following states. 00156 * 00157 * Several notes on the values: 00158 * - The FeatureOff can under circumstances be used to check if a 00159 * feature can be turned off. The use of any other state implies that 00160 * the feature is on. 00161 * - The FeatureOnePush activates the "one-push" adjustment when the 00162 * functor parameters are updated (setParameters() do that too, of 00163 * course), or when one specific methods for direct camera control 00164 * (like setBrightness()) is used. 00165 * - The FeatureAbsolute is identical to manual, except that, if a camera 00166 * supports it, the values are given in certain units specified by the 00167 * standard, like \b degrees for hue, pan and tilt, \b percentage for 00168 * brightness and saturation, \b meters for focus, and so on. 00169 * - FeatureNA is used to indicate that a feature is not available or 00170 * that the user wants this functor not to touch the configuration of 00171 * a given feature. 00172 */ 00173 enum eFeatureState { 00174 FeatureNA=0, /**< Feature not available */ 00175 FeatureOff=1, /**< Feature is deactivated */ 00176 FeatureAuto=2, /**< Feature adjustments are taken automatically */ 00177 FeatureManual=4, /**< Feature adjustments are done by the user */ 00178 FeatureOnePush=8,/**< Feature is automatically adjusted but only once */ 00179 FeatureAbsolute=16 /**< Feature is manually controled but using absolute 00180 values */ 00181 }; 00182 00183 /** 00184 * Enumeration of encoding methods allowed by the IIDC standard of the IEEE 00185 * 1394. Many of these constants are available for Format7 modes only, 00186 * i.e., if the camera supports scalable image sizes. 00187 * 00188 * Some of the following encoding methods are not supported by the LTI-Lib 00189 * yet, specially those with 16 bits. Hence, the equivalent formats with 00190 * lower precision would be used instead. 00191 */ 00192 enum eColorMode { 00193 Mono8 = 0, /**< Monochromatic with 8 bits (unsigned) per pixel */ 00194 Mono16, /**< Monochromatic with 16 bits (unsigned) per pixel */ 00195 Mono16s, /**< Monochromatic with 16 bits (signed) per pixel */ 00196 YUV411, /**< Yuv color space with 4:1:1 ratio */ 00197 YUV422, /**< Yuv color space with 4:2:2 ratio */ 00198 YUV444, /**< Yuv color space with 4:4:4 ratio */ 00199 RGB8, /**< RGB encoding with 8 bits per color channel */ 00200 RGB16, /**< RGB encoding with 16 bits (unsigned) per color channel */ 00201 RGB16s, /**< RGB encoding with 16 bits (signed) per color channel */ 00202 Raw8, /**< Raw data in 8 bits */ 00203 Raw16, /**< Raw data in 16 bits */ 00204 UnknownEncoding /**< Dummy value for an unknown encoding */ 00205 }; 00206 00207 /** 00208 * The parameters for the class fireWireDCAM 00209 */ 00210 class parameters : public frameGrabber::parameters { 00211 public: 00212 00213 /** 00214 * Default constructor 00215 */ 00216 parameters(); 00217 00218 /** 00219 * Copy constructor 00220 * @param other the parameters object to be copied 00221 */ 00222 parameters(const parameters& other); 00223 00224 /** 00225 * Destructor 00226 */ 00227 ~parameters(); 00228 00229 /** 00230 * Returns name of this type 00231 */ 00232 const char* getTypeName() const; 00233 00234 /** 00235 * Copy the contents of a parameters object 00236 * @param other the parameters object to be copied 00237 * @return a reference to this parameters object 00238 */ 00239 parameters& copy(const parameters& other); 00240 00241 /** 00242 * Copy the contents of a parameters object 00243 * @param other the parameters object to be copied 00244 * @return a reference to this parameters object 00245 */ 00246 parameters& operator=(const parameters& other); 00247 00248 00249 /** 00250 * Returns a pointer to a clone of the parameters 00251 */ 00252 virtual functor::parameters* clone() const; 00253 00254 /** 00255 * Write the parameters in the given ioHandler 00256 * @param handler the ioHandler to be used 00257 * @param complete if true (the default) the enclosing begin/end will 00258 * be also written, otherwise only the data block will be written. 00259 * @return true if write was successful 00260 */ 00261 virtual bool write(ioHandler& handler,const bool complete=true) const; 00262 00263 /** 00264 * Read the parameters from the given ioHandler 00265 * @param handler the ioHandler to be used 00266 * @param complete if true (the default) the enclosing begin/end will 00267 * be also written, otherwise only the data block will be written. 00268 * @return true if write was successful 00269 */ 00270 virtual bool read(ioHandler& handler,const bool complete=true); 00271 00272 # ifdef _LTI_MSC_6 00273 /** 00274 * This function is required by MSVC only, as a workaround for a 00275 * very awful bug, which exists since MSVC V.4.0, and still by 00276 * V.6.0 with all bugfixes (so called "service packs") remains 00277 * there... This method is also public due to another bug, so please 00278 * NEVER EVER call this method directly: use read() instead 00279 */ 00280 bool readMS(ioHandler& handler,const bool complete=true); 00281 00282 /** 00283 * This function is required by MSVC only, as a workaround for a 00284 * very awful bug, which exists since MSVC V.4.0, and still by 00285 * V.6.0 with all bugfixes (so called "service packs") remains 00286 * there... This method is also public due to another bug, so please 00287 * NEVER EVER call this method directly: use write() instead 00288 */ 00289 bool writeMS(ioHandler& handler,const bool complete=true) const; 00290 # endif 00291 00292 // ------------------------------------------------ 00293 // the parameters 00294 // ------------------------------------------------ 00295 00296 /** 00297 * Indicate how to behave if invalid parameters are given. 00298 * 00299 * You can choose if you want your parameters to be taken exactly as they 00300 * are given, and if there is an invalid configuration to report an error 00301 * (NoFix). You can also indicate that those invalid parameters should 00302 * be automatically modified to valid ones (AutoFix). A third 00303 * possibility is to upload the configuration within the physical camera 00304 * exactly as they are, overwriting everything is given here. 00305 * 00306 * Default value: Upload 00307 */ 00308 eFixMode fixMode; 00309 00310 /** 00311 * Size of the image to be acquired. 00312 * 00313 * The standard IIDC establishes a finite set of valid resolutions for 00314 * IEEE1394 cameras, and groups them in so called \e formats. These 00315 * formats have the following names: 00316 * 00317 * - Format 0: VGA non compressed, for resolutions less than or equal 00318 * to 640x480 00319 * - Format 1: SVGA non compressed, for resolutions greater than Format 0 00320 * and less than or equal to 1024x768 00321 * - Format 2: SVGA non compressed, for resolutions greater than Format 1 00322 * and less than or equal to 1600x1200 00323 * - Format 6: Still image 00324 * - Format 7: Scalable image size 00325 * 00326 * The set of accepted image sizes is 00327 * 00328 * - 160x120 (format 0) 00329 * - 320x240 (format 0) 00330 * - 640x480 (format 0) 00331 * - 800x600 (format 1) 00332 * - 1024x768 (format 1) 00333 * - 1280x960 (format 2) 00334 * - 1600x1200 (format 2) 00335 * 00336 * For each format, only a subset of valid pixel encodings are valid. 00337 * (see the documentation of attribute \c parameters::encoding for a 00338 * detailed list). 00339 * 00340 * Default: 640x480 00341 */ 00342 ipoint resolution; 00343 00344 /** 00345 * Pixel color encoding. 00346 * 00347 * Each resolution in IIDC standard supports only a subset of the 00348 * possible encodings and each camera usually supports just a subset of 00349 * those. 00350 * 00351 * The following table summarizes the possible combinations of 00352 * resolutions and encodings (red means "not allowed", F# indicates 00353 * the format #). 00354 * 00355 * <table align="center" frame="box" border=1> 00356 * <tr> 00357 * <td></td> 00358 * <td>Mono8</td> 00359 * <td>Mono16</td> 00360 * <td>YUV411</td> 00361 * <td>YUV422</td> 00362 * <td>YUV444</td> 00363 * <td>RGB8</td> 00364 * <td>RGB16</td> 00365 * </tr> 00366 * <tr> 00367 * <td>160x120</td> 00368 * <td bgcolor="red"></td> 00369 * <td bgcolor="red"></td> 00370 * <td bgcolor="red"></td> 00371 * <td bgcolor="red"></td> 00372 * <td bgcolor="gray">F0</td> 00373 * <td bgcolor="red"></td> 00374 * <td bgcolor="red"></td> 00375 * </tr> 00376 * <tr> 00377 * <td>320x240</td> 00378 * <td bgcolor="red"></td> 00379 * <td bgcolor="red"></td> 00380 * <td bgcolor="red"></td> 00381 * <td bgcolor="gray">F0</td> 00382 * <td bgcolor="red"></td> 00383 * <td bgcolor="red"></td> 00384 * <td bgcolor="red"></td> 00385 * </tr> 00386 * <tr> 00387 * <td>640x480</td> 00388 * <td bgcolor="gray">F0</td> 00389 * <td bgcolor="gray">F0</td> 00390 * <td bgcolor="gray">F0</td> 00391 * <td bgcolor="gray">F0</td> 00392 * <td bgcolor="red"></td> 00393 * <td bgcolor="gray">F0</td> 00394 * <td bgcolor="red"></td> 00395 * </tr> 00396 * <tr> 00397 * <td>800x600</td> 00398 * <td bgcolor="darkGray">F1</td> 00399 * <td bgcolor="darkGray">F1</td> 00400 * <td bgcolor="red"></td> 00401 * <td bgcolor="darkGray">F1</td> 00402 * <td bgcolor="red"></td> 00403 * <td bgcolor="darkGray">F1</td> 00404 * <td bgcolor="red"></td> 00405 * </tr> 00406 * <tr> 00407 * <td>1024x768</td> 00408 * <td bgcolor="darkGray">F1</td> 00409 * <td bgcolor="darkGray">F1</td> 00410 * <td bgcolor="red"></td> 00411 * <td bgcolor="darkGray">F1</td> 00412 * <td bgcolor="red"></td> 00413 * <td bgcolor="darkGray">F1</td> 00414 * <td bgcolor="red"></td> 00415 * </tr> 00416 * <tr> 00417 * <td>1280x960</td> 00418 * <td bgcolor="lightGray">F2</td> 00419 * <td bgcolor="lightGray">F2</td> 00420 * <td bgcolor="red"></td> 00421 * <td bgcolor="lightGray">F2</td> 00422 * <td bgcolor="red"></td> 00423 * <td bgcolor="lightGray">F2</td> 00424 * <td bgcolor="red"></td> 00425 * </tr> 00426 * <tr> 00427 * <td>1600x1200</td> 00428 * <td bgcolor="lightGray">F2</td> 00429 * <td bgcolor="lightGray">F2</td> 00430 * <td bgcolor="red"></td> 00431 * <td bgcolor="lightGray">F2</td> 00432 * <td bgcolor="red"></td> 00433 * <td bgcolor="lightGray">F2</td> 00434 * <td bgcolor="red"></td> 00435 * </tr> 00436 * </table> 00437 * 00438 * Default value: YUV422 00439 */ 00440 eColorMode encoding; 00441 00442 /** 00443 * Desired framerate. 00444 * 00445 * Only a finite set of framerates are allowed: 00446 * 00447 * - 1.875 00448 * - 3.75 00449 * - 7.5 00450 * - 15 00451 * - 30 00452 * - 60 00453 * - 120 00454 * - 240 00455 * 00456 * If you give another value then the nearest one will be used. 00457 * If the nearest value of the above list is not supported by the 00458 * current camera, then the behaviour will depend on \c autofix. 00459 * 00460 * Default: 15 00461 */ 00462 float framerate; 00463 00464 /** 00465 * @name Camera features 00466 * 00467 * The following attributes give access to most of the features supported 00468 * by the libdc1394. 00469 * 00470 * Each particular camera usually support just a subset of these 00471 * features. You can use the method 00472 * lti::fireWireDCAM::isFeatureAvailable() to check if a particular 00473 * feature is supported by your camera or not. 00474 * 00475 * The attributes with the word "State" control the "state" in which the 00476 * feature is to be used (see the IIDC 1.3x specifications for details, 00477 * which can be found at 00478 *http://damien.douxchamps.net/ieee1394/libdc1394/iidc_specifications.php 00479 * 00480 * Not all cameras support all possible states of a particular feature. 00481 * You can use the method lti::fireWireDCAM::checkFeatureStates() to test 00482 * the camera support for the on-off, auto, manual, one-push and absolute 00483 * states. 00484 * 00485 * If a camera supports the one-push state, then the corresponding values 00486 * for the feature will be automatically adjusted exaclty once, just when 00487 * you set the parameters or update them. Then the camera automatically 00488 * returns into the manual state. You can use the dumpParameters() 00489 * method to obtain the adjusted values. 00490 * 00491 * Please note that the LTI-Lib uses float values for the features to 00492 * cover directly the values that a "absolute-setting capable" camera 00493 * would admit. 00494 * 00495 * The supported features of the IIDC specification are: 00496 * 00497 * - FEATURE_BRIGHTNESS 00498 * - FEATURE_EXPOSURE 00499 * - FEATURE_SHARPNESS 00500 * - FEATURE_WHITE_BALANCE 00501 * - FEATURE_HUE 00502 * - FEATURE_SATURATION 00503 * - FEATURE_GAMMA 00504 * - FEATURE_SHUTTER 00505 * - FEATURE_GAIN 00506 * - FEATURE_IRIS 00507 * - FEATURE_FOCUS 00508 * - FEATURE_ZOOM 00509 * - FEATURE_PAN 00510 * - FEATURE_TILT 00511 * 00512 * The yet unsupported features are (patches to add support for these 00513 * missing features are always welcome). 00514 * 00515 * - FEATURE_TEMPERATURE 00516 * - FEATURE_TRIGGER 00517 * - FEATURE_TRIGGER_DELAY 00518 * - FEATURE_WHITE_SHADING 00519 * - FEATURE_FRAME_RATE 00520 * - FEATURE_OPTICAL_FILTER 00521 * - FEATURE_CAPTURE_SIZE 00522 * - FEATURE_CAPTURE_QUALITY 00523 */ 00524 //@{ 00525 00526 /** 00527 * Brightness feature state. 00528 * 00529 * The brightness usually refers to an offset value that is added to the 00530 * CCD signal before the A/D conversion, and is used to remove residual 00531 * offsets in the signal chain. Therefore, is is also known as "black 00532 * level". You may check, however, which use is being assigned to this 00533 * feature in your camera. 00534 * 00535 * - FeatureOff: Brightness level will have a fixed value. 00536 * - FeatureAuto: Camera will control the brightness level automatically. 00537 * - FeatureManual: User sets the brightness level manually with the 00538 * attribute \c parameters::brightness 00539 * - FeatureOnePush: Brightness value is automatically set and then 00540 * returns to manual state. 00541 * 00542 * Default value: FeatureAuto 00543 */ 00544 eFeatureState brightnessState; 00545 00546 /** 00547 * Overall brightness. 00548 * 00549 * Default value: 0 00550 */ 00551 float brightness; 00552 00553 /** 00554 * Auto Exposure state 00555 * 00556 * - FeatureOff: Exposure will be manually controlled by gain, iris and 00557 * shutter features. 00558 * - FeatureAuto: reference level is automatically adjusted continuously. 00559 * - FeatureManual: exposure level automatically set, but the user 00560 * selects the reference level in parameters::exposure 00561 * - FeatureOnePush: reference level is set once automatically and then 00562 * the state returns to manual. 00563 * 00564 * Default value: FeatureAuto 00565 */ 00566 eFeatureState exposureState; 00567 00568 /** 00569 * Auto exposure control. 00570 * 00571 * Reference level used for the auto exposure control 00572 * 00573 * Default value: 0 00574 */ 00575 float exposure; 00576 00577 /** 00578 * Sharpness control state. 00579 * 00580 * - FeatureOff: sharpness level will have a fixed value 00581 * - FeatureAuto: camera controls sharpness level automatically. 00582 * - FeatureManual: Sharpness level is set to the value in 00583 * parameters::sharpness 00584 * - FeatureOnePush: sharpness level is set once automatically and then 00585 * the state returns to manual. 00586 * 00587 * Default value: FeatureAuto 00588 */ 00589 eFeatureState sharpnessState; 00590 00591 /** 00592 * Sharpness control value 00593 * 00594 * Default value: 0 00595 */ 00596 float sharpness; 00597 00598 /** 00599 * Automatic white balance. 00600 * 00601 * - FeatureOff: white balance will have fixed values. 00602 * - FeatureAuto: camera controls white balance automatically. 00603 * - FeatureManual: white balance will be manually controlled through 00604 * the values parameters::redGain and 00605 * parameters::blueGain. 00606 * - FeatureOnePush: white balance is set once automatically and then 00607 * the state returns to manual. 00608 * 00609 * Default value: FeatureAuto 00610 */ 00611 eFeatureState whiteBalanceState; 00612 00613 /** 00614 * Gain applied to red (or V) components if the 00615 * parameters::whiteBalanceState requires it. 00616 * 00617 * Default value: 0 00618 */ 00619 float redGain; 00620 00621 /** 00622 * Gain applied to blue (or U) components if the 00623 * parameters::whiteBalanceState requires it. 00624 * 00625 * Default value: 0 00626 */ 00627 float blueGain; 00628 00629 /** 00630 * Hue control state 00631 * 00632 * - FeatureOff: hue control will have fixed values. 00633 * - FeatureAuto: camera controls hue automatically. 00634 * - FeatureManual: hue will be manually controlled through 00635 * the value parameters::hue. 00636 * - FeatureOnePush: hue is set once automatically and then 00637 * the state returns to manual. 00638 * 00639 * Default value: FeatureAuto 00640 */ 00641 eFeatureState hueState; 00642 00643 /** 00644 * Hue control value 00645 * 00646 * Controls color phase of the picture 00647 * 00648 * Default value: 0 00649 */ 00650 float hue; 00651 00652 /** 00653 * Saturation control state 00654 * 00655 * - FeatureOff: saturation control will have fixed values. 00656 * - FeatureAuto: camera controls saturation automatically. 00657 * - FeatureManual: saturation will be manually controlled through 00658 * the value parameters::saturation. 00659 * - FeatureOnePush: saturation is set once automatically and then 00660 * the state returns to manual. 00661 * 00662 * Default value: FeatureAuto 00663 */ 00664 eFeatureState saturationState; 00665 00666 /** 00667 * Saturation control value 00668 * 00669 * Controls color saturation of the picture 00670 * 00671 * Default value: 0 00672 */ 00673 float saturation; 00674 00675 /** 00676 * Gamma control state 00677 * 00678 * - FeatureOff: gamma control will have fixed values. 00679 * - FeatureAuto: camera controls gamma automatically. 00680 * - FeatureManual: gamma will be manually controlled through 00681 * the value parameters::gamma. 00682 * - FeatureOnePush: gamma is set once automatically and then 00683 * the state returns to manual. 00684 * 00685 * Default value: FeatureAuto 00686 */ 00687 eFeatureState gammaState; 00688 00689 /** 00690 * Gamma control value 00691 * 00692 * Controls gamma value used in the adjustment between incomming light 00693 * level and output picture level. 00694 * 00695 * Default value: 0 00696 */ 00697 float gamma; 00698 00699 /** 00700 * State for the shutter control. 00701 * 00702 * "Shutter" means the integration time of the incomming light. 00703 * 00704 * - FeatureOff: integration time will have fixed values. 00705 * - FeatureAuto: camera controls shutter automatically. 00706 * - FeatureManual: shutter will be manually controlled through 00707 * the value parameters::shutter. 00708 * - FeatureOnePush: shutter is set once automatically and then 00709 * the state returns to manual. 00710 * 00711 * Default value: FeatureAuto 00712 */ 00713 eFeatureState shutterState; 00714 00715 /** 00716 * Integration time of the incomming light. 00717 * 00718 * Influences shutter speed of the camera, higher values 00719 * usually mean lower shutter speed. 00720 * 00721 * Default value: 0 00722 */ 00723 float shutter; 00724 00725 /** 00726 * State used for gain control. 00727 * 00728 * Gain is usually a factor used to multiply the CCD signal, modifying 00729 * the entire dynamic range. 00730 * 00731 * - FeatureOff: gain control will have fixed values. 00732 * - FeatureAuto: camera controls gain automatically. 00733 * - FeatureManual: gain will be manually controlled through 00734 * the value parameters::gain. 00735 * - FeatureOnePush: gain is set once automatically and then 00736 * the state returns to manual. 00737 * 00738 * Default value: FeatureAuto 00739 */ 00740 eFeatureState gainState; 00741 00742 /** 00743 * Gain of the camera, usually applied on all colors. 00744 * 00745 * Default: 0 00746 */ 00747 float gain; 00748 00749 /** 00750 * State used for mechanical iris control. 00751 * 00752 * - FeatureOff: iris control will have fixed values. 00753 * - FeatureAuto: camera controls iris automatically. 00754 * - FeatureManual: iris will be manually controlled through 00755 * the value parameters::iris. 00756 * - FeatureOnePush: iris is set once automatically and then 00757 * the state returns to manual. 00758 * 00759 * Default value: FeatureAuto 00760 */ 00761 eFeatureState irisState; 00762 00763 /** 00764 * Manually set value for the mechanical iris control. 00765 * 00766 * Default: 0 00767 */ 00768 float iris; 00769 00770 /** 00771 * State used for lens focus control. 00772 * 00773 * - FeatureOff: focus control will have fixed values. 00774 * - FeatureAuto: camera controls focus automatically. 00775 * - FeatureManual: focus will be manually controlled through 00776 * the value parameters::focus. 00777 * - FeatureOnePush: focus is set once automatically and then 00778 * the state returns to manual. 00779 * 00780 * Default value: FeatureAuto 00781 */ 00782 eFeatureState focusState; 00783 00784 /** 00785 * Value used for manual lens focus control. 00786 * 00787 * Default: 0 00788 */ 00789 float focus; 00790 00791 /** 00792 * State used for lens zoom control. 00793 * 00794 * - FeatureOff: zoom control will have fixed values. 00795 * - FeatureAuto: camera controls zoom automatically. 00796 * - FeatureManual: zoom will be manually controlled through 00797 * the value parameters::zoom. 00798 * - FeatureOnePush: zoom is set once automatically and then 00799 * the state returns to manual. 00800 * 00801 * Default value: FeatureAuto 00802 */ 00803 eFeatureState zoomState; 00804 00805 /** 00806 * Value used for manual lens zoom control. 00807 * 00808 * Default: 0 00809 */ 00810 float zoom; 00811 00812 /** 00813 * State used for lens pan control. 00814 * 00815 * - FeatureOff: pan control will have fixed values. 00816 * - FeatureAuto: camera controls pan automatically. 00817 * - FeatureManual: pan will be manually controlled through 00818 * the value parameters::pan. 00819 * - FeatureOnePush: pan is set once automatically and then 00820 * the state returns to manual. 00821 * 00822 * Default value: FeatureAuto 00823 */ 00824 eFeatureState panState; 00825 00826 /** 00827 * Value used for manual lens pan control. 00828 * 00829 * Default: 0 00830 */ 00831 float pan; 00832 00833 /** 00834 * State used for lens tilt control. 00835 * 00836 * - FeatureOff: tilt control will have fixed values. 00837 * - FeatureAuto: camera controls tilt automatically. 00838 * - FeatureManual: tilt will be manually controlled through 00839 * the value parameters::tilt. 00840 * - FeatureOnePush: tilt is set once automatically and then 00841 * the state returns to manual. 00842 * 00843 * Default value: FeatureAuto 00844 */ 00845 eFeatureState tiltState; 00846 00847 /** 00848 * Value used for manual lens tilt control. 00849 * 00850 * Default: 0 00851 */ 00852 float tilt; 00853 //@} 00854 00855 /** 00856 * @name One-Push related parameters. 00857 * 00858 * When you set a feature state in "FeatureOnePush", then the camera is 00859 * told to switch into a "one-push" state. You can indicate with the 00860 * following attributes, first, if you want to wait for the camera to 00861 * automatically return to the manual control state; second, if you do 00862 * want to wait, then how often you want to check if the camera returned 00863 * from the "one-push" state, and for how long. 00864 */ 00865 //@{ 00866 /** 00867 * Wait for one-push state ready 00868 * 00869 * This indicates if you want to way for a one-push capable feature 00870 * to finish the automatic configuration. 00871 * 00872 * Default value: false; 00873 */ 00874 bool waitOnePush; 00875 00876 /** 00877 * Frequency (in Herz) of tests if the one-push features are ready. 00878 * 00879 * Default value: 2 (twice a second) 00880 */ 00881 float onePushUpdateRate; 00882 00883 /** 00884 * Time-out for the one-push checks (in seconds) 00885 * 00886 * Default value: 10 (seconds) 00887 */ 00888 float onePushTimeout; 00889 00890 //@} 00891 00892 00893 /** 00894 * Whether one shot mode should be used. 00895 * 00896 * In oneShot mode the computer advises the camera to shot 00897 * one picture and transfer it to the computer. 00898 * If oneShot is false, the camera will transfer pictures 00899 * 00900 * all the time, thus using a lot of fireWire bandwith. 00901 * The latter mode should be faster and recommended if high 00902 * framerates are desired. 00903 * 00904 * If the camera does not support the one shot mode, then 00905 * it will be assumed as if this value were set to false. 00906 * 00907 * Default: true 00908 */ 00909 bool oneShot; 00910 00911 /** 00912 * DMA buffer size in frames. 00913 * 00914 * For DMA access provided by the video1394 library, a buffer ring of the 00915 * given number of images is used. This means, the higher this number, 00916 * the higher the latency of the read images (i.e. the time-shift between 00917 * the image provided by the apply method and the actual time in which 00918 * that image was taken is much higher), as it will be the given number 00919 * of frames in the past. 00920 * 00921 * Default: 2 00922 */ 00923 int dmaBufferSize; 00924 00925 /** 00926 * Whether frames will be dropped to keep down latency. 00927 * 00928 * This indicates what to do if the ring buffer is full: should the 00929 * last image there be kept until read (false), or should the buffer 00930 * be overwritten with the incomming images. 00931 * 00932 * Default: true 00933 */ 00934 bool dropFrames; 00935 00936 /** 00937 * Device file for video capture. 00938 * 00939 * Default: "/dev/video1394/0" 00940 */ 00941 std::string deviceFile; 00942 00943 /** 00944 * Parameters for the Bayer pattern demosaicing method. 00945 * 00946 * Default values: NearestNeighbor and RGGB 00947 */ 00948 bayerDemosaicing::parameters bayerParameters; 00949 00950 /** 00951 * Camera names file. 00952 * 00953 * To provide an easy way to identify your cameras, this functor manages 00954 * a very simple table of camera names associated with a 64bit number. 00955 * The table is stored in the file with the name given here. You can 00956 * provide an absolute path with the file if you want a system-wide 00957 * name convention for your cameras. 00958 * 00959 * If a new camera has been detected, and the \c cameraName is not 00960 * in the current table, then a new line will be added with that name. 00961 * If the file is in use, then a name "Camera-x" will be added with "x" a 00962 * sequence number. 00963 * 00964 * The first camera in the file will always be the default one used. 00965 * 00966 * Please note that this is a class attribute (a static attribute), which 00967 * means that all instances share the same file, since it makes sense 00968 * that all cameras can be addressed using the same names. 00969 * 00970 * Default value: "cameras.txt" 00971 */ 00972 static std::string cameraNamesFile; 00973 00974 /** 00975 * Camera name. 00976 * 00977 * The camera with the given name in the cameraNamesFile will be used. 00978 * If the name has not yet been registered in the cameraNamesFiles, then 00979 * the first available camera will be taken and asigned this \c 00980 * cameraName, which can be later modified by hand in the corresponding 00981 * names file. 00982 * 00983 * Default value: "Default" 00984 */ 00985 std::string cameraName; 00986 00987 protected: 00988 /** 00989 * Write the name of the encoding method into a string 00990 */ 00991 const char* encodingName(const eColorMode& code) const; 00992 /** 00993 * Convert the name of an encoding type to the corresponding 00994 * enum value. 00995 */ 00996 const eColorMode getEncoding(const std::string& name) const; 00997 00998 /** 00999 * Get a string for the fix mode 01000 */ 01001 const char* fixModeName(const eFixMode& mode) const; 01002 01003 /** 01004 * For the given string, return a valid fix mode 01005 */ 01006 const eFixMode getFixMode(const std::string& name) const; 01007 01008 }; 01009 01010 /** 01011 * Default constructor 01012 * 01013 * You usually avoid using this constructor. Using fireWireDCAM(const 01014 * parameters&) you can provide directly for which camera the constructed 01015 * instance should work. 01016 */ 01017 fireWireDCAM(); 01018 01019 /** 01020 * Construct with the given parameters instance. 01021 * 01022 * You can give directly in the parameters object for which camera 01023 * the instance should be created, therefore this is the most used 01024 * constructor of this functor. 01025 */ 01026 fireWireDCAM(const parameters& par); 01027 01028 01029 /** 01030 * Copy constructor 01031 * @param other the object to be copied 01032 */ 01033 fireWireDCAM(const fireWireDCAM& other); 01034 01035 /** 01036 * Destructor 01037 */ 01038 virtual ~fireWireDCAM(); 01039 01040 /** 01041 * Returns the name of this type ("fireWireDCAM") 01042 */ 01043 virtual const char* getTypeName() const; 01044 01045 /** 01046 * Gets one frame from camera. 01047 * @param dest image the result will be left here. 01048 * @return true if apply successful or false otherwise. 01049 */ 01050 bool apply(image& dest); 01051 01052 /** 01053 * Gets one frame from camera. 01054 * @param dest channel8 the result be left here. 01055 * @return true if apply successful or false otherwise. 01056 */ 01057 bool apply(channel8& dest); 01058 01059 01060 /** 01061 * Grabs a raw frame from camera. 01062 * @param dest channle8 where the result will be left. 01063 * @return true if apply successful or false otherwise. 01064 */ 01065 bool grabRaw(matrix<ubyte>& dest); 01066 01067 /** 01068 * write parameters in camera 01069 */ 01070 bool updateParameters(); 01071 01072 /** 01073 * @name Direct access to camera features. 01074 * 01075 * These methods access the camera registers directly, and they try to 01076 * update the internal parameters. However, since the cameras may adjust 01077 * themselves, you may find the method fireWireDCAM::dumpParameters() 01078 * useful, which asks the camera for all parameters in use at once. 01079 * 01080 * If a feature supports the "one-push state", then the automatic 01081 * configuration will begin as soon as you call the corresponding method 01082 * with the value \c FeatureOnePush as state (for example 01083 * setWhiteBalance(FeatureOnePush) ). 01084 * 01085 * If you set the state of one or more features to one-push, then you may 01086 * want to wait for them to be ready with the method onePushWait(). Of 01087 * course, this will work if and only if the camera supports this feature 01088 * state. 01089 * 01090 * The methods to query information from the camera do indeed ask the 01091 * camera for the corresponding value (if and only if this is possible). 01092 * There are cameras which do not support the readout capability for the 01093 * registers holding the feature values. In that case, the get* methods 01094 * will return \c false. 01095 */ 01096 //@{ 01097 01098 /** 01099 * Set brightness control state and register in camera directly. 01100 * 01101 * @param state Camera desired state (@see eFeatureState) 01102 * @param brightness If state is manual, the value to be used. 01103 * 01104 * @return true if operation was successfull, false otherwise 01105 */ 01106 bool setBrightness(const eFeatureState state, 01107 const float brightness=0); 01108 01109 /** 01110 * Get brightness state and value directly out of camera. 01111 * 01112 * @param state Variable where the current brightness state is to be 01113 * written. 01114 * @param brightness Variable where the brightness value is to be written. 01115 * 01116 * @return true if operation was successfull, false otherwise 01117 */ 01118 bool getBrightness(eFeatureState& state, 01119 float& brightness) const; 01120 01121 /** 01122 * Set exposure control state and register in camera directly. 01123 * 01124 * @param state Camera desired state (@see eFeatureState) 01125 * @param exposure If state is manual, the value to be used. 01126 * 01127 * @return true if operation was successfull, false otherwise 01128 */ 01129 bool setExposure(const eFeatureState state, 01130 const float exposure=0); 01131 01132 /** 01133 * Get exposure state and value directly out of camera. 01134 * 01135 * @param state Variable where the current exposure state is to be 01136 * written. 01137 * @param exposure Variable where the exposure value is to be written. 01138 * 01139 * @return true if operation was successfull, false otherwise 01140 */ 01141 bool getExposure(eFeatureState& state, 01142 float& exposure) const; 01143 01144 /** 01145 * Set sharpness control state and register in camera directly. 01146 * 01147 * @param state Camera desired state (@see eFeatureState) 01148 * @param sharpness If state is manual, the value to be used. 01149 * 01150 * @return true if operation was successfull, false otherwise 01151 */ 01152 bool setSharpness(const eFeatureState state, 01153 const float sharpness=0); 01154 01155 /** 01156 * Get sharpness state and value directly out of camera. 01157 * 01158 * @param state Variable where the current sharpness state is to be 01159 * written. 01160 * @param sharpness Variable where the sharpness value is to be written. 01161 * 01162 * @return true if operation was successfull, false otherwise 01163 */ 01164 bool getSharpness(eFeatureState& state, 01165 float& sharpness) const; 01166 01167 /** 01168 * Set whiteBalance control state and register in camera directly. 01169 * 01170 * Depending on the color space used by the camera (RGB or YUV), the 01171 * color gains are applied to UV or to BR. 01172 * 01173 * @param state Camera desired state (@see eFeatureState) 01174 * @param ubGain gain for the blue channel (or U channel) 01175 * @param vrGain gain for the red channel (or V channel) 01176 * 01177 * @return true if operation was successfull, false otherwise 01178 */ 01179 bool setWhiteBalance(const eFeatureState state, 01180 const float ubGain=0, 01181 const float vrGain=0); 01182 01183 /** 01184 * Get whiteBalance state and value directly out of camera. 01185 * 01186 * @param state Variable where the current whiteBalance state is to be 01187 * written. 01188 * @param ubGain gain for the blue channel (or U channel) 01189 * @param vrGain gain for the red channel (or V channel) 01190 * 01191 * @return true if operation was successfull, false otherwise 01192 */ 01193 bool getWhiteBalance(eFeatureState& state, 01194 float& ubGain, 01195 float& vrGain); 01196 01197 /** 01198 * Set hue control state and register in camera directly. 01199 * 01200 * @param state Camera desired state (@see eFeatureState) 01201 * @param hue If state is manual, the value to be used. 01202 * 01203 * @return true if operation was successfull, false otherwise 01204 */ 01205 bool setHue(const eFeatureState state, 01206 const float hue=0); 01207 01208 /** 01209 * Get hue state and value directly out of camera. 01210 * 01211 * @param state Variable where the current hue state is to be 01212 * written. 01213 * @param hue Variable where the hue value is to be written. 01214 * 01215 * @return true if operation was successfull, false otherwise 01216 */ 01217 bool getHue(eFeatureState& state, 01218 float& hue) const; 01219 01220 /** 01221 * Set saturation control state and register in camera directly. 01222 * 01223 * @param state Camera desired state (@see eFeatureState) 01224 * @param saturation If state is manual, the value to be used. 01225 * 01226 * @return true if operation was successfull, false otherwise 01227 */ 01228 bool setSaturation(const eFeatureState state, 01229 const float saturation=0); 01230 01231 /** 01232 * Get saturation state and value directly out of camera. 01233 * 01234 * @param state Variable where the current saturation state is to be 01235 * written. 01236 * @param saturation Variable where the saturation value is to be written. 01237 * 01238 * @return true if operation was successfull, false otherwise 01239 */ 01240 bool getSaturation(eFeatureState& state, 01241 float& saturation) const; 01242 01243 /** 01244 * Set gamma control state and register in camera directly. 01245 * 01246 * @param state Camera desired state (@see eFeatureState) 01247 * @param gamma If state is manual, the value to be used. 01248 * 01249 * @return true if operation was successfull, false otherwise 01250 */ 01251 bool setGamma(const eFeatureState state, 01252 const float gamma=0); 01253 01254 /** 01255 * Get gamma state and value directly out of camera. 01256 * 01257 * @param state Variable where the current gamma state is to be 01258 * written. 01259 * @param gamma Variable where the gamma value is to be written. 01260 * 01261 * @return true if operation was successfull, false otherwise 01262 */ 01263 bool getGamma(eFeatureState& state, 01264 float& gamma) const; 01265 01266 /** 01267 * Set shutter control state and register in camera directly. 01268 * 01269 * @param state Camera desired state (@see eFeatureState) 01270 * @param shutter If state is manual, the value to be used. 01271 * 01272 * @return true if operation was successfull, false otherwise 01273 */ 01274 bool setShutter(const eFeatureState state, 01275 const float shutter=0); 01276 01277 /** 01278 * Get shutter state and value directly out of camera. 01279 * 01280 * @param state Variable where the current shutter state is to be 01281 * written. 01282 * @param shutter Variable where the shutter value is to be written. 01283 * 01284 * @return true if operation was successfull, false otherwise 01285 */ 01286 bool getShutter(eFeatureState& state, 01287 float& shutter) const; 01288 01289 /** 01290 * Set gain control state and register in camera directly. 01291 * 01292 * @param state Camera desired state (@see eFeatureState) 01293 * @param gain If state is manual, the value to be used. 01294 * 01295 * @return true if operation was successfull, false otherwise 01296 */ 01297 bool setGain(const eFeatureState state, 01298 const float gain=0); 01299 01300 /** 01301 * Get gain state and value directly out of camera. 01302 * 01303 * @param state Variable where the current gain state is to be 01304 * written. 01305 * @param gain Variable where the gain value is to be written. 01306 * 01307 * @return true if operation was successfull, false otherwise 01308 */ 01309 bool getGain(eFeatureState& state, 01310 float& gain) const; 01311 01312 /** 01313 * Set iris control state and register in camera directly. 01314 * 01315 * @param state Camera desired state (@see eFeatureState) 01316 * @param iris If state is manual, the value to be used. 01317 * 01318 * @return true if operation was successfull, false otherwise 01319 */ 01320 bool setIris(const eFeatureState state, 01321 const float iris=0); 01322 01323 /** 01324 * Get iris state and value directly out of camera. 01325 * 01326 * @param state Variable where the current iris state is to be 01327 * written. 01328 * @param iris Variable where the iris value is to be written. 01329 * 01330 * @return true if operation was successfull, false otherwise 01331 */ 01332 bool getIris(eFeatureState& state, 01333 float& iris) const; 01334 01335 /** 01336 * Set focus control state and register in camera directly. 01337 * 01338 * @param state Camera desired state (@see eFeatureState) 01339 * @param focus If state is manual, the value to be used. 01340 * 01341 * @return true if operation was successfull, false otherwise 01342 */ 01343 bool setFocus(const eFeatureState state, 01344 const float focus=0); 01345 01346 /** 01347 * Get focus state and value directly out of camera. 01348 * 01349 * @param state Variable where the current focus state is to be 01350 * written. 01351 * @param focus Variable where the focus value is to be written. 01352 * 01353 * @return true if operation was successfull, false otherwise 01354 */ 01355 bool getFocus(eFeatureState& state, 01356 float& focus) const; 01357 01358 /** 01359 * Set zoom control state and register in camera directly. 01360 * 01361 * @param state Camera desired state (@see eFeatureState) 01362 * @param zoom If state is manual, the value to be used. 01363 * 01364 * @return true if operation was successfull, false otherwise 01365 */ 01366 bool setZoom(const eFeatureState state, 01367 const float zoom=0); 01368 01369 /** 01370 * Get zoom state and value directly out of camera. 01371 * 01372 * @param state Variable where the current zoom state is to be 01373 * written. 01374 * @param zoom Variable where the zoom value is to be written. 01375 * 01376 * @return true if operation was successfull, false otherwise 01377 */ 01378 bool getZoom(eFeatureState& state, 01379 float& zoom) const; 01380 01381 /** 01382 * Set pan control state and register in camera directly. 01383 * 01384 * @param state Camera desired state (@see eFeatureState) 01385 * @param pan If state is manual, the value to be used. 01386 * 01387 * @return true if operation was successfull, false otherwise 01388 */ 01389 bool setPan(const eFeatureState state, 01390 const float pan=0); 01391 01392 /** 01393 * Get pan state and value directly out of camera. 01394 * 01395 * @param state Variable where the current pan state is to be 01396 * written. 01397 * @param pan Variable where the pan value is to be written. 01398 * 01399 * @return true if operation was successfull, false otherwise 01400 */ 01401 bool getPan(eFeatureState& state, 01402 float& pan) const; 01403 01404 /** 01405 * Set tilt control state and register in camera directly. 01406 * 01407 * @param state Camera desired state (@see eFeatureState) 01408 * @param tilt If state is manual, the value to be used. 01409 * 01410 * @return true if operation was successfull, false otherwise 01411 */ 01412 bool setTilt(const eFeatureState state, 01413 const float tilt=0); 01414 01415 /** 01416 * Get tilt state and value directly out of camera. 01417 * 01418 * @param state Variable where the current tilt state is to be 01419 * written. 01420 * @param tilt Variable where the tilt value is to be written. 01421 * 01422 * @return true if operation was successfull, false otherwise 01423 */ 01424 bool getTilt(eFeatureState& state, 01425 float& tilt) const; 01426 01427 //@} 01428 01429 /** 01430 * Get current video mode directly out of camera. 01431 * 01432 * The IIDC enum value read from the camera is decoded into a 01433 * resolution and a pixel encoding value. 01434 * 01435 * \param resolution ipoint with the image resolution. 01436 * \param encoding encoding type of each pixel (YUV422, RGB, etc.) 01437 * 01438 * @return true if operation was successfull, false otherwise 01439 */ 01440 bool getVideoMode(ipoint& resolution,eColorMode& encoding) const; 01441 01442 /** 01443 * Get current frame rate directly out of camera. 01444 * @return true if operation was successfull, false otherwise 01445 */ 01446 bool getFramerate(float& framerate) const; 01447 01448 /** 01449 * Initializes the IEEE Bus and checks for available cameras. 01450 * 01451 * This method will be called automatically, when necessary. Hence, 01452 * you do not need to worry about it. 01453 * 01454 * @return true if operation was successfull, false otherwise 01455 */ 01456 bool init(); 01457 01458 /** 01459 * Member function that prints informations about camera features on 01460 * stdout. 01461 * @return true if operation was successfull, false otherwise 01462 */ 01463 bool printFeatures() const; 01464 01465 /** 01466 * Read the actual hardware settings of the \b active camera and leave them 01467 * into the given parameter instance. 01468 * 01469 * @param par the parameters instance on which the gained information 01470 * will be stored. 01471 * 01472 * @return true if operation was successfull, false otherwise (for 01473 * instance, if there is no active camera to be read) 01474 */ 01475 bool dumpParameters(parameters &par); 01476 01477 /** 01478 * Copy data of "other" functor. 01479 * @param other the functor to be copied 01480 * @return a reference to this functor object 01481 */ 01482 fireWireDCAM& copy(const fireWireDCAM& other); 01483 01484 /** 01485 * Alias for copy member 01486 * @param other the functor to be copied 01487 * @return a reference to this functor object 01488 */ 01489 fireWireDCAM& operator=(const fireWireDCAM& other); 01490 01491 /** 01492 * Returns a pointer to a clone of this functor. 01493 */ 01494 virtual functor* clone() const; 01495 01496 /** 01497 * Returns used parameters 01498 */ 01499 const parameters& getParameters() const; 01500 01501 /** 01502 * \name Access to internal data structures 01503 * 01504 * The following methods can be found useful by GUI programmers who want 01505 * to ask for availability of several features in order to set-up properly 01506 * GUI elements. 01507 */ 01508 //@{ 01509 /** 01510 * Check if a camera has been activated for this functor. 01511 * 01512 * @return true if a camera has been successfully activated, or false 01513 * otherwise. 01514 */ 01515 bool isCameraActive() const; 01516 01517 /** 01518 * Check if the active camera supports format 7 01519 */ 01520 bool hasCameraFormat7() const; 01521 01522 /** 01523 * Check if a particular feature is available in the current active 01524 * camera. 01525 * 01526 * You have to ensure that a camera is already active (see 01527 * isCameraActive()). 01528 * 01529 * \param featureId The identification of the feature expects one of the 01530 * following values, defined in the libdc1394: 01531 * - FEATURE_BRIGHTNESS 01532 * - FEATURE_EXPOSURE 01533 * - FEATURE_SHARPNESS 01534 * - FEATURE_WHITE_BALANCE 01535 * - FEATURE_HUE 01536 * - FEATURE_SATURATION 01537 * - FEATURE_GAMMA 01538 * - FEATURE_SHUTTER 01539 * - FEATURE_GAIN 01540 * - FEATURE_IRIS 01541 * - FEATURE_FOCUS 01542 * - FEATURE_TEMPERATURE 01543 * - FEATURE_TRIGGER 01544 * - FEATURE_TRIGGER_DELAY 01545 * - FEATURE_WHITE_SHADING 01546 * - FEATURE_FRAME_RATE 01547 * - FEATURE_ZOOM 01548 * - FEATURE_PAN 01549 * - FEATURE_TILT 01550 * - FEATURE_OPTICAL_FILTER 01551 * - FEATURE_CAPTURE_SIZE 01552 * - FEATURE_CAPTURE_QUALITY 01553 */ 01554 bool isFeatureAvailable(const unsigned int featureId) const; 01555 01556 /** 01557 * Check if a feature is available and is read-out capable. 01558 * 01559 * \param featureId identification for the feature to be queried. 01560 * (see fireWireDCAM::isFeatureAvailable() for a list of 01561 * valid values) 01562 * \return \c true if feature is read-out capable or \c false if it is not 01563 * available at all, or if it is not readable. 01564 */ 01565 bool isFeatureReadable(const unsigned int featureId) const; 01566 01567 /** 01568 * Check for availability of feature states 01569 * 01570 * Following the IIDC 1.3x standard, a given feature (see the list of 01571 * valid identifiers in lti::fireWireDCAM::isFeatureAvailable() ) can 01572 * have one of four states: 01573 * - Off state: the feature is deactivated (some features cannot be 01574 * deactivated). 01575 * - Auto state: the feature is automatically adjusted 01576 * - Manual state: the user controls the values a feature can get 01577 * - One-Push state: the feature is automatically adjusted but only once. 01578 * 01579 * This method asks the active camera which states are supported and 01580 * returns a bitwise combination of fireWireDCAM::eFeatureState constants. 01581 * 01582 * You have to ensure that a camera is active (see 01583 * fireWireDCAM::isCameraActive()). 01584 * 01585 * \param featureId identification for the feature to be modified 01586 * (see fireWireDCAM::isFeatureAvailable() for a list of 01587 * valid values) 01588 * 01589 */ 01590 unsigned int checkFeatureStates(const unsigned int featureId) const; 01591 01592 /** 01593 * Get feature state of the camera 01594 * 01595 * @return \c true if feature state could be successfully read, or \c false 01596 * if this was not possible (maybe the camera does not support 01597 * the given feature at all). 01598 */ 01599 bool getFeatureState(const unsigned int featureId, 01600 eFeatureState& state) const; 01601 01602 /** 01603 * Set feature state of the camera 01604 * 01605 * @return \c true if feature state could be successfully set, or \c false 01606 * if this was not possible (maybe the camera does not support 01607 * the given state for the feature. 01608 */ 01609 bool setFeatureState(const unsigned int featureId, 01610 const eFeatureState state); 01611 01612 /** 01613 * Set control state and value of a particular feature. 01614 * 01615 * This method does not support those features that require two values, 01616 * like white balance. 01617 * 01618 * This private method does not modify the internal parameters. 01619 * 01620 * @param featureId identification for the feature to be modified 01621 * (see fireWireDCAM::isFeatureAvailable() for a list of 01622 * valid values) 01623 * @param state Camera desired state (@see eFeatureState) 01624 * @param value If state is manual, the value to be used. 01625 * 01626 * @return true if operation was successfull, false otherwise 01627 */ 01628 inline bool setFeatureValue(const unsigned int featureId, 01629 const eFeatureState state, 01630 const float value=0); 01631 01632 /** 01633 * Get control state and value of a particular feature. 01634 * 01635 * This method does not support those features that require two values, 01636 * like white balance. 01637 * 01638 * @param featureId identification for the feature to be queried. 01639 * @param state State in which the feature is being used 01640 * @param value if state is manual, the value to be used. 01641 * 01642 * @return \c true if operation was successfull, \c false otherwise (for 01643 * example, if the feature is not supported by the camera). 01644 */ 01645 inline bool getFeatureValue(const unsigned int featureId, 01646 eFeatureState& state, 01647 float& value) const; 01648 01649 /** 01650 * Check the valid value range for a specified feature. 01651 * 01652 * You have to ensure that there is an active camera before calling this 01653 * method. (see fireWireDCAM::isCameraActive() ) 01654 * 01655 * @param featureId identification for the feature to be modified 01656 * (see fireWireDCAM::isFeatureAvailable() for a list of 01657 * valid values) 01658 * @param minValue minimum value accepted for the specified feature. 01659 * @param maxValue maximum value accepted for the specified feature. 01660 * 01661 * @return \c true if successful or \c false otherwise. 01662 */ 01663 bool checkFeatureValueRange(const unsigned int featureId, 01664 int& minValue, 01665 int& maxValue) const; 01666 //@} 01667 01668 protected: 01669 /** 01670 * Returns modifieable parameters 01671 */ 01672 parameters& getRWParameters(); 01673 01674 /** 01675 * For a bitwise combination of available states and a desired state, 01676 * return a valid supported state. 01677 */ 01678 eFeatureState fixState(const unsigned int states, 01679 const eFeatureState desired) const; 01680 01681 void fixFeature(const unsigned int featureId, 01682 float& value, 01683 eFeatureState& state) const; 01684 /** 01685 * Analyse the given parameters instance and change its attributes to 01686 * contain values supported by the active camera. 01687 * 01688 * This method will work only if the camera of the given parameters is 01689 * connected and found. Otherwise there will be no way to determine 01690 * which values are appropriate for the camera. 01691 */ 01692 bool fixParameters(parameters& par) const; 01693 01694 /** 01695 * Get the closest framerate of the libdc1394 set of enums to the 01696 * given framerate value coded in a float of fps. 01697 * 01698 * This method does not consider the camera supported framerates, but 01699 * the simple convertion. 01700 */ 01701 unsigned int convertFramerate(const float fps) const; 01702 01703 /** 01704 * Get the float value in fps equivalent to the framerate enum value 01705 * of the libdc1394 01706 */ 01707 float convertFramerate(const unsigned int eFR) const; 01708 01709 /** 01710 * Get "nearest" IIDC mode value from the given resolution and encoding. 01711 * 01712 * As "nearest" it will be taken the resolution with the 01713 * most similar number of pixels and within that resolution, the "nearest" 01714 * encoding will be chosen (RGBs are in a group, Mono in another and YUV 01715 * in another. 01716 * 01717 */ 01718 unsigned int convertMode(const ipoint& resolution, 01719 const eColorMode& encoding) const; 01720 01721 /** 01722 * From the given value for format/mode after IIDC encoding, get 01723 * the equivalent resolution and pixel encoding. 01724 */ 01725 void convertMode(const unsigned int value, 01726 ipoint& resolution, 01727 eColorMode& encoding) const; 01728 01729 /** 01730 * For a mode of the formats 0, 1 or 2, indicate if it is a color 01731 * mode. 01732 * 01733 * @return \c true if the mode is a color mode (RGB or YUV), or \c false 01734 * if the mode is monochrome. 01735 */ 01736 bool isModeColor(const unsigned int mode) const; 01737 01738 /** 01739 * Compute the closest supported mode to a given IIDC valid mode. 01740 * 01741 * the approximation is done with the following priorities: 01742 * 01743 * -# keep the mono or color attribute (unless your camera is 01744 * monochrome, of course) 01745 * -# select the closest resolution. 01746 */ 01747 unsigned int computeClosestMode(const unsigned int mode) const; 01748 01749 /** 01750 * Compute the closest supported framerate for a given mode 01751 */ 01752 float computeClosestFrameRate(const unsigned int mode, 01753 const float fr) const; 01754 01755 /** 01756 * From the given value for format7/mode after IIDC encoding, get 01757 * the equivalent resolution and pixel encoding. 01758 * 01759 * This method ask only for format 7 resolutions and encodings. For this 01760 * task it has to ask the camera for that information. 01761 * 01762 * The resolution returned will be the largest the camera supports. 01763 */ 01764 void convertMode7(const unsigned int value, 01765 ipoint& resolution, 01766 eColorMode& encoding) const; 01767 01768 /** 01769 * Get a functor valid code for a color space given in the libdc1394 01770 * enumeration for a Format7 color code. 01771 */ 01772 eColorMode getColorCode7(const unsigned int code) const; 01773 01774 /** 01775 * Get the corresponding format for the given resolution 01776 */ 01777 unsigned int getFormat(const ipoint& resolution) const; 01778 01779 01780 /** 01781 * converts YUV411 to RGB 01782 */ 01783 void yuv411toRGB(image& srcdest) const; 01784 01785 /** 01786 * converts YUV422 to RGB 01787 */ 01788 void yuv422toRGB(image& srcdest) const; 01789 01790 /** 01791 * Check if a specific feature is set to "auto" 01792 * 01793 * See lti::fireWireDCAM::isFeatureAvailable() for a list of the valid 01794 * \c featureId and their meanings. 01795 * 01796 * \param featureId identification for the feature to be modified 01797 * (see fireWireDCAM::isFeatureAvailable() for a list of 01798 * valid values) 01799 * 01800 * @return \c true if the feature is set to "auto" or false otherwise. 01801 */ 01802 bool isFeatureAuto(const unsigned int featureId) const; 01803 01804 /** 01805 * Set a feature to "auto" 01806 * 01807 * @param featureId identification for the feature to be modified 01808 * (see fireWireDCAM::isFeatureAvailable() for a list of 01809 * valid values) 01810 * @param on (default true) if \c true, the auto state is activated. 01811 * If \c false, the auto state is turned off. 01812 */ 01813 bool setFeatureAuto(const unsigned int featureId, 01814 const bool on=true) const; 01815 01816 /** 01817 * Turn a feature on or off. 01818 * 01819 * @param featureId identification for the feature to be modified 01820 * (see fireWireDCAM::isFeatureAvailable() for a list of 01821 * valid values) 01822 * @param on if \c true the feature is turned on, if \c false then it is 01823 * turned off 01824 * 01825 * @return \c true if feature state could be modified, of false otherwise. 01826 */ 01827 bool setFeatureOn(const unsigned int featureId, 01828 const bool on=true); 01829 01830 /** 01831 * Turn a feature absolute state on or off 01832 * 01833 * @param featureId identification for the feature to be modified 01834 * (see fireWireDCAM::isFeatureAvailable() for a list of 01835 * valid values) 01836 * @param on if \c true the absolute mode is turned on, if \c false then 01837 * it is turned off 01838 * 01839 * @return \c true if feature state could be modified, of false otherwise. 01840 */ 01841 bool setFeatureAbsoluteState(const unsigned int featureId, 01842 const bool on=true); 01843 01844 /** 01845 * Just capture a frame through libdc1394 01846 */ 01847 bool captureFrame(); 01848 01849 /** 01850 * @name Initialization methods and attributes for the library libdc1394 01851 * 01852 * The following methods are used in the initialization of the IEEE1394 bus 01853 * and cameras. They are inspired on the code of "coriander" 01854 * (http://damien.douxchamps.net/ieee1394/coriander/index.php) 01855 */ 01856 //@{ 01857 01858 /** 01859 * IEEE 1394 Bus Information Class 01860 */ 01861 class busInfo { 01862 public: 01863 /** 01864 * Default constructor 01865 * 01866 * Initializes everything with NULL o zero 01867 */ 01868 busInfo(); 01869 01870 /** 01871 * Destructor 01872 * 01873 * Takes care of deallocation 01874 */ 01875 ~busInfo(); 01876 01877 /** 01878 * Array of bus handles (type declared in file libraw1394/raw1394.h). 01879 * 01880 * The number of elements in the array is given by portNum. 01881 */ 01882 raw1394handle_t *handles; 01883 01884 /** 01885 * Nodes 01886 * 01887 * Array of pointers to nodeid_t structures. This array will 01888 * have portNum number of elements. 01889 */ 01890 nodeid_t **cameraNodes; 01891 01892 /** 01893 * Total camera number (should be the sum of all elements in the 01894 * portCameraNum array. 01895 */ 01896 int cameraNum; 01897 01898 /** 01899 * Array with the number of cameras for each port. 01900 * 01901 * The number of elements of this array is given by portNum. 01902 */ 01903 int *portCameraNum; 01904 01905 /** 01906 * Port number 01907 * 01908 * Number of ports available. The portCameraNum and cameraNodes 01909 * attributes are arrays with this number of elements. 01910 */ 01911 int portNum; 01912 01913 /** 01914 * Flag to indicate if a camera was found. 01915 */ 01916 bool cardFound; 01917 01918 /** 01919 * Fill the structure with information about the bus, nodes and cameras 01920 */ 01921 bool get(); 01922 01923 /** 01924 * Get camera nodes. 01925 * 01926 * Returns false if no card could be found (which also sets the 01927 * attribute cardFound to false 01928 */ 01929 bool getNodes(); 01930 01931 protected: 01932 /** 01933 * Delete the camera nodes. 01934 * 01935 * \returns false if nothing was deleted or true otherwise. 01936 */ 01937 bool deleteCameraNodes(); 01938 01939 /** 01940 * Bus reset handler 01941 * 01942 * TODO: we have to decide what is to be done when the cameras are 01943 * life plugged/unplugged! 01944 */ 01945 static int busResetHandler(raw1394handle_t handle, 01946 unsigned int generation); 01947 }; 01948 01949 /** 01950 * Structure to hold format 7 mode information 01951 * 01952 * This structure will be replicated in an array, of which each 01953 * component will hold information about one particular format7 mode 01954 * (there are at this time only 8 available). 01955 */ 01956 struct format7ModeInfo { 01957 /** 01958 * Corresponding format7 mode is available 01959 */ 01960 bool present; 01961 01962 /** 01963 * Current image size in use. 01964 */ 01965 uipoint size; 01966 01967 /** 01968 * Maximum image size. 01969 */ 01970 uipoint maxSize; 01971 01972 /** 01973 * Position of subimage in the total CCD image size. 01974 */ 01975 uipoint pos; 01976 01977 /** 01978 * Unit size 01979 */ 01980 uipoint unitSize; 01981 01982 /** 01983 * Unit position 01984 */ 01985 uipoint unitPos; 01986 01987 /** 01988 * ID number of the color coding 01989 */ 01990 unsigned int colorCodingId; 01991 01992 /** 01993 * Bitwise combination of color coding modes supported. 01994 */ 01995 quadlet_t colorCoding; 01996 01997 /** 01998 * Number of pixels 01999 */ 02000 unsigned int pixnum; 02001 02002 /** 02003 * Number of bytes per packet 02004 */ 02005 unsigned int bpp; // bpp is byte_per_packet 02006 02007 /** 02008 * Minimum number of bytes per packet 02009 */ 02010 unsigned int minBpp; 02011 02012 /** 02013 * Maximum number of bytes per packet. 02014 */ 02015 unsigned int maxBpp; 02016 02017 /** 02018 * Total number of bytes 02019 */ 02020 uint64 totalBytes; 02021 }; 02022 02023 /** 02024 * Structure to hold format 7 information 02025 */ 02026 struct format7Info { 02027 /** 02028 * Flag to indicate if the format7 is available at all. 02029 */ 02030 bool available; 02031 02032 /** 02033 * Array of structures representing each of the format7 modes. 02034 */ 02035 format7ModeInfo mode[NUM_MODE_FORMAT7]; 02036 }; 02037 02038 /** 02039 * The camera information class 02040 * 02041 * For each camera detected in the bus a set of information is extracted 02042 * which is encapsulated in objects of this type. 02043 */ 02044 class cameraInfo { 02045 public: 02046 /** 02047 * Default constructor 02048 */ 02049 cameraInfo(); 02050 02051 /** 02052 * Destructor 02053 */ 02054 ~cameraInfo(); 02055 02056 /** 02057 * Information about the camera 02058 */ 02059 dc1394_camerainfo info; 02060 02061 /** 02062 * Set of features of the current camera 02063 */ 02064 dc1394_feature_set featureSet; 02065 02066 /** 02067 * Other information 02068 */ 02069 dc1394_miscinfo miscInfo; 02070 02071 /** 02072 * Information about format 7 02073 */ 02074 format7Info format7; 02075 02076 /** 02077 * Basic functionality of the camera 02078 * 02079 * This includes most importantly three features: 02080 * - Bit 16: camera process power ON/OFF capability 02081 * - Bit 19: one shot transmission capability 02082 * - Bit 20: multishot transmission capability 02083 */ 02084 quadlet_t basics; 02085 02086 /** 02087 * Flag to indicate if this camera is already being used by an instance 02088 */ 02089 bool inUse; 02090 02091 /** 02092 * Error string 02093 */ 02094 std::string errorStr; 02095 02096 /** 02097 * Store the modes supported. 02098 * 02099 * This information is generated when get() is called. 02100 */ 02101 std::set<uint32> supportedModes; 02102 02103 /** 02104 * Store the framerates supported for each supported mode. 02105 * 02106 * The map key is a given mode, using the IIDC value for them, and the 02107 * value for that key is a set containing the framerates supported. 02108 * 02109 * This information is generated when get() is called. 02110 */ 02111 std::map<uint32,std::set<float> > supportedFramerates; 02112 02113 /** 02114 * Get camera information from the given port and node. 02115 * 02116 * \return true if successful or false if an error occurred, 02117 * in which case the errorStr will contain an appropriate 02118 * message. 02119 */ 02120 bool get(const int port,const nodeid_t& node); 02121 02122 protected: 02123 /** 02124 * Get information about the format 7 capabilities 02125 */ 02126 bool getFormat7Capabilities(); 02127 02128 /** 02129 * Get information on a specific format7 mode 02130 * 02131 * @param format Format code, which should lie between MODE_FORMAT7_MIN 02132 * and MODE_FORMAT7_MAX (usually from MODE_FORMAT7_0 to 02133 * MODE_FORMAT7_7). 02134 */ 02135 bool getFormat7ModeInfo(const unsigned int format); 02136 02137 /** 02138 * Get information on the supported modes. 02139 * 02140 * \return true if successful or false otherwise 02141 */ 02142 bool getSupportedModesAndFramerates(const nodeid_t& node); 02143 }; 02144 02145 /** 02146 * Set of cameras 02147 * 02148 * This class represents the set of all available cameras 02149 */ 02150 class cameraSet { 02151 public: 02152 /** 02153 * Default constructor 02154 */ 02155 cameraSet(); 02156 02157 /** 02158 * Default destructor 02159 */ 02160 ~cameraSet(); 02161 02162 /** 02163 * Get the information block of the camera identified with the given 02164 * index. 02165 */ 02166 const cameraInfo& operator[](const int idx) const; 02167 02168 /** 02169 * Get the information block of the camera identified with the given 02170 * index. 02171 */ 02172 cameraInfo& operator[](const int idx); 02173 02174 /** 02175 * Return the total number of cameras found 02176 */ 02177 unsigned int size() const; 02178 02179 /** 02180 * Evaluate the given bus and create all the necessary objects to 02181 * obtain and retain the information of all available cameras. 02182 */ 02183 bool get(busInfo& bus); 02184 02185 /** 02186 * Try to find a camera within the set with the given identification. 02187 * 02188 * @param euID64 is the identification number used by the libdc1394 02189 * @param camIdx if the id is found, this will contain the index to 02190 * access the camera with the given id, otherwise it 02191 * will be set to -1. 02192 * 02193 * \returns \c true if the camera is found, or false if not. 02194 */ 02195 bool findCamera(const u_int64_t& euID64, 02196 int& camIdx) const; 02197 02198 /** 02199 * This method finds the first available camera. 02200 */ 02201 bool findFreeCamera(int& camIdx) const; 02202 02203 /** 02204 * Mark the camera with the given index as being in use. 02205 * 02206 * Only one instance of this functor can use a particular camera at 02207 * a time. 02208 */ 02209 bool reserveIndex(const int idx); 02210 02211 /** 02212 * Mark the camera with the given index as free to be used by other 02213 * instances. 02214 * 02215 */ 02216 bool releaseIndex(const int idx); 02217 02218 /** 02219 * Error string 02220 */ 02221 std::string errorStr; 02222 02223 protected: 02224 /** 02225 * Camera array 02226 */ 02227 std::vector<cameraInfo> cams_; 02228 02229 /** 02230 * Protect the camera array 02231 */ 02232 mutable mutex lock_; 02233 02234 }; 02235 //@} 02236 02237 /** 02238 * Camera database 02239 * 02240 * Just one instance of this class is used to manage the names of 02241 * the available cameras. 02242 */ 02243 class nameDB { 02244 public: 02245 /** 02246 * Default constructor 02247 * 02248 * Does nothing 02249 */ 02250 nameDB(); 02251 02252 /** 02253 * Default destructor 02254 * 02255 * Saves all new data acquired in the file indicated by the use() method. 02256 */ 02257 ~nameDB(); 02258 02259 /** 02260 * Use the given file to serialize the data 02261 * 02262 * \returns \c true if the file can be successfully open and read, or 02263 * if it does not exist, if it can be successfully created. 02264 */ 02265 bool use(const std::string& filename); 02266 02267 /** 02268 * Query a camera id through a camera name. 02269 * 02270 * \returns \c true if the name could be found, in which case id will 02271 * contain the proper data. \c false if the name could not 02272 * be found. 02273 */ 02274 bool query(const std::string& name,u_int64_t& id) const; 02275 02276 /** 02277 * Add a name,id pair. 02278 * 02279 * \returns \c true if the pair could be successfully added or \c false 02280 * if there was a problem (usually, the name already existed! 02281 */ 02282 bool add(const std::string& name,u_int64_t& id); 02283 02284 /** 02285 * Delete an entry with the given name as key 02286 * 02287 * \returns \c true if the entry was removed or \c false if some problem 02288 * occured, for instance, the entry didn't exist. 02289 */ 02290 bool del(const std::string& name); 02291 02292 protected: 02293 /** 02294 * Map names to the identification numbers of cameras 02295 */ 02296 std::map<std::string,u_int64_t> data_; 02297 02298 /** 02299 * Filename in use (given by use() method) 02300 */ 02301 std::string filename_; 02302 02303 /** 02304 * Protect data 02305 */ 02306 mutable mutex lock_; 02307 02308 /** 02309 * Dump the data_ into the file with the name filename_. 02310 * 02311 * This does not lock! Do it outside the method. 02312 * 02313 * \returns \c true if the file could be dumped or \c false if an error 02314 * occurred (like no use() called before) 02315 */ 02316 bool dump(); 02317 02318 /** 02319 * Read the data_ from the file with the name \c filename. 02320 * 02321 * This does not lock! Do it outside the method. 02322 * 02323 * \returns \c true if the file could be read or \c false if an error 02324 * occurred (like no use() called before) 02325 */ 02326 bool read(const std::string& filename); 02327 02328 /** 02329 * Convert a 64 integer into a hex chain 02330 * 02331 * Since not all compilers behave the same with 64 bit chains, we 02332 * better take charge ourselves of converting them into a chain of 16 02333 * nibbles preceded by 0x. 02334 */ 02335 void hexToString(const u_int64_t& data, 02336 std::string& str) const; 02337 02338 /** 02339 * Convert a 16 nibble string into a u_int64_t value 02340 * 02341 * The string has to begin with "0x" and continue with a number 02342 * of less or exactly 16 hex digits 02343 */ 02344 bool stringToHex(const std::string& str, 02345 u_int64_t& data) const; 02346 02347 /** 02348 * The file has to be read just once! 02349 * 02350 * This flag stores if it was read or not 02351 */ 02352 bool init_; 02353 02354 /** 02355 * Flag to indicate if the database has been modified since the last 02356 * read. 02357 */ 02358 bool modified_; 02359 02360 }; 02361 02362 02363 /** 02364 * @name Hardware singletons 02365 * 02366 * The following attributes represent the IEEE 1394 bus and all 02367 * available cameras. 02368 */ 02369 //@{ 02370 /** 02371 * Flag set to true if the bus and camera set were already initialized or 02372 * false otherwise. 02373 */ 02374 static bool hwCreated_; 02375 02376 /** 02377 * The one and only instance for the IEEE1394 bus. 02378 */ 02379 static busInfo bus_; 02380 02381 /** 02382 * The camera set attached to the IEEE1394 bus found. 02383 */ 02384 static cameraSet cams_; 02385 02386 /** 02387 * The camera names database 02388 */ 02389 static nameDB cameraNames_; 02390 02391 /** 02392 * Initialize the hardware 02393 */ 02394 bool initHardware(); 02395 02396 /** 02397 * Initialize the current camera 02398 */ 02399 bool initCamera(const parameters& par); 02400 //@} 02401 02402 /** 02403 * Store the index for cams_ of the camera represented by this instance 02404 * 02405 * If activeCamera_ is less than zero then it indicates that this functor 02406 * has not initialized its camera yet. 02407 */ 02408 int activeCamera_; 02409 02410 /** 02411 * Active camera name 02412 * 02413 * The index in activeCamera_ corresponds to the a camera with 02414 * the name activeCameraName_, which is used to decide if setParameters 02415 * is telling this functor to change the camera being used. 02416 */ 02417 std::string activeCameraName_; 02418 02419 /** 02420 * Release the active camera. 02421 * 02422 * This allow that another instance can take control of this camera. 02423 */ 02424 bool releaseCamera(); 02425 02426 /** 02427 * @name Shadow and pointers for active camera attributes 02428 * 02429 * This shadows are set in updateParameters() 02430 */ 02431 //@{ 02432 02433 /** 02434 * Shadow value of current in use camera to indicate that it is capable of 02435 * oneShot capture. 02436 * 02437 * This is a shadow of cams_[activeCamera_].miscInfo.one_shot_capable; 02438 */ 02439 bool oneShotCapable_; 02440 02441 /** 02442 * FireWire handle for low level communication 02443 * 02444 * This is a pointer to cams_[activeCamera_].info.handle 02445 */ 02446 const raw1394handle_t* handle_; 02447 02448 /** 02449 * Saves what features are available. 02450 * 02451 * This is a pointer to cams_[activeCamera_].featureSet 02452 */ 02453 const dc1394_feature_set* features_; 02454 02455 /** 02456 * Shadow of the node id. 02457 * 02458 * This is a pointer to cams_[activeCamera_].info.id 02459 */ 02460 const nodeid_t* node_; 02461 02462 /** 02463 * FireWire channel used for the camera 02464 */ 02465 unsigned int busChannel_; 02466 02467 /** 02468 * FireWire bus speed used 02469 */ 02470 unsigned int busSpeed_; 02471 02472 /** 02473 * Flag to indicate if the ISO transmision has been started 02474 */ 02475 bool isoTransStarted_; 02476 02477 //@} 02478 02479 /** 02480 * Colormode used for conversion to rgb image 02481 */ 02482 eColorMode colorMode_; 02483 02484 /** 02485 * Just a buffer channel8 02486 */ 02487 channel8 ch8_; 02488 02489 /** 02490 * Capture handle with the camera node, buffer etc. 02491 */ 02492 dc1394_cameracapture camera_; 02493 02494 /** 02495 * If a setup capture succeeded 02496 */ 02497 bool setupCapture_; 02498 02499 /** 02500 * merger for YUV to RGB conversion 02501 */ 02502 mergeYCbCrToImage merger_; 02503 02504 /** 02505 * demosaicing functor for Mono to RGB conversion 02506 */ 02507 bayerDemosaicing bayer_; 02508 02509 /** 02510 * @name One-Push Wait Scheduler 02511 * 02512 * The following methods provide a very basic scheduler for 02513 * check of the successful automatic adjustment of features in the 02514 * one push mode 02515 */ 02516 //@{ 02517 02518 /** 02519 * Feature list in waiting process 02520 */ 02521 std::set<unsigned int> waitingFeatures_; 02522 02523 /** 02524 * Protect the queue from multiple access. 02525 */ 02526 mutex onePushLock_; 02527 02528 /** 02529 * Insert the given feature into the waiting queue. 02530 * @param featureId identification of the feature that want to wait for 02531 * leaving the one-push state. 02532 * @return \c true if feature could be inserted or \c false if it was 02533 * something wrong (not supported, or a real error). 02534 */ 02535 bool onePushQueueInsert(const unsigned int featureId); 02536 02537 public: 02538 /** 02539 * Wait until all features in the waiting queue have left the queue. 02540 * 02541 * @return \c true if all features left the one-push state on a time 02542 * less than the time-out, or false otherwise. 02543 */ 02544 bool onePushWait(); 02545 02546 //@} 02547 }; 02548 02549 /** 02550 * Read function for fireWireDCAM::eFeatureState type 02551 * 02552 * @ingroup gStorable 02553 */ 02554 bool read(ioHandler& handler, fireWireDCAM::eFeatureState& data); 02555 02556 /** 02557 * Write function for fireWireDCAM::eFeatureState type 02558 * 02559 * @ingroup gStorable 02560 */ 02561 bool write(ioHandler& handler, const fireWireDCAM::eFeatureState& data); 02562 02563 } 02564 02565 #endif 02566 02567 #endif