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 (YVUYVUYVU... instead of YYY...UUU...VVV...)
00008 /*! @note That's not a typo - the byte ordering is YVU, @e not YUV
00009  *
00010  *  Sorry about the misleading name... This @e takes filter banks
00011  *  containing YUV information, however.  The main reason for this
00012  *  class is to interleave the image in order to pass it to the jpeg
00013  *  compression routines.  JPEG expect YCbCr, which corresponds to YVU
00014  *  order.
00015  *
00016  *  Also, I should point out that mathematically, V!=Cb, and U!=Cr,
00017  *  but they do carry the same information.  It's just a matter of
00018  *  scaling and offset.  These comments use the "Y", "U", and "V"
00019  *  labels loosely.
00020  *
00021  *  There's only one channel, which holds the interleaved data.  The
00022  *  increment is set to 3, but if you want to access each component in
00023  *  order, just use 1 instead (as you would expect hopefully, since
00024  *  that's the whole point of this class)
00025  *  
00026  *  The generated events use 0 for their event source IDs.  The row
00027  *  skip is always 0, and the row stride is always width*3.  But it
00028  *  would be better to use the proper accessor functions to be more
00029  *  general.
00030  *
00031  *  should receive FilterBankEvents from any standard format FilterBankGenerator (like RawCameraGenerator)
00032  *
00033  *  @see FilterBankGenerator for information on serialization format
00034  */
00035 class InterleavedYUVGenerator : public FilterBankGenerator {
00036 public:
00037   //! constructor
00038   InterleavedYUVGenerator(unsigned int mysid, FilterBankGenerator* fbg, EventBase::EventTypeID_t tid);
00039   //! constructor, you can pass which channels to interleave
00040   InterleavedYUVGenerator(unsigned int mysid, unsigned int syc, unsigned int suc, unsigned int svc, FilterBankGenerator* fbg, EventBase::EventTypeID_t tid);
00041 
00042   //! destructor
00043   virtual ~InterleavedYUVGenerator() {
00044     freeCaches();
00045     destruct();
00046   }
00047 
00048   static const unsigned int CHAN_YUV=0; //!< so you can refer to the YUV channel symbolically.
00049 
00050   static std::string getClassDescription() { return "Converts a FilterBankGenerator's data into interleaved format"; }
00051 
00052   //! should receive FilterBankEvents from any standard format FilterBankGenerator (like RawCameraGenerator)
00053   virtual void processEvent(const EventBase& event);
00054   
00055   virtual unsigned int getBinSize() const;
00056 
00057   virtual unsigned int LoadBuffer(const char buf[], unsigned int len);
00058 
00059   virtual unsigned int SaveBuffer(char buf[], unsigned int len) const;
00060 
00061   virtual void freeCaches();
00062   virtual void invalidateCaches();
00063 
00064 protected:
00065   virtual void setNumImages(unsigned int nLayers, unsigned int nChannels);
00066   virtual void setDimensions(); //!< resets stride parameter (to correspond to width*3 from FilterBankGenerator::setDimensions())
00067   virtual void destruct();
00068   virtual unsigned char * createImageCache(unsigned int layer, unsigned int chan) const;
00069   virtual void calcImage(unsigned int layer, unsigned int chan);
00070 
00071   unsigned int srcYChan; //!< the channel of the source's Y channel
00072   unsigned int srcUChan; //!< the channel of the source's U channel
00073   unsigned int srcVChan; //!< the channel of the source's V channel
00074   
00075   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
00076 
00077 private:
00078   InterleavedYUVGenerator(const InterleavedYUVGenerator& fbk); //!< don't call
00079   const InterleavedYUVGenerator& operator=(const InterleavedYUVGenerator& fbk); //!< don't call
00080 };
00081 
00082 /*! @file 
00083  * @brief Describes InterleavedYUVGenerator, which generates FilterBankEvents containing raw camera images with interleaved pixels (YUVYUVYUV... instead of YYY...UUU...VVV...)
00084  * @author ejt (Creator)
00085  *
00086  * $Author: ejt $
00087  * $Name: tekkotsu-2_4_1 $
00088  * $Revision: 1.14 $
00089  * $State: Exp $
00090  * $Date: 2005/06/13 18:03:15 $
00091  */
00092 
00093 #endif

Tekkotsu v2.4.1
Generated Tue Aug 16 16:32:47 2005 by Doxygen 1.4.4