Homepage Demos Overview Downloads Tutorials Reference
Credits

RegionGenerator.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_RegionGenerator_h_
00003 #define INCLUDED_RegionGenerator_h_
00004 
00005 #include "Vision/FilterBankGenerator.h"
00006 #include "Events/SegmentedColorFilterBankEvent.h"
00007 #include "Vision/cmvision.h"
00008 
00009 //! Connects regions of CMVision format runs in RLEGenerator
00010 /*! Uses the CMVision library for main processing.
00011  *  
00012  *  Uses fields in the RLEGenerator's runs to store region
00013  *  information.  This means we don't have to make an extra copy of
00014  *  the data, but unfortunately also means these two stages are
00015  *  tightly coupled...
00016  *
00017  *  Similarly, this also accesses the color information of the runs,
00018  *  so the events received must be a SegmentedColorFilterBankEvents so
00019  *  that it can interpret the color information.  Some statistical
00020  *  information will then be stored in the color struct to report the
00021  *  min region area, max region area, and number of regions.
00022  */
00023 class RegionGenerator : public FilterBankGenerator {
00024 public:
00025   typedef CMVision::region region; //!< using the CMVision library's region information
00026   typedef CMVision::color_class_state region_stats; //!< using the CMVision library's color struct to store the region info
00027   
00028   //! constructor
00029   RegionGenerator(EventBase::EventGeneratorID_t gid, unsigned int sid, unsigned int mysid);
00030   //! destructor
00031   virtual ~RegionGenerator();
00032 
00033   static std::string getClassDescription() { return "Connects runs in an RLE compressed image into regions"; }
00034 
00035   virtual void freeCaches();
00036 
00037   //! see class notes above for what data this can handle
00038   virtual void processEvent(const EventBase& event);
00039 
00040   virtual unsigned int getBinSize() const;
00041   virtual unsigned int LoadBuffer(const char buf[], unsigned int len);
00042   virtual unsigned int SaveBuffer(char buf[], unsigned int len) const;
00043 
00044   //! returns the FilterBankGenerator this is receiving events from
00045   virtual const FilterBankGenerator * getSourceGenerator() const { return src; }
00046 
00047 protected:
00048   typedef SegmentedColorFilterBankEvent::color_class_state color_class_state; //!< use the same color info as SegmentedColorFilterBankEvent (since that's what's supplying the color info)
00049   static const unsigned int MAX_REGIONS=176*144/16;  //!< maximum number of regions, value is from historical Vision sources
00050 
00051   virtual void setDimensions(); //!< resets the width, height, skip and stride parameters
00052   virtual void setNumImages(unsigned int nLayers, unsigned int nChannels);
00053   virtual unsigned char * createImageCache(unsigned int layer, unsigned int chan) const;
00054   virtual void calcImage(unsigned int layer, unsigned int chan) const;
00055   virtual void destruct();
00056 
00057   const FilterBankGenerator * src; //!< the generator of the last FilterBankEvent received
00058   
00059   unsigned int srcNumColors; //!< number of colors available (from src->src, which should be SegmentedColorGenerator...)
00060   color_class_state * srcColors; //!< colors information (from src->src, which should be SegmentedColorGenerator...)
00061   region *** regions; //!< data storage for region information
00062 
00063 private:
00064   RegionGenerator(const RegionGenerator& fbk); //!< don't call
00065   const RegionGenerator& operator=(const RegionGenerator& fbk); //!< don't call
00066 };
00067 
00068 /*! @file 
00069  * @brief Describes RegionGenerator, which connects regions of CMVision format runs in RLEGenerator
00070  * @author alokl (Creator)
00071  * @author ejt (reorganized)
00072  *
00073  * $Author: ejt $
00074  * $Name: tekkotsu-2_0 $
00075  * $Revision: 1.3 $
00076  * $State: Exp $
00077  * $Date: 2004/01/18 10:16:59 $
00078  */
00079 
00080 #endif

Tekkotsu v2.0
Generated Wed Jan 21 03:20:29 2004 by Doxygen 1.3.4