Homepage Demos Overview Downloads Tutorials 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 #include <ext/hash_map>
00008 
00009 //! This event provides some additional color information over its superclass for image banks made up of indexed colors
00010 /*! The color information is stored using the CMVision library's data structures
00011  *
00012  *  Don't bother trying to access the region information which is also
00013  *  held in the color_class_state structures.  The RegionGenerator,
00014  *  doesn't fill in the global color information because each layer
00015  *  and channel is going to need its own region processing, so a
00016  *  single global structure only makes sense for the colors.
00017  */
00018 class SegmentedColorFilterBankEvent : public FilterBankEvent {
00019 public:
00020   typedef CMVision::color_class_state color_class_state; //!< use CMVision's color structure
00021   typedef __gnu_cxx::hash_map<const char*, unsigned int, __gnu_cxx::hash<const char*>, hashcmp_eqstr> hashmap; //!< a shorthand for the hash structure that CMVision expects for the color lookups
00022 
00023   //! constructor, to be used when first segmented, later stages should use the other constructor
00024   SegmentedColorFilterBankEvent(FilterBankGenerator* creator,EventBase::EventGeneratorID_t gid,unsigned int sid, FilterBankGenerator* segColorSrc, unsigned int nColors, color_class_state * colorInfos, const hashmap * clrNames)
00025     : FilterBankEvent(creator,gid,sid), segsrc(segColorSrc), numColors(nColors), colors(colorInfos), colorNames(clrNames)
00026   {}
00027 
00028   //! constructor, allows you to pass along color information to later stages
00029   SegmentedColorFilterBankEvent(FilterBankGenerator* creator,EventBase::EventGeneratorID_t gid,unsigned int sid, const SegmentedColorFilterBankEvent& segevt )
00030     : FilterBankEvent(creator,gid,sid), segsrc(segevt.segsrc), numColors(segevt.numColors), colors(segevt.colors), colorNames(segevt.colorNames)
00031   {}
00032 
00033   //! Gives access to underlying generator
00034   inline FilterBankGenerator* getSegmentedColorSource() const { return segsrc; }
00035 
00036   //! returns the number of different colors available
00037   inline unsigned int getNumColors() const { return numColors; }
00038 
00039   //! gives direct access to the color information
00040   inline color_class_state * getColors() const { return colors; }
00041 
00042   //! gives direct access to the color information
00043   inline color_class_state& getColor(unsigned int i) const { return colors[i]; }
00044 
00045   //! returns index of color corresponding to a string (uses a fast hash lookup)
00046   inline unsigned int getColorIndex(const char * name) const {
00047     hashmap::const_iterator i;
00048     i=colorNames->find(name);
00049     return (i==colorNames->end())?-1U:i->second;
00050   }
00051   
00052   //! returns index of color corresponding to a string (uses a fast hash lookup)
00053   inline unsigned int getColorIndex(const std::string& name) const { return getColorIndex(name.c_str()); }
00054   
00055 protected:
00056   //! pointer to generator which did the segmentation and therefore holds the color information
00057   FilterBankGenerator* segsrc;
00058   const unsigned int numColors; //!< number of available colors
00059   color_class_state * const colors; //!< array of available colors
00060   const hashmap * const colorNames; //!< hash map to look up index from name
00061 
00062 private:
00063   SegmentedColorFilterBankEvent(const SegmentedColorFilterBankEvent& fbk); //!< don't call
00064   const SegmentedColorFilterBankEvent& operator=(const SegmentedColorFilterBankEvent& fbk); //!< don't call
00065 };
00066 
00067 /*! @file 
00068  * @brief Defines SegmentedColorFilterBankEvent, an event provides some additional color information over its superclass for image banks made up of indexed colors
00069  * @author ejt (Creator)
00070  *
00071  * $Author: ejt $
00072  * $Name: tekkotsu-2_2_2 $
00073  * $Revision: 1.2 $
00074  * $State: Exp $
00075  * $Date: 2004/01/18 10:16:57 $
00076  */
00077 
00078 #endif

Tekkotsu v2.2.2
Generated Tue Jan 4 15:43:15 2005 by Doxygen 1.4.0