sphere_mixed.h
00001 /*
00002  *  Player - One Hell of a Robot Server
00003  *  Copyright (C) 2000  Brian Gerkey et al.
00004  *
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 #include <stdint.h>
00023 
00024 #include <libplayercore/playercore.h>
00025 
00026 #include "v4lcapture.h"
00027 
00028 #define PLAYER_CAMERA_FORMAT_RGB 6
00029 #define PLAYER_CAMERA_FORMAT_YUV420P 7
00030 
00032 // The class for the driver
00033 class SphereDriver : public ThreadedDriver
00034 {
00035   public:
00036 
00037     // Constructor; need that
00038     SphereDriver(ConfigFile* cf, int section);
00039 
00040     // Must implement the following methods.
00041     int MainSetup();
00042     void MainQuit();
00043     // Main function for device thread.
00044     virtual void Main();
00045 
00046     // This method will be invoked on each incoming message
00047     virtual int ProcessMessage(QueuePointer & resp_queue,
00048                                player_msghdr * hdr,
00049                                void * data);
00050     //void ProcessConfig();
00051     void ProcessCommand(player_msghdr_t* hdr, player_ptz_cmd_t &data);
00052     void RefreshData();
00053 
00054  private:
00055 
00056     void YUV422toRGB(uint8_t* argInputData, uint8_t* argOutputData);
00057 
00058     inline double LimitPan(double argP)
00059     {return (argP < mPanMin) ? mPanMin : ((argP > mPanMax) ? mPanMax : argP);};
00060     inline double LimitTilt(double argT)
00061     {return (argT < mTiltMin) ? mTiltMin : ((argT > mTiltMax) ? mTiltMax : argT);};
00062 
00063     // Camera interface
00064     player_devaddr_t       mCameraAddr;
00065     player_camera_data_t   mCameraData;
00066     // PTZ interface
00067     player_devaddr_t    mPtzAddr;
00068     player_ptz_data_t   mPtzData;
00069     player_ptz_cmd_t    mPtzCmd;
00070 
00071     int32_t mSleep;
00072     int32_t mFrameRate;
00073     int32_t mShutterSpeed;
00074     int32_t mCompressionPreference;
00075     int32_t mAutomaticGain;
00076     int32_t mSharpness;
00077     int32_t mBacklight;
00078     int32_t mFlicker;
00079     int32_t mNoiseReduction;
00080     int32_t mDumpSettings;
00081     int32_t mDebug;
00082     const char *mAutomaticWb;
00083 
00084     double mPanMin;
00085     double mPanMax;
00086     double mTiltMin;
00087     double mTiltMax;
00088 
00089     // Video device
00090     const char *mDevice;
00091     // Input source
00092     int32_t mSource;
00093 
00094     // Camera palette
00095     const char *mPalette;
00096     // Frame grabber interface
00097     FRAMEGRABBER* mFg;
00098 
00099     // The current image (local copy)
00100     FRAME* mFrame;
00101     FRAME* mRGBFrame;
00102     int32_t mFrameNumber;
00103 
00104     // Image dimensions
00105     int32_t mWidth, mHeight;
00106     // Pixel depth
00107     int32_t mDepth;
00108 
00109     // Write frames to disk?
00110     int32_t mSave;
00111 
00112 };