BufferedImageGenerator.h
Go to the documentation of this file.00001
00002 #ifndef INCLUDED_BufferedImageGenerator_h_
00003 #define INCLUDED_BufferedImageGenerator_h_
00004
00005 #include "FilterBankGenerator.h"
00006 #include "RawCameraGenerator.h"
00007
00008
00009 class BufferedImageGenerator : public FilterBankGenerator {
00010 public:
00011
00012 struct ImageSource {
00013
00014 ImageSource() : width(0), height(0), channels(0), frameIndex(0), layer(0), img(NULL) {}
00015
00016 ImageSource(const ImageSource& src) : width(src.width), height(src.height), channels(src.channels), frameIndex(src.frameIndex), layer(src.layer), img(src.img) {}
00017
00018 ImageSource& operator=(const ImageSource& src) { width=src.width; height=src.height; channels=src.channels; frameIndex=src.frameIndex; layer=src.layer; img=src.img; return *this; }
00019 unsigned int width;
00020 unsigned int height;
00021 unsigned int channels;
00022 unsigned int frameIndex;
00023
00024
00025
00026
00027 unsigned int layer;
00028
00029
00030
00031 unsigned char * img;
00032 };
00033
00034
00035 BufferedImageGenerator(const std::string& name,EventBase::EventGeneratorID_t mgid, unsigned int msid, unsigned int nLayers, EventBase::EventGeneratorID_t srcgid, unsigned int srcsid)
00036 : FilterBankGenerator(name,mgid,msid,srcgid,srcsid), imgsrc(), isAllocated(NULL)
00037 {
00038
00039
00040
00041
00042
00043 unsetAutoListen();
00044
00045 setNumImages(nLayers,RawCameraGenerator::NUM_CHANNELS);
00046 }
00047
00048 virtual ~BufferedImageGenerator() { destruct(); }
00049
00050
00051 virtual void doStart() { FilterBankGenerator::doStart(); addSrcListener(); }
00052
00053 virtual void doEvent();
00054
00055 virtual unsigned int getBinSize() const;
00056
00057 virtual unsigned int loadBuffer(const char buf[], unsigned int len, const char* filename=NULL);
00058
00059 virtual unsigned int saveBuffer(char buf[], unsigned int len) const;
00060
00061 virtual unsigned int saveFileStream(FILE* f) const;
00062
00063 virtual void freeCaches();
00064 virtual void invalidateCaches();
00065
00066 protected:
00067 virtual unsigned char * createImageCache(unsigned int layer, unsigned int channel) const;
00068 virtual void calcImage(unsigned int layer, unsigned int channel) ;
00069 virtual void setDimensions();
00070 virtual void destruct();
00071 virtual void setNumImages(unsigned int nLayers, unsigned int nChannels);
00072
00073
00074
00075 virtual void upsampleImage(unsigned int srcLayer, unsigned int chan, unsigned int destLayer);
00076
00077 virtual void downsampleImage(unsigned int destLayer, unsigned int chan);
00078
00079 virtual void calcDx(unsigned int layer, unsigned int srcChan=RawCameraGenerator::CHAN_Y, unsigned int dstChan=RawCameraGenerator::CHAN_Y_DX);
00080
00081 virtual void calcDy(unsigned int layer, unsigned int srcChan=RawCameraGenerator::CHAN_Y, unsigned int dstChan=RawCameraGenerator::CHAN_Y_DY);
00082
00083 virtual void calcDxDy(unsigned int layer);
00084
00085 ImageSource imgsrc;
00086 bool ** isAllocated;
00087
00088 private:
00089 BufferedImageGenerator(const BufferedImageGenerator&);
00090 BufferedImageGenerator& operator=(const BufferedImageGenerator&);
00091 };
00092
00093
00094 inline std::istream& operator>>(std::istream& s, BufferedImageGenerator::ImageSource& i) { void * x; return s>>x; }
00095
00096 inline std::ostream& operator<<(std::ostream& s, const BufferedImageGenerator::ImageSource& i) { return s << &i; }
00097
00098
00099
00100
00101
00102
00103 #endif