LTI-Lib latest version v1.9 - last update 10 Apr 2010

ltiITIFrameGrabber.h

00001 /*
00002  * Copyright (C) 1999, 2000, 2001, 2002, 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 Digital Image/Signal Processing Library
00026  * file .......: ltiFrameGrabber.h
00027  * authors ....: Peter Mathes
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 13.08.99
00030  * revisions ..: $Id: ltiITIFrameGrabber.h,v 1.6 2006/02/08 12:04:27 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_ITI_FRAMEGRABBER_H_
00034 #define _LTI_ITI_FRAMEGRABBER_H_
00035 
00036 #ifdef _USE_ITI_FRAME_GRABBER
00037 
00038 #ifdef _LTI_MSC_6
00039 
00040 #include "ltiFrameGrabber.h"
00041 
00042 // ------- ITI includes -------
00043 
00044 #include <itxcore.h>
00045 #include <icp.h>
00046 #include <ams.h>
00047 #include <amc1.h>
00048 
00049 // ----------------------------
00050 
00051 namespace lti {
00052 
00053   /**
00054    * iti frame grabber class (Windows ONLY!).
00055    *
00056    * class for grabbing frames from cameras and converting them to lti::image
00057    * format.
00058    *
00059    * Don't forget to uncomment the line "#define _USE_ITI_FRAME_GRABBER" in
00060    * the file
00061    * ltiHardwareConfig.h before compiling!
00062    *
00063    * You must also include the file "itxco10.lib" in your settings (unter
00064    * <code>Project->Settings->Link->General->Library modules</code>)
00065    */
00066   class itiFrameGrabber : public frameGrabber {
00067   public:
00068     /**
00069      * frameGrabber parameters class
00070      */
00071     class parameters : public frameGrabber::parameters {
00072     public:
00073       /**
00074        * default constructor
00075        */
00076       parameters();
00077 
00078       /**
00079        * copy constructor
00080        */
00081       parameters( const parameters& other ) 
00082         : frameGrabber::parameters() {
00083         copy( other );
00084       };
00085 
00086       /**
00087        * copy member
00088        */
00089       parameters& copy( const parameters& other );
00090 
00091       /**
00092        * returns a pointer to a clone of the parameters.
00093        */
00094       virtual functor::parameters* clone() const;
00095 
00096       /**
00097        * returns the type name
00098        */
00099       virtual const char* getTypeName() const;
00100 
00101       // ------------- The Parameters ---------------
00102 
00103       /**
00104        * path and filename of the grabber configuration file
00105        */
00106       std::string configFile;
00107 
00108       /**
00109        * image data transfer mode
00110        */
00111       enum eCameraMode {
00112         FullImageRectangular = 0, /*!< full image rectangular */
00113         FullImageSquare,          /*!< full image square */
00114         QuarterImageFiltered,     /*!< quarter image filtered */
00115         QuarterImageSampled       /*!< quarter image sampled */
00116       };
00117 
00118       /**
00119        * specify the appearance of the transfered image
00120        */
00121       eCameraMode mode;
00122 
00123       /**
00124        * voltage reference, negative, red, green and blue values
00125        */
00126       trgbPixel<double> referenceNegative;
00127 
00128       /**
00129        * voltage reference, positive, red, green and blue values
00130        */
00131       trgbPixel<double> referencePositive;
00132 
00133       /**
00134        * if true, a low pass filter (hardware) will be used
00135        */
00136       bool lowPassFilterOn;
00137     };
00138 
00139     /**
00140      * default constructor
00141      */
00142     itiFrameGrabber(const bool& initialize=true);
00143 
00144     /**
00145      * copy constructor
00146      */
00147     itiFrameGrabber(const itiFrameGrabber& other);
00148 
00149     /**
00150      * constructor, sets the parameters
00151      */
00152     itiFrameGrabber(const parameters& theParam);
00153 
00154     /**
00155      * destructor
00156      */
00157     virtual ~itiFrameGrabber( void );
00158 
00159     /**
00160      * returns current parameters.
00161      */
00162     const parameters& getParameters() const;
00163 
00164     /**
00165      * returns the name of this type
00166      */
00167     virtual const char* getTypeName() const;
00168 
00169     /**
00170      * load an (color) image from the grabber
00171      */
00172     virtual image& apply(image& theImage);
00173 
00174     /**
00175      * load a grey value channel from the
00176      */
00177     virtual channel8& apply(channel8& theChannel);
00178 
00179     /**
00180      * copy member
00181      */
00182     itiFrameGrabber& copy(const itiFrameGrabber& other);
00183 
00184     /**
00185      * clone member
00186      */
00187     functor* clone() const;
00188 
00189     /**
00190      * check if the frame grabber is active
00191      */
00192     bool isActive() const;
00193 
00194     /**
00195      * initialize frame grabber
00196      */
00197     void init();
00198 
00199     // error codes
00200     static const short NoError;
00201     static const short Error;
00202     static const short NoGrabber;
00203 
00204 
00205   protected:
00206     /**
00207      * true if the frame grabber has been successfully initialized
00208      */
00209     bool active;
00210 
00211     /** capture quarter image
00212         @return true if everything is ok, false if error
00213      */
00214     bool captureQuarter(image& theImage);
00215 
00216     /** capture the full image, and extract a square from it
00217         @return true if everything is ok, false if error
00218      */
00219     bool captureFullSquare(image& theImage);
00220 
00221     /** capture the full rectangular image
00222         @return true if everything is ok, false if error
00223      */
00224     bool captureFull(image& theImage);
00225 
00226     /** cut to square and decimate the buffer
00227         @return true if everything is ok, false if error
00228      */
00229     bool cutToSquareAndDecimate(image& theImage);
00230 
00231     /** take a picture!
00232         @return true if everything is ok, false if error
00233     */
00234     bool snap();
00235 
00236   private:
00237     /**
00238      * Abstract class for the hardware modules
00239      */
00240     class itiModule {
00241     public:
00242       virtual ~itiModule( void );
00243 
00244       virtual short setRGB( void ) = 0;
00245       virtual short setBGR( void ) = 0;
00246       virtual short setHSI( void );
00247 
00248       virtual short lowpassOn( void ) = 0;
00249       virtual short lowpassOff( void ) = 0;
00250 
00251       /** set reference value for the ADC (in Volt)
00252           0.0<=neg<=1.476 0.7<=pos<=1.97 pos>=neg
00253           @param neg negative reference voltage (in volt)
00254           @param pos positive reference voltage (in volt)
00255           @return returns a Error if something was wrong, NoError otherwise.
00256         */
00257       virtual short setRedRef( double neg, double pos ) = 0;
00258 
00259       /** set reference value for the ADC (in Volt)
00260           0.0<=neg<=1.476 0.7<=pos<=1.97 pos>=neg
00261           @param neg negative reference voltage (in volt)
00262           @param pos positive reference voltage (in volt)
00263           @return returns a Error if something was wrong, NoError otherwise.
00264         */
00265       virtual short setGreenRef( double neg, double pos ) = 0;
00266 
00267       /** set reference value for the ADC (in Volt)
00268           0.0<=neg<=1.476 0.7<=pos<=1.97 pos>=neg
00269           @param neg negative reference voltage (in volt)
00270           @param pos positive reference voltage (in volt)
00271           @return returns a Error if something was wrong, NoError otherwise.
00272         */
00273       virtual short setBlueRef( double neg, double pos ) = 0;
00274 
00275       virtual short getRedRef( double &neg, double &pos ) = 0;
00276       virtual short getGreenRef( double &neg, double &pos ) = 0;
00277       virtual short getBlueRef( double &neg, double &pos ) = 0;
00278 
00279       virtual short selectPort(int port) = 0;
00280       virtual short getPort(int &port) = 0;
00281 
00282       bool    isAMCLR( void );
00283       bool    isAMSTD( void );
00284     };
00285 
00286     /**
00287      * a newer model of the frame grabber card
00288      */
00289     class  itiAMStd : public itiModule {
00290     public:
00291       itiAMStd( MODCNF* theIcpmod, MODCNF* theModule );
00292       virtual ~itiAMStd( void );
00293 
00294       virtual short setRGB( void );
00295       virtual short setBGR( void );
00296 
00297       virtual short lowpassOn( void );
00298       virtual short lowpassOff( void );
00299 
00300       /** set reference value for the ADC (in Volt)
00301           0.0<=neg<=1.476 0.7<=pos<=1.97 pos>=neg
00302           @param neg negative reference voltage (in volt)
00303           @param pos positive reference voltage (in volt)
00304           @return returns a Error if something was wrong, NoError otherwise.
00305         */
00306       virtual short setRedRef( double neg, double pos );
00307 
00308       /** set reference value for the ADC (in Volt)
00309           0.0<=neg<=1.476 0.7<=pos<=1.97 pos>=neg
00310           @param neg negative reference voltage (in volt)
00311           @param pos positive reference voltage (in volt)
00312           @return returns a Error if something was wrong, NoError otherwise.
00313         */
00314       virtual short setGreenRef( double neg, double pos );
00315 
00316       /** set reference value for the ADC (in Volt)
00317           0.0<=neg<=1.476 0.7<=pos<=1.97 pos>=neg
00318           @param neg negative reference voltage (in volt)
00319           @param pos positive reference voltage (in volt)
00320           @return returns a Error if something was wrong, NoError otherwise.
00321         */
00322       virtual short setBlueRef( double neg, double pos );
00323 
00324       /** get the voltage references values of the ADC (in Volt)
00325           @param neg negative reference voltage (in volt)
00326           @param pos positive reference voltage (in volt)
00327           @return returns a Error if something was wrong, NoError otherwise.
00328        */
00329       virtual short getRedRef( double &neg, double &pos );
00330 
00331       /** get the voltage references values of the ADC (in Volt)
00332           @param neg negative reference voltage (in volt)
00333           @param pos positive reference voltage (in volt)
00334           @return returns a Error if something was wrong, NoError otherwise.
00335        */
00336       virtual short getGreenRef( double &neg, double &pos );
00337 
00338       /** get the voltage references values of the ADC (in Volt)
00339           @param neg negative reference voltage (in volt)
00340           @param pos positive reference voltage (in volt)
00341           @return returns a Error if something was wrong, NoError otherwise.
00342        */
00343       virtual short getBlueRef( double &neg, double &pos );
00344 
00345       virtual short selectPort(int port);
00346       virtual short getPort(int &port);
00347 
00348     protected:
00349       MODCNF*     icpmod;
00350       MODCNF*     module;
00351       AMS_CAMCNF* camera;
00352     private:
00353       static const double maxVoltage;
00354       static const double minVoltage;
00355       static const double minDiffVoltage;
00356     };
00357 
00358     /**
00359      * An older model of the frame grabber card
00360      */
00361     class  itiAMClr : public itiModule {
00362     public:
00363       itiAMClr( MODCNF* theIcpmod, MODCNF* theModule );
00364       virtual ~itiAMClr( void );
00365 
00366       virtual short setRGB( void );
00367       virtual short setBGR( void );
00368       virtual short setHSI( void );
00369 
00370       virtual short lowpassOn( void );
00371       virtual short lowpassOff( void );
00372 
00373       /** set reference value for the ADC (in Volt)
00374           0.0<=neg<=1.476 0.7<=pos<=1.97 pos>=neg
00375           @param neg negative reference voltage (in volt)
00376           @param pos positive reference voltage (in volt)
00377           @return returns a Error if something was wrong, NoError otherwise.
00378         */
00379       virtual short setRedRef( double neg, double pos );
00380 
00381       /** set reference value for the ADC (in Volt)
00382           0.0<=neg<=1.476 0.7<=pos<=1.97 pos>=neg
00383           @param neg negative reference voltage (in volt)
00384           @param pos positive reference voltage (in volt)
00385           @return returns a Error if something was wrong, NoError otherwise.
00386         */
00387       virtual short setGreenRef( double neg, double pos );
00388 
00389       /** set reference value for the ADC (in Volt)
00390           0.0<=neg<=1.476 0.7<=pos<=1.97 pos>=neg
00391           @param neg negative reference voltage (in volt)
00392           @param pos positive reference voltage (in volt)
00393           @return returns a Error if something was wrong, NoError otherwise.
00394         */
00395       virtual short setBlueRef( double neg, double pos );
00396 
00397       /** get the voltage references values of the ADC (in Volt)
00398           @param neg negative reference voltage (in volt)
00399           @param pos positive reference voltage (in volt)
00400           @return returns a Error if something was wrong, NoError otherwise.
00401        */
00402       virtual short getRedRef( double &neg, double &pos );
00403 
00404       /** get the voltage references values of the ADC (in Volt)
00405           @param neg negative reference voltage (in volt)
00406           @param pos positive reference voltage (in volt)
00407           @return returns a Error if something was wrong, NoError otherwise.
00408        */
00409       virtual short getGreenRef( double &neg, double &pos );
00410 
00411       /** get the voltage references values of the ADC (in Volt)
00412           @param neg negative reference voltage (in volt)
00413           @param pos positive reference voltage (in volt)
00414           @return returns a Error if something was wrong, NoError otherwise.
00415        */
00416       virtual short getBlueRef( double &neg, double &pos );
00417 
00418       virtual short selectPort(int port);
00419       virtual short getPort(int &port);
00420 
00421     protected:
00422       MODCNF* icpmod;
00423       MODCNF* module;
00424       AMC1_MATRIX *rgbmat, *hsimat, *bgrmat;
00425       AMC1_CAMCNF *camera;
00426     };
00427 
00428     /**
00429      * generate an hardware interface module for the correct iti frame
00430      * grabber card.
00431      */
00432     class itiFactory {
00433     public:
00434       itiModule* generateModule( MODCNF* icpmod );
00435     };
00436 
00437     /**
00438      * buffer for a half image
00439      */
00440     char*       halfPict;
00441 
00442 
00443     MODCNF*     icpmod;
00444 
00445     /**
00446      * the module (the instance depends on the existent frame grabber)
00447      */
00448     itiModule*  module;
00449 
00450     /**
00451      * creates the module with the correct type
00452      */
00453     itiFactory  moduleFactory;
00454 
00455     /**
00456      * id of the grabbed frame
00457      */
00458     short frameID;
00459 
00460     uint16      xCam;
00461     uint16      yCam;
00462 
00463     uint32      firstFieldStart;
00464     uint32      secondFieldStart;
00465   };
00466 }
00467 
00468 #endif // _LTI_MSC_6
00469 #endif // _USE_ITI_FRAME_GRABBER
00470 #endif // #ifdef _LTI_ITI_FRAMEGRABBER_H_

Generated on Sat Apr 10 15:25:40 2010 for LTI-Lib by Doxygen 1.6.1