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 class ColorObjectMap
00034 {
00035 public:
00036   ~ColorObjectMap();
00037   static const ColorObjectMap& get_instance() { return *__singleton; }
00038   static YUV_t get_color(color_t color);
00039
00040   const color_t& get(hint_t hint) const
00041   { return __color_for_hint.find(hint) != __color_for_hint.end() ? __color_for_hint.find(hint)->second : __c_other; }
00042   const hint_t get(color_t color) const
00043   { return __hint_for_color.find(color) != __hint_for_color.end() ? __hint_for_color.find(color)->second : __h_unknown; }
00044
00045   private:
00046     ColorObjectMap();
00047     void set_mapping(hint_t roi, color_t color);
00048
00049     static ColorObjectMap    *__singleton;
00050     std::map<hint_t, color_t> __color_for_hint;
00051     std::map<color_t, hint_t> __hint_for_color;
00052     color_t                   __c_other;
00053     hint_t                    __h_unknown;
00054   };
00055
00056 #endif // __FIREVISION_MODELS_COLOR_COLOR_MAPPING_H__