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

ltiSonyEviD100P.h

00001 /*
00002  * Copyright (C) 2003, 2004, 2005, 2006
00003  * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany
00004  *
00005  * This file is part of the LTI-Computer Vision Library (LTI-Lib)
00006  *
00007  * The LTI-Lib is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public License (LGPL)
00009  * as published by the Free Software Foundation; either version 2.1 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * The LTI-Lib is distributed in the hope that it will be
00013  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
00014  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with the LTI-Lib; see the file LICENSE.  If
00019  * not, write to the Free Software Foundation, Inc., 59 Temple Place -
00020  * Suite 330, Boston, MA 02111-1307, USA.
00021  */
00022 
00023 
00024 /*--------------------------------------------------------------------
00025  * project ....: LTI-Lib: Image Processing and Computer Vision Library
00026  * file .......: ltiSonyEviD100P.h
00027  * authors ....: Claudia Goenner
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 28.8.2003
00030  * revisions ..: $Id: ltiSonyEviD100P.h,v 1.7 2006/02/08 12:07:57 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_SONYEVID100P_H_
00034 #define _LTI_SONYEIVD100P_H_
00035 
00036 #include "ltiCamera.h"
00037 #include "ltiPanTiltUnit.h"
00038 #include "ltiSerial.h"
00039 #include "ltiMutex.h"
00040 #include <string>
00041 
00042 
00043 namespace lti {
00044   /**
00045    * Access to the Sony Evi D100P camera and pan tilt unit. So far only a
00046    * single device on the serial port and asynchronous behauvior are
00047    * supported.
00048    *
00049    * In asynchronous mode a returned true of the set-methods means that the
00050    * command has been successfully sent to the device. About the proper
00051    * execution by the device nothing is known at that time. Furthermore the
00052    * sony protocoll does not tell which commands have been completed
00053    * successfully or caused an error. It is unclear, if the order of sent
00054    * commands and received status messages correspond.
00055    *
00056    * If a command is successfully sent to the device, but not executed
00057    * properly the parameters do not resemble the current status of the
00058    * device. Therefore all called methods send a command to the device, no
00059    * matter whether the device should already be in that status or not.
00060    */
00061   class sonyEviD100P : public camera, public panTiltUnit {
00062     /*-----------------------------------------
00063      * Poll Helper
00064      *----------------------------------------*/
00065   private:
00066     /**
00067      * Polls the Sony Evi D100P camera. This class performs all communication
00068      * to the camera, guaranteeing thread safety. It has a buffer for all
00069      * information send by the camera, i.e. pan and tilt position. In order
00070      * to keep the buffers up to date, inquiries should be send on a regular
00071      * basis, e.g. by a deduced class with a thread running in a loop to allow
00072      * asynchronous communication.
00073      *
00074      * Please note that after construction all inquired values are set to their
00075      * default, no matter whether this resembles the actual state of the sony
00076      * or not. The buffers will be updated as soon as the first inquiry has
00077      * been sent and received. 
00078      */
00079     class poll : public object {
00080     public:
00081 
00082       /**
00083        * Constructor.
00084        * @param serialPortName The serial port, to which the camera is connected,
00085        *                       e.g. Com1 (default)
00086        * @param waitForInit the msec which will be waited for feedback from
00087        *                    the device, e.g. 100 (default)
00088        */
00089       poll(serial::parameters::ePortType port = serial::parameters::Com1,
00090      int waitForInit=100);
00091 
00092       /**
00093        * Destructor.
00094        */
00095       ~poll();
00096       
00097       /**
00098        * @return the name of this type
00099        */
00100       virtual const char* getTypeName () const;
00101       
00102       /**
00103        * check returned messages and update the buffers
00104        */
00105       virtual void processMessages();
00106       
00107       /**
00108        * send inquiry commands to the device
00109        * @return true on success
00110        */
00111       virtual bool inquiry();
00112       
00113       /**
00114        * Registration. Call this method for each copied pointer.
00115        */
00116       virtual void enroll();
00117       
00118       /**
00119        * SignOff a pointer.
00120        * @return the number of objects that are still registered.
00121        */
00122       virtual int signOff();
00123 
00124       /**
00125        * Send a command to the device.
00126        * @param description the command in a format well readable to humans
00127        * @param command the hex command which will be send to the device
00128        * @return true on success
00129        */
00130       virtual bool send(const std::string& description, vector<ubyte>& command);
00131       
00132       /**
00133        * Get the current pan and tilt position (of the same time instant).
00134        * @param pan the current pan position in an internal format
00135        * @param tilt the current tilt position in an internal format
00136        */
00137       virtual void getPanTilt(float& pan, float& tilt) const;
00138 
00139       /**
00140        * Get the current pan position.
00141        * @return the current pan position in an internal format
00142        */
00143       virtual int getPan() const;
00144 
00145       /**
00146        * Get the current tilt position.
00147        * @return the current tilt position in an internal format
00148        */
00149       virtual int getTilt() const;
00150 
00151       /**
00152        * Set the pan and tilt position, i.e. update the buffers
00153        * @param pan the current pan position in an internal format
00154        * @param tilt the current tilt position in an internal format
00155        */
00156       virtual void setPanTilt(int pan, int tilt);
00157 
00158       /**
00159        * Get the current lens setting.
00160        * @param focus the current focus in an internal format
00161        * @param zoom the current zoom in an internal format
00162        */
00163       virtual void getLensSetting(int& focus, float& zoom) const;
00164       
00165       /**
00166        * Get the current zoom.
00167        * @return the current zoom in an internal format
00168        */
00169       virtual int getZoom()  const;
00170 
00171       /**
00172        * Get the current focus.
00173        * @return the current focus in an internal format
00174        */
00175       virtual int getFocus()  const;
00176 
00177       /**
00178        * Set the current lens setting.
00179        * @param zoom the current zoom in an internal format
00180        * @param focus the current focus in an internal format
00181        * @param focusNearLimit the current focusNearLimit in an internal format
00182        */
00183       virtual void setLensSetting(int zoom, int focus, int focusNearLimit);
00184 
00185       /**
00186        * Get the current focus near limit position. 
00187        * @return the focus near limit position in an internal format
00188        */
00189       virtual int getFocusNearLimit() const;
00190       
00191       /**
00192        * Remember the current focus mode
00193        * @param mode the focus mode (auto focus (1), manual focus (0)).
00194        */
00195       virtual void rememberFocusMode(bool mode);
00196 
00197       /**
00198        * @return the current focus mode (auto focus (1), manual focus (0)).
00199        */
00200       virtual bool getFocusMode() const;
00201       
00202       /**
00203        * Turn on/off polling for lens values. This slows down the pan/tilt
00204        * position rate.
00205        * @param on poll the lens system if true, do not otherwise
00206        */
00207       virtual void pollLens(bool on);
00208  
00209      /**
00210        * Poll for pan tilt positions. If this slows down the lens system is not
00211        * tested yet.
00212        * @param on poll for pan and tilt position if true, do not otherwise
00213        */
00214       virtual void pollPanTilt(bool on);
00215     
00216       /*
00217        * init the camera network and get the camera address
00218        * @return true on success
00219        */
00220       bool initCamNetwork();
00221  
00222     private: // No copies
00223       
00224       poll ( const poll & rhs );
00225       
00226       poll & operator = ( const poll & rhs );
00227       
00228     private:
00229       //the serial port to which the camera is connected
00230       serial m_serialPort;    //not static because there are several serial ports in the system
00231       
00232       //the camera address - currently only one camera per port is provided
00233       unsigned char m_camAddress;
00234       unsigned char m_recAddress;
00235       bool m_ifClear;
00236       int m_waitForInit;
00237 
00238       //latest values
00239       int m_panPos;
00240       int m_tiltPos;
00241       int m_zoomPos;
00242       int m_focusPos;
00243       int m_focusNearLimitPos;
00244       bool m_autoFocus;
00245       //bool m_focusing;
00246       //bool m_zooming;
00247       
00248       int m_numPosInquiries;    //counts pan tilt position inquiries on the way
00249       int m_numBlockInquiries;  //counts block inquiries (lens system) on the way
00250       int m_numPosCalls;  //counts when no inquiry are send (too much traffic)
00251       int m_numLensCalls; //counts when no inquiry are send (too much traffic)
00252 
00253       bool m_pollLens;              //poll lens values 
00254       bool m_pollPanTilt;           //pan tilt positions 
00255     
00256       //buffer of received messages
00257       //max. possible number of bytes is 15, the end flag 0xFF is not stored
00258       ubyte m_recBuffer[15];
00259       //current length of read bytes
00260       int m_length;
00261       
00262       //mutex for thread safety
00263       //1) for registration/signing off
00264       //2) for sending/reading commands via the serial port (communication)
00265       //3) for writing/reading pan tilt positions or lens settings (write)
00266       //4) for inquiry/processMessages (max. 3 inquiries may be on the way)
00267       mutex m_registrateMutex;
00268       mutex m_communicateMutex;
00269       mutable mutex m_bufferMutex;
00270       mutex m_inquiryMutex;
00271 
00272       //object count
00273       int m_referenceCount;
00274     };
00275     
00276     //ToDo: Deduce class for asynchronous polling 
00277     //Remark: A class with signaling (synchronous) only make sense, if I guarantee
00278     //        that the the answer belongs too a specific inquiry. Then only
00279     //        one inquiry may be on the way (instead of three). The sony
00280     //        also should not be moving to ensure that the inquired values
00281     //        fit to the grabbed image. Solution: Add blocking getNextPanTilt(...),
00282     //        getNextLensSetting(...) which also checks if the sony moves and has
00283     //        a timeout.
00284 
00285     /*---------------------------------------------------------------------------
00286      * the spy class: This is here to ensure registration 
00287      *--------------------------------------------------------------------------*/
00288   public: 
00289     /**
00290      * If an user wants to send inquiries to the device and process the answers explicitly,
00291      * he may obtain a reference to this class.
00292      */
00293     class externPoll : public object {
00294       
00295       public:
00296       /**
00297        * constructor
00298        */
00299       externPoll();
00300       
00301       /**
00302        * copy constructor
00303        * @param other the class to be copied
00304        */
00305       externPoll(const externPoll& other);
00306     
00307       /**
00308        * destructor
00309        */
00310       ~externPoll();
00311 
00312       /**
00313        * copy data of "other" functor.
00314        * @param other the class to be copied
00315        * @return a reference to this functor object
00316        */
00317       externPoll& copy(const externPoll& other);
00318 
00319       /**
00320        * alias for copy member
00321        * @param other the class to be copied
00322        * @return a reference to this functor object
00323        */
00324       externPoll& operator=(const externPoll& other);
00325 
00326       /**
00327        * Attaches the class which does the actual inquiry of the device.
00328        * @param poller the poller-object which does the inquiry
00329        */
00330       virtual void attachPoller(poll *poller);
00331 
00332       /**
00333        * @return the name of this type
00334        */
00335       virtual const char* getTypeName () const;
00336 
00337       /**
00338        * check returned messages and update the buffers. 
00339        * @return true on success, false otherwise.
00340        */
00341       virtual bool processMessages() const;
00342       
00343       /**
00344        * send inquiry commands to the device.
00345        * @return true on success, false otherwise.
00346        */
00347       virtual bool inquiry() const;
00348 
00349       private:
00350       mutable poll *m_poller;
00351     };
00352 
00353     /*-----------------------------------------
00354      * Parameters
00355      *----------------------------------------*/
00356   public:
00357  
00358     //ToDo: Add a parameter which determines the poller (when there is a choice)
00359     //      The poller may only be changed if 1 registration (1 sony)
00360     //      otherwise copied instanced do not have a poller anymore
00361     /**
00362      * the parameters for the class sonyEviD100P
00363      *
00364      * CAVEAUTS: Continuous movement to the newest pan tilt position only works
00365      *           in absolute mode. When moving in relative coordinates it is hard to
00366      *           figure out, where the camera is moving too, i.e. which command is
00367      *           executed. This restriction only applies if a new pan-tilt-command
00368      *           is issued before the old pan-tilt-command is completed.
00369      */
00370     class parameters : public camera::parameters, public panTiltUnit::parameters {
00371     public:
00372       /**
00373        * default constructor
00374        */
00375       parameters();
00376 
00377       /**
00378        * copy constructor
00379        * @param other the parameters object to be copied
00380        */
00381       parameters(const parameters& other);
00382 
00383       /**
00384        * destructor
00385        */
00386       ~parameters();
00387 
00388       /**
00389        * returns name of this type
00390        */
00391       const char* getTypeName() const;
00392 
00393       /**
00394        * copy the contents of a parameters object
00395        * @param other the parameters object to be copied
00396        * @return a reference to this parameters object
00397        */
00398       parameters& copy(const parameters& other);
00399 
00400       /**
00401        * copy the contents of a parameters object
00402        * @param other the parameters object to be copied
00403        * @return a reference to this parameters object
00404        */
00405       parameters& operator=(const parameters& other);
00406 
00407 
00408       /**
00409        * returns a pointer to a clone of the parameters
00410        */
00411       virtual functor::parameters* clone() const;
00412 
00413       /**
00414        * write the parameters in the given ioHandler
00415        * @param handler the ioHandler to be used
00416        * @param complete if true (the default) the enclosing begin/end will
00417        *        be also written, otherwise only the data block will be written.
00418        * @return true if write was successful
00419        */
00420       virtual bool write(ioHandler& handler,const bool complete=true) const;
00421 
00422       /**
00423        * read the parameters from the given ioHandler
00424        * @param handler the ioHandler to be used
00425        * @param complete if true (the default) the enclosing begin/end will
00426        *        be also written, otherwise only the data block will be written.
00427        * @return true if write was successful
00428        */
00429       virtual bool read(ioHandler& handler,const bool complete=true);
00430 
00431 #     ifdef _LTI_MSC_6
00432       /**
00433        * this function is required by MSVC only, as a workaround for a
00434        * very awful bug, which exists since MSVC V.4.0, and still by
00435        * V.6.0 with all bugfixes (so called "service packs") remains
00436        * there...  This method is also public due to another bug, so please
00437        * NEVER EVER call this method directly: use read() instead
00438        */
00439       bool readMS(ioHandler& handler,const bool complete=true);
00440 
00441       /**
00442        * this function is required by MSVC only, as a workaround for a
00443        * very awful bug, which exists since MSVC V.4.0, and still by
00444        * V.6.0 with all bugfixes (so called "service packs") remains
00445        * there...  This method is also public due to another bug, so please
00446        * NEVER EVER call this method directly: use write() instead
00447        */
00448       bool writeMS(ioHandler& handler,const bool complete=true) const;
00449 #     endif
00450 
00451       // ------------------------------------------------
00452       // the parameters
00453       // ------------------------------------------------
00454        /**
00455        * The possible poll-modes: Manual (the user is responsible for polling
00456        * the device). Further modes could be added, e.g. asynchronous polling,
00457        * where the class splits off a seperate poll-thread which updates its
00458        * internal buffers a regular basis, or a synchronous behavior, where each
00459        * command blocks till its success.
00460        */
00461       enum ePollerType { ManualPoll };
00462  
00463       /**
00464        * the type of requested polling behavior.
00465        */
00466       ePollerType poller;
00467 
00468       /**
00469        * Turn on/off polling for lens values. This slows down the pan/tilt
00470        * position rate. If true lens system inquiries will be send. Default: false.
00471        */
00472       bool pollLens;
00473 
00474       /**
00475        * Poll for pan tilt positions. Whether this slows down the lens system is not
00476        * tested yet. If true pan tilt inquiries will be send. Default: true.
00477        */
00478       bool pollPanTilt;
00479       
00480       /**
00481        * the time in ms which the constructor waits for feedback from the device.
00482        * If this time intervall is too short, the feedback will be received later
00483        * by the method processMessages(). Commands sent to the camera might return
00484        * an error, though, due to missing initialization information.
00485        * Default: 200 ms.
00486        */
00487       int waitForInit;
00488 
00489       //---------------
00490       // pan tilt unit
00491       //---------------
00492 
00493       /**
00494        * The pan speed with which the pan Tilt unit shall move in degrees/s.
00495        * Default: max. speed.
00496        */
00497       float panSpeed;
00498 
00499       /**
00500        * the minimum pan speed, i.e. 2 degrees/s
00501        */
00502       static const float minPanSpeed;
00503 
00504       /**
00505        * the maximum pan speed, i.e. 300 degrees/s
00506        */
00507       static const float maxPanSpeed;
00508 
00509       /**
00510        * The tilt speed with which the pan tilt unit shall move in degrees/s.
00511        * Default: max. speed.
00512        */
00513       float tiltSpeed;
00514   
00515       /**
00516        * the minimum tilt speed, i.e. 2 degrees/s 
00517        */
00518       static const float minTiltSpeed;    
00519 
00520       /**
00521        * the maximum tilt speed, i.e. 125 degrees/s 
00522        */
00523       static const float maxTiltSpeed;
00524 
00525       //--------
00526       // camera
00527       //--------
00528       
00529       /**
00530        * the white balance modes supported by the sony Evi D100:
00531        * auto tracing (3000 - 7500K), extended auto tracing (2000 - 10000 K),
00532        * indoor (3200 K), outdor (5800 K), triggering one push and manual.
00533        */
00534       enum eWhiteBalanceType { Auto, ExtendedAuto, Indoor, Outdoor, OnePush, Manual };
00535 
00536       /**
00537        * a specialisation of auto or manual white balance. Thereby Auto,
00538        * ExtendedAuto, Indoor and Outdoor are considered as automatic modes,
00539        * i.e the autoWhiteBalance parameter is true. Whereas OnePush and
00540        * Manual require the autoWhiteBalance to be false. On conflicts between
00541        * the two parameters the boolean autoWhiteBalance has higher priority,
00542        * and the whiteBalanceMode will be changed to Auto or Manual respectively.
00543        * Default: Auto.
00544        */
00545       eWhiteBalanceType whiteBalanceMode;
00546 
00547       /**
00548        * If true the iris will be set automatically, otherwise manual controll is
00549        * enabled. Default: true.
00550        */
00551       bool autoIris;
00552 
00553       /**
00554        * the possible iris openings.
00555        */
00556       enum eIrisType { Close, F28, F22, F19, F16, F14, F11, F9_6, F8, F6_8, F5_6,
00557            F4_8, F4, F3_4, F2_8, F2_4, F2, F1_8 };
00558       
00559       /**
00560        * the desired iris setting if in manual mode. Default: F11.
00561        */
00562       eIrisType iris;
00563 
00564       /**
00565        * If true, both gain and iris are adjusted using an internal algorithm,
00566        * according to a brighness level set by the user. The brightness mode is
00567        * considered a special combined automatic iris and white balance mode.
00568        * Thus the parameters autoWhiteBalance and autoIris must be true. Otherwise
00569        * this flag has no effect. Default: false.
00570        */
00571       bool enableBrightness;
00572 
00573       /**
00574        * The brightness level ranging from 0 to 23. Default: 6
00575        */
00576       int brightness;
00577 
00578       /**
00579        * the maximum brightness level, i.e. 23.
00580        */
00581       static const int maxBrightness;
00582 
00583       /**
00584        * Value of the exposure compensation. Exposure compensation is a function
00585        * which offsets the internal reference brightness level by steps of 1.5 dB.
00586        * Default: 0
00587        */
00588       int exposureCompensation;
00589 
00590       /**
00591        * the minimum exposure compensation, i.e. -7.
00592        */
00593       static const int minExposureCompensation;
00594 
00595       /**
00596        * the maximum exposure compensation, i.e. 7.
00597        */
00598       static const int maxExposureCompensation;
00599 
00600       /**
00601        * If the background is too bright or too dark when shooting in automatic
00602        * exposure mode, backlight compensation will make the subject appear clearer.
00603        * If true backlight compensation is enabled.
00604        */
00605       bool enableBackLightCompensation;
00606 
00607       /**
00608        * Aperture controll is a function which adjusts the enhancement of edges
00609        * of objects in the picture. Ranges from 0 (no enhancement) to 15. Default: 5.
00610        */
00611       int aperture;
00612 
00613       /**
00614        * the maximum aperture enhancement, i.e. 15
00615        */
00616       static const int maxAperture;
00617 
00618       /**
00619        * The sony allows several picture effects:
00620        * Pastel (gradient in the first band and UV in the second and third),
00621        * NegArt (negative/positive reversal),
00622        * Sepia, Monochrome,
00623        * Solarize (simple mean shift algorithm),
00624        * Mosaic (coarse resolution),
00625        * Slim (vertical stretch),
00626        * Stretch (horizontal stretch),
00627        * and Color.
00628        */
00629       enum ePictureEffectType { Pastel, NegArt, Sepia, Monochrome, Solarize, Mosaic,
00630         Slim, Stretch, Color };
00631 
00632       /**
00633        * the picture effect, see above. Default: Color.
00634        */
00635       ePictureEffectType pictureEffect;
00636 
00637       /**
00638        * The sony allows some digital effects, which are executed via the field memory.
00639        * Still: moving image on still image,
00640        * Flash: Continuous still image,
00641        * Lumi: Moving images on a binaried still image,
00642        * Trail: Afterimage lag of moving subject,
00643        * None: no digital effect.
00644        */
00645       enum eDigitalEffectType { Still, Flash, Lumi, Trail, None };
00646 
00647       /**
00648        * the digital effect, see above. Default: None.
00649        */
00650       eDigitalEffectType digitalEffect;
00651 
00652       /**
00653        * Digital effect level: 0 to 24 (flash, trail) and 0 t0 32 (still, lumi). 
00654        * Default: 0.
00655        */
00656       int digitalEffectLevel;
00657 
00658       /**
00659        * The maximum level of the still effect;
00660        */
00661       static const int maxStillLevel;
00662 
00663       /**
00664        * The maximum level of the flash effect;
00665        */
00666       static const int maxFlashLevel; 
00667       
00668       /**
00669        * The maximum level of the lumi effect;
00670        */
00671       static const int maxLumiLevel;   
00672       
00673       /**
00674        * The maximum level of the trail effect;
00675        */
00676       static const int maxTrailLevel;
00677  
00678       /**
00679        * If true the auto focus has a high sensitiviy, otherwise the sensitivity is low.
00680        * Default: 0.
00681        */
00682       bool highAutoFocusSensitivity;
00683 
00684       /**
00685        * the focus near limit in meter. Default: 0.
00686        */
00687       float focusNearLimit;
00688 
00689       /**
00690        * the focus speed. Default: max. speed
00691        */
00692       int focusSpeed;
00693 
00694       /**
00695        * the mininum focus speed, i.e. 0
00696        */
00697       static const int minFocusSpeed;
00698 
00699       /**
00700        * the maximum focus speed, i.e. 7
00701        */
00702       static const int maxFocusSpeed;
00703 
00704       /**
00705        * the maximum optical zoom, i.e. 10
00706        */
00707       static const float maxOpticalZoom;
00708 
00709       /**
00710        * Enable or disable the digital zoom.
00711        */
00712       bool digitalZoom;
00713 
00714       /**
00715        * the speed of the zoom. Default: max. speed
00716        */
00717       int zoomSpeed;
00718 
00719       /**
00720        * the minimum zoom speed, i.e. 0
00721        */
00722       static const float minZoomSpeed;
00723 
00724       /**
00725        * the maximum zoom speed, i.e. 7
00726        */
00727       static const float maxZoomSpeed;
00728  
00729     };
00730 
00731     /**
00732      * default constructor
00733      */
00734     sonyEviD100P();
00735 
00736     /**
00737      * Construct a functor using the given parameters
00738      */
00739     sonyEviD100P(const parameters& par);
00740 
00741     /**
00742      * copy constructor
00743      * @param other the object to be copied
00744      */
00745     sonyEviD100P(const sonyEviD100P& other);
00746 
00747     /**
00748      * destructor
00749      */
00750     virtual ~sonyEviD100P();
00751 
00752     /**
00753      * returns the name of this type ("sonyEviD100P")
00754      */
00755     virtual const char* getTypeName() const;
00756 
00757     /**
00758      * copy data of "other" functor.
00759      * @param other the functor to be copied
00760      * @return a reference to this functor object
00761      */
00762     sonyEviD100P& copy(const sonyEviD100P& other);
00763 
00764     /**
00765      * alias for copy member
00766      * @param other the functor to be copied
00767      * @return a reference to this functor object
00768      */
00769     sonyEviD100P& operator=(const sonyEviD100P& other);
00770 
00771     /**
00772      * returns a pointer to a clone of this functor.
00773      */
00774     virtual functor* clone() const;
00775 
00776     /**
00777      * returns used parameters
00778      */
00779     const parameters& getParameters() const;
00780 
00781     /**
00782      * Set the parameters and inform the hardware about changes
00783      * @param par the parameters to be used
00784      * @return true if successful, false otherwise
00785      */
00786     virtual bool setParameters(const functor::parameters& par);
00787 
00788     //---------------------
00789     // the pan tilt methods
00790     //---------------------
00791 
00792     /**
00793      * Reset the pan tilt device. This method resets internal pan and tilt
00794      * registers.  Some devices need resets from time to time to avoid
00795      * accumulation errors.  After succesfull execution the pan tilt unit
00796      * should be in the same position as before the call. During execution the
00797      * pan tilt unit may move.
00798      *
00799      * @return true on success
00800      */
00801     virtual bool reset();
00802 
00803     /**
00804      * stop the movement
00805      * @return true on success
00806      */
00807     virtual bool stopPanTilt();
00808 
00809     /** 
00810      * set the pan and tilt position. Usually pan and tilt are sent to
00811      * the device in a single package. The pan tilt moves with maximum
00812      * speed.
00813      * @param pan the pan position the device will move to
00814      * @param tilt the pan position the device will move to
00815      * @return true on success
00816      */
00817     virtual bool setPanTilt(float pan, float tilt);
00818 
00819     /**
00820      * set the pan and tilt position including pan and tilt speeds.
00821      * @param pan the pan position the device will move to
00822      * @param tilt the pan position the device will move to
00823      * @param panSpeed the speed in pan direction
00824      * @param tiltSpeed the speed in tilt direction
00825      * @return true on success
00826      */
00827     virtual bool setPanTilt(float pan, float tilt,
00828           float panSpeed, float tiltSpeed); 
00829 
00830     /** 
00831      * set the pan position
00832      * @param pan the pan position the device will move to
00833      * @return true on success
00834      */
00835     virtual bool setPan(float pan);
00836 
00837     /** 
00838      * set the tilt position
00839      * @param tilt the tilt position the device will move to
00840      * @return true on success
00841      */
00842     virtual bool setTilt(float tilt);
00843 
00844     /**
00845      * get the current pan and tilt position. The combined
00846      * get-methods guarantee pan and tilt positions of the
00847      * same time instant.
00848      * @param pan the pan position which the device is in
00849      * @param tilt the tilt position which the device is in
00850      * @return true on success
00851      */
00852     virtual bool getPanTilt(float& pan, float& tilt) const;
00853 
00854     /**
00855      * @return the current pan position
00856      */
00857     virtual float getPan() const;
00858 
00859     /**
00860      * @return the current tilt position
00861      */
00862     virtual float getTilt() const;
00863 
00864     //-------------------
00865     // the camera methods
00866     //-------------------
00867 
00868     /**
00869      * turn on automatic exposure (AE) mode.
00870      * The iris and gain are set automatically, the
00871      * shutter speed is fixed to 1/50 s. Disables brightness.
00872      * @return true on success
00873      */
00874     virtual bool autoExposureOn();
00875     
00876     /**
00877      * turn automatic gain and iris control. The shutter will be
00878      * set manually. Disables brightness.
00879      * @return true on success
00880      */
00881     virtual bool shutterPriorityOn();
00882 
00883     /**
00884      * turn on manual gain, shutter and iris. Disables brightness.
00885      * @return true on success
00886      */
00887     virtual bool manualExposureOn();
00888 
00889     /**
00890      * turn automatic shutter and gain control. The iris will be
00891      * set manually. Disables brightness.
00892      * @return true on success
00893      */
00894     virtual bool irisPriorityOn();
00895 
00896     /**
00897      * turn automatic shutter and iris control. The gain will be
00898      * set manually. Disables brightness.
00899      * @return true on success
00900      */
00901     virtual bool gainPriorityOn();
00902 
00903     /**
00904      * turn on automatic shutter only. The gain and iris will
00905      * be set manually. Disables brightness.
00906      * @return true on success
00907      */
00908     virtual bool onlyAutoShutterOn();
00909 
00910     /**
00911      * turn on automatic gain only. The shutter and iris will
00912      * be set manually. Disables brightness.
00913      * @return true on success
00914      */
00915     virtual bool onlyAutoGainOn();
00916 
00917     /**
00918      * turn on automatic iris only. The shutter and gain will
00919      * be set manually. Disables brightness.
00920      * @return true on success
00921      */
00922     virtual bool onlyAutoIrisOn();
00923 
00924     //----------
00925     // WB + gain
00926     //----------
00927 
00928     /**
00929      * Trigger the white balance one push, assuming that a white
00930      * object occupies at least half the image. The value will be
00931      * fixed till the next trigger. This is a special manual white
00932      * balance mode, i.e. the autoWhiteBalance-parameter is false.
00933      * @return true on success
00934      */
00935     virtual bool triggerWhiteBalance();
00936   
00937     /**
00938      * The red and blue gain values will be determined
00939      * on call of the method triggerWhiteBalance().
00940      * @return true on success
00941      */
00942     virtual bool onePushWhiteBalanceOn();
00943   
00944     /**
00945      * Extend the auto white balance tracing to 2000 to 10000 K.
00946      * This is a special auto white balance mode.
00947      * @return true on success
00948      */
00949     virtual bool extendedAutoWhiteBalanceOn();
00950 
00951     /**
00952      * Fix the white balance to 3200 K.
00953      * This is a special auto white balance mode.
00954      * @return true on success
00955      */
00956     virtual bool outdoorWhiteBalanceOn();
00957 
00958     /**
00959      * Fix the white balance to 5800 K.
00960      * This is a special auto white balance mode.
00961      * @return true on success
00962      */
00963     virtual bool indoorWhiteBalanceOn();
00964 
00965     /**
00966      * turn on automatic white balance (3000 to 7500 K)
00967      * @return true on success
00968      */
00969     virtual bool autoWhiteBalanceOn();
00970 
00971     /**
00972      * turn on manual white balance
00973      * @return true on success
00974      */
00975     virtual bool manualWhiteBalanceOn();  
00976 
00977     /**
00978      * turn on automatic gain. Disables brightness.
00979      * @return true on success
00980      */
00981     virtual bool autoGainOn();
00982 
00983     /**
00984      * set the global gain. Turns off automatic gain if the
00985      * according parameter is true.
00986      * @param value the gain value
00987      * @return true on success
00988      */
00989     virtual bool setGain(float value);
00990 
00991     /**
00992      * set the red gain. Switched to manual white balance unless
00993      * the parameters already indicate that state.
00994      * @param value the red gain value
00995      * @return true on success
00996      */
00997     virtual bool setRedGain(float value);
00998 
00999     /**
01000      * set the blue gain. Switched to manual white balance unless
01001      * the parameters already indicate that state.
01002      * @param value the blue gain value
01003      * @return true on success
01004      */
01005     virtual bool setBlueGain(float value);
01006 
01007     //---------------
01008     // shutter speed
01009     //---------------
01010     /**
01011      * turn on automatic choice of the shutter speed.
01012      * The shutter changes automatically depending onf the brightness of
01013      * the subject. Disables brightness.
01014      * @return true on success
01015      */
01016     virtual bool autoShutterSpeedOn();
01017 
01018     /**
01019      * set the shutter speed. Turns off automatic shutter if the according
01020      * parameter is true.
01021      * @param value the shutter speed
01022      * @return true on success
01023      */
01024     virtual bool setShutterSpeed(float value);
01025 
01026     //-------
01027     // iris
01028     //-------
01029     /**
01030      * turn on automatic choice of the iris. Disables brightness.
01031      * @return true on success
01032      */
01033     virtual bool autoIrisOn();
01034 
01035     /**
01036      * set the iris. Turns off automatic iris if the according
01037      * parameter is true.
01038      * @param value the iris setting
01039      * @return true on success
01040      */
01041     virtual bool setIris(parameters::eIrisType value);
01042 
01043     //-----------------
01044     // brightness & co
01045     //-----------------
01046     /**
01047      * Turn of the brightness mode. The bright controll function adjusts both gain
01048      * and iris depending on the brightness level. It only works if automatic
01049      * iris and gain are turned on. Otherwise false is returned.
01050      * @return true on success
01051      */
01052     virtual bool brightnessOn();
01053 
01054     /**
01055      * Set the brightness level. Enables the brightness mode if its
01056      * parameter is turned off.
01057      * Turns on auto white balance and auto iris.
01058      * @param value the brightness value
01059      * @return true on success
01060      */
01061     virtual bool setBrightness(int value);
01062 
01063     /**
01064      * set an offset to the internal reference brightness level
01065      * @param value the degree of exposure compensation
01066      * @return true on success
01067      */    
01068     virtual bool setExposureCompensation(int value);
01069 
01070     //-----------------
01071     // special effects
01072     //-----------------
01073     
01074     /**
01075      * If the background is too bright or too dark when shooting in automatic
01076      * exposure mode, back light compensation will make the subject appear clearer.
01077      * @return true on success
01078      */
01079     virtual bool backLightCompensationOn();
01080     
01081     /**
01082      * Turn off the back light compensation
01083      * @return true on success
01084      */ 
01085     virtual bool backLightCompensationOff();
01086 
01087     /**
01088      * Aperture controll is a function which adjusts the enhancement of edges
01089      * of objects in the picture. Ranges from 0 (no enhancement) to 15.
01090      * param value the aperture
01091      * @return true on success
01092      */
01093     virtual bool setAperture(int value);
01094    
01095     /**
01096      * set the picture effect, see parameters documentation for details
01097      * param effect the picture effect
01098      * @return true on success
01099      */
01100     virtual bool setPictureEffect(parameters::ePictureEffectType effect);
01101 
01102     /**
01103      * set the digital effect, see parameters documentation for details
01104      * param effect the digital effect
01105      * @return true on success
01106      */  
01107     virtual bool setDigitalEffect(parameters::eDigitalEffectType effect);
01108 
01109     /**
01110      * Digital effect level: 00 (flash) to 24 (trail) and 00 (still) t0 32
01111      * (lumi). 
01112      * param value the level of the digital effect
01113      * @return true on success
01114      */
01115     virtual bool setDigitalEffectLevel(int value);  
01116 
01117     //-------
01118     // focus
01119     //-------
01120     /**
01121      * Enable the highly sensible auto focus.
01122      * @return true on success
01123      */
01124     virtual bool highAutoFocusSensibilityOn();
01125 
01126     /**
01127      * Enable the low sensible auto focus.
01128      * @return true on success
01129      */
01130     virtual bool lowAutoFocusSensibilityOn(); 
01131 
01132     /**
01133      * set the focus. Turns off autofocus if the
01134      * parameters indicate that it is on.
01135      * @param value the focus value
01136      * @return true on success
01137      */
01138     virtual bool setFocus(float value);
01139 
01140     /**
01141      * Set the focus to its maximum value.
01142      *
01143      * Turns off autofocus if the parameters indicate that it is on.
01144      *
01145      * @param speed the focusing speed
01146      *
01147      * @return true on success
01148      */
01149     virtual bool setFarFocus(int speed = 7);
01150 
01151     /**
01152      * Set the focus to its minimum value.
01153      *
01154      * Turns off autofocus if the parameters indicate that it is on.
01155      *
01156      * @param speed the focusing speed
01157      * @return true on success
01158      */
01159     virtual bool setNearFocus(int speed = 7);
01160 
01161     /**
01162      * Stop the focus at its current position. 
01163      *
01164      * The focus position in the parameter set is not updated, because
01165      * the actual focus position is unknown yet due to the delay of
01166      * the inquiries and their answers.  Turns off autofocus if the
01167      * parameters indicate that it is on.
01168      *
01169      * @return true on success
01170      */
01171     virtual bool stopFocus();  
01172 
01173     /**
01174      * Set the focus to infiniy.
01175      *
01176      * Turns off autofocus if the parameters indicate that it is on.
01177      *
01178      * @return true on success
01179      */
01180     virtual bool setFocusToInfinity();
01181     
01182     /**
01183      * Turn on manual focus
01184      *
01185      * @return true on success
01186      */
01187     virtual bool manualFocusOn();
01188     
01189     /**
01190      * Turn on auto focus
01191      *
01192      * @return true on success
01193      */
01194     virtual bool autoFocusOn(); 
01195 
01196     /**
01197      * Trigger the focus one push.
01198      *
01199      * Turns off auto focus.  The actual focus value is unknown yet
01200      * and thus the parameter's focus is not updated.
01201      *
01202      * @return true on success
01203      */
01204     virtual bool triggerFocus();
01205     
01206     /**
01207      * @return the current focus
01208      */
01209     virtual float getFocus() const;
01210 
01211     //---------
01212     // zoom
01213     //---------
01214 
01215     /**
01216      * Stop the zoom at its current position. The zoom
01217      * position in the parameter set is not updated, because
01218      * the actual zoom position is unknown yet due to the delay
01219      * of the inquiries and their answers.
01220      * @return true on success
01221      */
01222     virtual bool stopZoom();
01223 
01224     /**
01225      * set the zoom to its minimum value.
01226      * @param speed the zooming speed
01227      * @return true on success
01228      */
01229     virtual bool setWideZoom(int speed = 7);
01230 
01231     /**
01232      * set the zoom to its maximum optical value.
01233      * @param speed the zooming speed
01234      * @return true on success
01235      */    
01236     virtual bool setTeleZoom(int speed = 7);
01237 
01238     /*
01239      * Turn on the digital zoom.
01240      * @return true on success
01241      */    
01242     virtual bool digitalZoomOn();
01243 
01244    /*
01245      * Turn off the digital zoom.
01246      * @return true on success
01247      */    
01248     virtual bool digitalZoomOff();
01249 
01250     /**
01251      * set the zoom. Returns true on success. If the digital zoom is
01252      * disabled only values up to 10 are allowed.
01253      * Otherwise a 4 times digital zoom is combined with the 10 times
01254      * optical zoom resulting in a maximal possible zoom factor of 40.
01255      * @param value the zoom value
01256      * @return true on success
01257      */
01258     virtual bool setZoom(float value);
01259 
01260     /**
01261      * @return the current zoom
01262      */
01263     virtual float getZoom() const;
01264 
01265     /**
01266      * Get the focus and zoom values from a single time instant.
01267      * @param focus the current focus value
01268      * @param zoom the current zoom value
01269      * @return true on success
01270      */
01271     virtual bool getLensSetting(float& focus, float& zoom) const;
01272 
01273     //-------------------
01274     // poll/trigger stuff
01275     //-------------------
01276 
01277     /**
01278      * Get a reference to the poller. This may be usefull
01279      * if the user wants to send and process inquiries himself.
01280      * return a reference to the extern poller
01281      */
01282     virtual const externPoll& getPoller();
01283 
01284     /**
01285      * Check wether the camera was initialized completely on construction.
01286      * A complete initialization requires feedback from the hardware. Because
01287      * this driver only waits a limited amount of time for the feedback, it
01288      * does not always perform a complete initialization. In this case
01289      * the hardware still works, but the desired parameters have not been
01290      * sent to the hardware yet, e.g. the camera might not have the expected
01291      * zoom. It is up to the user to recall setParameters() after an incomplete
01292      * initialization.
01293      */
01294     virtual bool completeInit();
01295 
01296     /**
01297      * Turn on polling the lens system.
01298      * @return true on success
01299      */
01300     virtual bool pollLensOn();
01301       
01302     /**
01303      * Turn off polling the lens system.
01304      * @return true on success
01305      */
01306     virtual bool pollLensOff();
01307 
01308     /**
01309      * Turn on polling the pan tilt positions.
01310      * @return true on success
01311      */
01312     virtual bool pollPanTiltOn();
01313 
01314     /**
01315      * Turn off polling the pan tilt positions.
01316      * @return true on success
01317      */
01318     virtual bool pollPanTiltOff();
01319     
01320   protected:
01321     /** get a pointer to the parameters */
01322     parameters& getWritableParameters();
01323 
01324     /** initialize device */
01325     bool init();
01326 
01327     /** initialize Set*Position command string */
01328     bool initPosCommand(vector<ubyte>& command, float pan, float tilt, 
01329       float panSpeed, float tiltSpeed);
01330 
01331     /** Convert focus from distance in m to internal value */
01332     int distance2Focus (float& distance) const;
01333 
01334     /** Convert focus from internal value to distance in m */
01335     float focus2Distance (int focus) const;
01336 
01337     /** the poller, which is not static because we may have different serial ports
01338      * and thus different cameras */
01339     poll *m_poller;
01340     /** the user access to the poller whith limited operations */
01341     externPoll m_externPoller;
01342 
01343     /** false if the constructor did not have enough time to init the camera */
01344     bool m_completeInit;
01345 
01346     /** for conversion between degrees/radiant and sony-format */
01347     static const float m_tiltFactor;
01348     static const float m_panFactor;
01349   };
01350 }
01351 
01352 #endif

Generated on Sat Apr 10 15:26:13 2010 for LTI-Lib by Doxygen 1.6.1