color_object_map.h

00001 
00002 /***************************************************************************
00003  *  color_object_map.h - Mapping between color and roi
00004  *
00005  *  Created: Mon May 16th 2008
00006  *  Copyright  2008 Christof Rath <c.rath@student.tugraz.at>
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #ifndef __FIREVISION_MODELS_COLOR_COLOR_MAPPING_H__
00025 #define __FIREVISION_MODELS_COLOR_COLOR_MAPPING_H__
00026 
00027 #include <fvutils/base/types.h>
00028 #include <fvutils/base/roi.h>
00029 #include <fvutils/color/yuv.h>
00030 
00031 #include <map>
00032 
00033 namespace firevision {
00034 #if 0 /* just to make Emacs auto-indent happy */
00035 }
00036 #endif
00037 
00038 class ColorObjectMap
00039 {
00040  public:
00041   ~ColorObjectMap();
00042   static const ColorObjectMap& get_instance() { return *__singleton; }
00043   static YUV_t get_color(color_t color);
00044 
00045   const color_t& get(hint_t hint) const
00046   { return __color_for_hint.find(hint) != __color_for_hint.end() ? __color_for_hint.find(hint)->second : __c_other; }
00047   const hint_t get(color_t color) const
00048   { return __hint_for_color.find(color) != __hint_for_color.end() ? __hint_for_color.find(color)->second : __h_unknown; }
00049 
00050  private:
00051   ColorObjectMap();
00052   void set_mapping(hint_t roi, color_t color);
00053 
00054   static ColorObjectMap    *__singleton;
00055   std::map<hint_t, color_t> __color_for_hint;
00056   std::map<color_t, hint_t> __hint_for_color;
00057   color_t                   __c_other;
00058   hint_t                    __h_unknown;
00059 };
00060 
00061 } // end namespace firevision
00062 
00063 #endif // __FIREVISION_MODELS_COLOR_COLOR_MAPPING_H__