Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

InterleavedYUVGenerator.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_InterleavedYUVGenerator_h_
00003 #define INCLUDED_InterleavedYUVGenerator_h_
00004 
00005 #include "Vision/FilterBankGenerator.h"
00006 
00007 //! Generates FilterBankEvents containing raw camera images with interleaved pixels (YUVYUVYUV... instead of YYY...UUU...VVV...)
00008 /*!
00009  *  There's only one channel, which holds the interleaved data.  The
00010  *  increment is set to 3, but if you want to access each component in
00011  *  order, just use 1 instead (as you would expect hopefully, since
00012  *  the very specific memory layout is the whole point of this class)
00013  *  
00014  *  The row
00015  *  skip is always 0, and the row stride is always width*3.  But it
00016  *  would be better to use the proper accessor functions to be more
00017  *  general.
00018  *
00019  *  should receive FilterBankEvents from any standard format FilterBankGenerator (like RawCameraGenerator)
00020  *
00021  *  @see FilterBankGenerator for information on serialization format
00022  */
00023 class InterleavedYUVGenerator : public FilterBankGenerator {
00024 public:
00025   //! constructor
00026   InterleavedYUVGenerator(unsigned int mysid, FilterBankGenerator* fbg, EventBase::EventTypeID_t tid);
00027   //! constructor, you can pass which channels to interleave
00028   InterleavedYUVGenerator(unsigned int mysid, unsigned int syc, unsigned int suc, unsigned int svc, FilterBankGenerator* fbg, EventBase::EventTypeID_t tid);
00029 
00030   //! destructor
00031   virtual ~InterleavedYUVGenerator() {
00032     freeCaches();
00033     destruct();
00034   }
00035 
00036   static const unsigned int CHAN_YUV=0; //!< so you can refer to the YUV channel symbolically. (as opposed to others that might be added?)
00037 
00038   static std::string getClassDescription() { return "Converts a FilterBankGenerator's data into interleaved format"; }
00039 
00040   //! should receive FilterBankEvents from any standard format FilterBankGenerator (like RawCameraGenerator)
00041   virtual void doEvent();
00042   
00043   virtual unsigned int getBinSize() const;
00044 
00045   virtual unsigned int loadBuffer(const char buf[], unsigned int len, const char* filename=NULL);
00046 
00047   virtual unsigned int saveBuffer(char buf[], unsigned int len) const;
00048 
00049   virtual void freeCaches();
00050   virtual void invalidateCaches();
00051 
00052 protected:
00053   virtual void setNumImages(unsigned int nLayers, unsigned int nChannels);
00054   virtual void setDimensions(); //!< resets stride parameter (to correspond to width*3 from FilterBankGenerator::setDimensions())
00055   virtual void destruct();
00056   virtual unsigned char * createImageCache(unsigned int layer, unsigned int chan) const;
00057   virtual void calcImage(unsigned int layer, unsigned int chan);
00058 
00059   unsigned int srcYChan; //!< the channel of the source's Y channel
00060   unsigned int srcUChan; //!< the channel of the source's U channel
00061   unsigned int srcVChan; //!< the channel of the source's V channel
00062   
00063   bool ** isAllocated; //!< flag for each image, set to true if the corresponding value in #images will need to be freed, or false if it's a passthrough from the previous stage
00064 
00065 private:
00066   InterleavedYUVGenerator(const InterleavedYUVGenerator& fbk); //!< don't call
00067   const InterleavedYUVGenerator& operator=(const InterleavedYUVGenerator& fbk); //!< don't call
00068 };
00069 
00070 /*! @file 
00071  * @brief Describes InterleavedYUVGenerator, which generates FilterBankEvents containing raw camera images with interleaved pixels (YUVYUVYUV... instead of YYY...UUU...VVV...)
00072  * @author ejt (Creator)
00073  */
00074 
00075 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:42 2016 by Doxygen 1.6.3