ImageStreamDriver.h
Go to the documentation of this file.00001
00002 #ifndef INCLUDED_ImageStreamDriver_h_
00003 #define INCLUDED_ImageStreamDriver_h_
00004
00005 #include "DataStreamDriver.h"
00006
00007
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
00028 enum format_t {
00029 FORMAT_YUV=0,
00030 FORMAT_PNG,
00031 FORMAT_JPEG,
00032 FORMAT_TEKKOTSU
00033 };
00034
00035 static const size_t NUM_FORMATS = 4;
00036
00037 static const char * formatNames[NUM_FORMATS+1];
00038
00039
00040
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;
00052
00053 private:
00054
00055 static const std::string autoRegisterDriver;
00056 ImageStreamDriver(const ImageStreamDriver&);
00057 ImageStreamDriver operator=(const ImageStreamDriver&);
00058 };
00059
00060
00061
00062
00063
00064
00065 #endif