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 #include "Shared/ProjectInterface.h"
00007
00008
00009 class ImageStreamDriver : public DataStreamDriver {
00010 public:
00011 explicit ImageStreamDriver(const std::string& name)
00012 : DeviceDriver(autoRegisterDriver,name), DataStreamDriver(autoRegisterDriver,name), format(FORMAT_JPEG,formatNames), payloadSize(0), sid(ProjectInterface::visRawCameraSID)
00013 {
00014 addEntry("Format",format,"The type of format to expect from the comm port.\n"
00015 "'YUV' expects interleaved components 'CameraResolutionX' wide and 'CameraResolutionY' high\n"
00016 "(defined in target's RobotInfo namespace)");
00017 }
00018
00019 virtual std::string getClassName() const { return autoRegisterDriver; }
00020
00021 virtual void getImageSources(std::map<std::string,DataSource*>& sources) {
00022 sources.clear();
00023 sources["Camera"]=this;
00024 }
00025
00026 virtual void plistValueChanged(const plist::PrimitiveBase& pl);
00027
00028
00029 enum format_t {
00030 FORMAT_YUV=0,
00031 FORMAT_PNG,
00032 FORMAT_JPEG,
00033 FORMAT_TEKKOTSU
00034 };
00035
00036 static const size_t NUM_FORMATS = 4;
00037
00038 static const char * formatNames[NUM_FORMATS+1];
00039
00040
00041
00042 plist::NamedEnumeration<format_t> format;
00043
00044 protected:
00045 virtual bool readData(std::istream& is);
00046 RCRegion * readImage(std::istream& is);
00047 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);
00048
00049 virtual void connect(CommPort* comm);
00050 virtual void disconnect(CommPort* comm);
00051
00052 void setSID(unsigned short imageSID) {this->sid = imageSID;}
00053
00054 size_t payloadSize;
00055 unsigned short sid;
00056
00057 private:
00058
00059 static const std::string autoRegisterDriver;
00060 ImageStreamDriver(const ImageStreamDriver&);
00061 ImageStreamDriver operator=(const ImageStreamDriver&);
00062 };
00063
00064
00065
00066
00067
00068
00069 #endif