Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

SegmentedColorFilterBankEvent.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_SegmentedColorFilterBankEvent_h_
00003 #define INCLUDED_SegmentedColorFilterBankEvent_h_
00004 
00005 #include "Events/FilterBankEvent.h"
00006 #include "Vision/cmvision.h"
00007 
00008 //! This event provides some additional color information over its superclass for image banks made up of indexed colors
00009 /*! The color information is stored using the CMVision library's data structures
00010  *
00011  *  Don't bother trying to access the region information which is also
00012  *  held in the color_class_state structures.  The RegionGenerator,
00013  *  doesn't fill in the global color information because each layer
00014  *  and channel is going to need its own region processing, so a
00015  *  single global structure only makes sense for the colors.
00016  */
00017 class SegmentedColorFilterBankEvent : public FilterBankEvent {
00018 public:
00019   typedef CMVision::color_class_state color_class_state; //!< use CMVision's color structure
00020   typedef CMVision::color_name_map color_name_map; //!< shorthand for CMVision's color name lookup data structure
00021 
00022   //! constructor, to be used when first segmented, later stages should use the other constructor
00023   SegmentedColorFilterBankEvent(FilterBankGenerator* creator,EventBase::EventGeneratorID_t gid,size_t sid,EventBase::EventTypeID_t tid, FilterBankGenerator* segColorSrc, unsigned int nColors, color_class_state * colorInfos, const color_name_map * clrNames)
00024     : FilterBankEvent(creator,gid,sid,tid), segsrc(segColorSrc), numColors(nColors), colors(colorInfos), colorNames(clrNames)
00025   {}
00026 
00027   //! constructor, allows you to pass along color information to later stages
00028   SegmentedColorFilterBankEvent(FilterBankGenerator* creator,EventBase::EventGeneratorID_t gid,size_t sid,EventBase::EventTypeID_t tid, const SegmentedColorFilterBankEvent& segevt )
00029     : FilterBankEvent(creator,gid,sid,tid), segsrc(segevt.segsrc), numColors(segevt.numColors), colors(segevt.colors), colorNames(segevt.colorNames)
00030   {}
00031 
00032   //! copy constructor (shallow copy -- the generator shouldn't be going anywhere)
00033   SegmentedColorFilterBankEvent(const SegmentedColorFilterBankEvent& fbk)
00034     : FilterBankEvent(fbk), segsrc(fbk.segsrc), numColors(fbk.numColors),
00035       colors(fbk.colors), colorNames(fbk.colorNames)
00036   {}
00037   
00038   //! assignment operator  (shallow copy -- the generator shouldn't be going anywhere)
00039   const SegmentedColorFilterBankEvent& operator=(const SegmentedColorFilterBankEvent& fbk) {
00040     EventBase::operator=(fbk);
00041     segsrc=fbk.segsrc; numColors=fbk.numColors;
00042     colors=fbk.colors; colorNames=fbk.colorNames;
00043     return *this;
00044   }
00045 
00046   virtual EventBase* clone() const { return new SegmentedColorFilterBankEvent(*this); }
00047 
00048   //don't do this until we actually override the LoadSave interface
00049   //virtual unsigned int getClassTypeID() const { return makeClassTypeID("SFBK"); }
00050 
00051   //! Gives access to underlying generator
00052   inline FilterBankGenerator* getSegmentedColorSource() const { return segsrc; }
00053 
00054   //! returns the number of different colors available
00055   inline unsigned int getNumColors() const { return numColors; }
00056 
00057   //! gives direct access to the color information
00058   inline const color_class_state * getColors() const { return colors; }
00059 
00060   //! gives direct access to the color information
00061   inline const color_class_state& getColor(unsigned int i) const { return colors[i]; }
00062 
00063   //! returns index of color corresponding to a string
00064   inline unsigned int getColorIndex(const char * name) const {
00065     color_name_map::const_iterator i = colorNames->find(name);
00066     return (i==colorNames->end())?-1U:i->second;
00067   }
00068   
00069   //! returns index of color corresponding to a string
00070   inline unsigned int getColorIndex(const std::string& name) const { return getColorIndex(name.c_str()); }
00071   
00072   virtual classTypeID_t getClassTypeID() const { return autoRegisterSegmentedColorFilterBankEvent; }
00073   
00074 protected:
00075   //! pointer to generator which did the segmentation and therefore holds the color information
00076   FilterBankGenerator* segsrc;
00077   unsigned int numColors; //!< number of available colors
00078   const color_class_state * colors; //!< array of available colors
00079   const color_name_map * colorNames; //!< look up index from name
00080 
00081   //! causes class type id to automatically be regsitered with EventBase's FamilyFactory (getTypeRegistry())
00082   /*! This is instantiated in EventBase.cc to save on file bloat */
00083   static const EventBase::classTypeID_t autoRegisterSegmentedColorFilterBankEvent;
00084   
00085   //! default constructor, only intended to be called from the FamilyFactory, followed by a loadXML...
00086   SegmentedColorFilterBankEvent() : FilterBankEvent(), segsrc(NULL), numColors(), colors(), colorNames() {}
00087   friend struct Factory0Arg<EventBase>::Factory<SegmentedColorFilterBankEvent>;
00088 };
00089 
00090 /*! @file 
00091  * @brief Defines SegmentedColorFilterBankEvent, an event provides some additional color information over its superclass for image banks made up of indexed colors
00092  * @author ejt (Creator)
00093  */
00094 
00095 #endif

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