Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
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 class RLEGenerator;
00010 
00011 //! Connects regions of CMVision format runs in RLEGenerator
00012 /*! Uses the CMVision library for main processing.
00013  *
00014  *  getImage() will return an array of RegionGenerator::region_stats -
00015  *  one entry per color.  This will give you some statistics on colors
00016  *  present, as well as the head of a linked list through regions of
00017  *  each color in the image.
00018  *  
00019  *  Uses fields in the RLEGenerator's runs to store region
00020  *  information.  This means we don't have to make an extra copy of
00021  *  the data, but unfortunately also means these two stages are
00022  *  tightly coupled...
00023  *
00024  *  Similarly, this also accesses the color information of the runs,
00025  *  so the events received must be a SegmentedColorFilterBankEvents so
00026  *  that it can interpret the color information.  Some statistical
00027  *  information will then be stored in the color struct to report the
00028  *  min region area, max region area, and number of regions.
00029  */
00030 class RegionGenerator : public FilterBankGenerator {
00031 public:
00032   typedef CMVision::region region; //!< using the CMVision library's region information
00033   typedef CMVision::color_class_state region_stats; //!< using the CMVision library's color struct to store the region info
00034   
00035   //! constructor
00036   RegionGenerator(unsigned int mysid, RLEGenerator* rleg, EventBase::EventTypeID_t tid);
00037   
00038   //! destructor
00039   virtual ~RegionGenerator() {
00040     freeCaches();
00041     destruct();
00042   }
00043 
00044   static std::string getClassDescription() { return "Connects runs in an RLE compressed image into regions"; }
00045 
00046   virtual void freeCaches();
00047 
00048   //! see class notes above for what data this can handle
00049   virtual void doEvent();
00050 
00051   virtual unsigned int getBinSize() const;
00052   virtual unsigned int loadBuffer(const char buf[], unsigned int len, const char* filename=NULL);
00053   virtual unsigned int saveBuffer(char buf[], unsigned int len) const;
00054 
00055   virtual size_t getImageSize(unsigned int /*layer*/, unsigned int /*chan*/) const { return sizeof(region_stats); }
00056   
00057 protected:
00058   typedef SegmentedColorFilterBankEvent::color_class_state color_class_state; //!< use the same color info as SegmentedColorFilterBankEvent (since that's what's supplying the color info)
00059   static const unsigned int MAX_REGIONS=640*480/16;  //!< maximum number of regions, value is from historical Vision sources
00060 
00061   virtual void setNumImages(unsigned int nLayers, unsigned int nChannels);
00062   virtual unsigned char * createImageCache(unsigned int layer, unsigned int chan) const;
00063   virtual void calcImage(unsigned int layer, unsigned int chan);
00064   virtual void destruct();
00065 
00066   unsigned int srcNumColors; //!< number of colors available (from src->src, which should be SegmentedColorGenerator...)
00067   const color_class_state * srcColors; //!< colors information (from src->src, which should be SegmentedColorGenerator...)
00068   region *** regions; //!< data storage for region information
00069 
00070 private:
00071   RegionGenerator(const RegionGenerator& fbk); //!< don't call
00072   const RegionGenerator& operator=(const RegionGenerator& fbk); //!< don't call
00073 };
00074 
00075 /*! @file 
00076  * @brief Describes RegionGenerator, which connects regions of CMVision format runs in RLEGenerator
00077  * @author alokl (Creator)
00078  * @author ejt (reorganized)
00079  */
00080 
00081 #endif

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