Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

ImageStreamDriver.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_ImageStreamDriver_h_
00003 #define INCLUDED_ImageStreamDriver_h_
00004 
00005 #include "DataStreamDriver.h"
00006 
00007 //! description of ImageStreamDriver
00008 class ImageStreamDriver : public DataStreamDriver {
00009 public:
00010   explicit ImageStreamDriver(const std::string& name)
00011     : DeviceDriver(autoRegisterDriver,name), DataStreamDriver(autoRegisterDriver,name), format(FORMAT_JPEG,formatNames), payloadSize(0)
00012   {
00013     addEntry("Format",format,"The type of format to expect from the comm port.\n"
00014          "'YUV' expects interleaved components 'CameraResolutionX' wide and 'CameraResolutionY' high\n"
00015          "(defined in target's RobotInfo namespace)");
00016   }
00017 
00018   virtual std::string getClassName() const { return autoRegisterDriver; }
00019 
00020   virtual void getImageSources(std::map<std::string,DataSource*>& sources) {
00021     sources.clear();
00022     sources["Camera"]=this;
00023   }
00024   
00025   virtual void plistValueChanged(const plist::PrimitiveBase& pl);
00026   
00027   //! enumerates the available formats for input to the driver
00028   enum format_t {
00029     FORMAT_YUV=0, //!< raw interleaved YUV data, @c CameraResolutionX wide by @c CameraResolutionY high (defined in target's RobotInfo namespace)
00030     FORMAT_PNG, //!< PNG compressed image
00031     FORMAT_JPEG, //!< JPEG compressed iamge
00032     FORMAT_TEKKOTSU //!< the format used by the Tekkotsu streaming video
00033   };
00034   //! number of entries in format_t
00035   static const size_t NUM_FORMATS = 4;
00036   //! human-readable names for the supported formats, see format_t
00037   static const char * formatNames[NUM_FORMATS+1];
00038   
00039   //! The type of format to expect from the comm port.
00040   /*! 'YUV' expects interleaved components 'CameraResolutionX' wide and 'CameraResolutionY' high (defined in target's RobotInfo namespace) */
00041   plist::NamedEnumeration<format_t> format;
00042 
00043 protected:
00044   virtual bool readData(std::istream& is);
00045   RCRegion * readImage(std::istream& is);
00046   static void copyImage(char * buf, unsigned int width, unsigned int height, unsigned int channels, const char * chan, unsigned int lwidth, unsigned int lheight, unsigned int lchan);
00047   
00048   virtual void connect(CommPort* comm);
00049   virtual void disconnect(CommPort* comm);
00050   
00051   size_t payloadSize; //!< caches size of last decompressed (yuv) image to assume next image will be the same size
00052   
00053 private:
00054   //! holds the class name, set via registration with the DeviceDriver registry
00055   static const std::string autoRegisterDriver;
00056   ImageStreamDriver(const ImageStreamDriver&); //!< no call
00057   ImageStreamDriver operator=(const ImageStreamDriver&); //!< no call
00058 };
00059 
00060 /*! @file
00061  * @brief 
00062  * @author Ethan Tira-Thompson (ejt) (Creator)
00063  */
00064 
00065 #endif

Tekkotsu Hardware Abstraction Layer 5.1CVS
Generated Fri Mar 16 05:30:34 2012 by Doxygen 1.6.3