qualifiers.h

00001 /***************************************************************************
00002  *  qualifiers.h - Pixel qualifier
00003  *
00004  *  Created: Mon, 09. Jun 2008 22:54
00005  *  Copyright  2008  Christof Rath <c.rath@student.tugraz.at>
00006  *
00007  ****************************************************************************/
00008
00009 /*  This program is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU Library General Public License for more details.
00018  *
00019  *  Read the full text in the LICENSE.GPL file in the doc directory.
00020  */
00021
00022
00023 #ifndef __FIREVISION_APPS_NAO_LOC_QUALIFIERS_H_
00024 #define __FIREVISION_APPS_NAO_LOC_QUALIFIERS_H_
00025 
00026 #include <fvutils/color/colorspaces.h>
00027 #include <fvutils/base/types.h>
00028
00029 class Qualifier
00030 {
00031  public:
00032   Qualifier();
00033   virtual ~Qualifier();
00034 
00035   /** Getter.
00036    * @param pixel the pixel of interest
00037    * @return a corresponding int value
00038    */
00039   virtual int   get(fawkes::point_t pixel) = 0;
00040
00041   virtual unsigned char* get_buffer();
00042   virtual void set_buffer(unsigned char* buffer, unsigned int width = 0,
00043                           unsigned int height = 0);
00044
00045   virtual colorspace_t get_colorspace();
00046   virtual void set_colorspace(colorspace_t colorspace);
00047
00048
00049  protected:
00050   Qualifier(unsigned char* buffer, unsigned int width,
00051             unsigned int height, colorspace_t colorspace);
00052 
00053   /** Image buffer */
00054   unsigned char* buffer_;
00055 
00056   /** Width of the buffer */
00057   unsigned int width_;
00058   /** Height of the buffer */
00059   unsigned int height_;
00060 
00061   /** Size of the buffer */
00062   unsigned int size_;
00063 
00064   /** Colorspace of the buffer */
00065   colorspace_t colorspace_;
00066 };
00067
00068
00069 class LumaQualifier: public Qualifier
00070 {
00071  public:
00072   LumaQualifier() {};
00073   LumaQualifier(unsigned char* buffer, unsigned int width,
00074                 unsigned int height, colorspace_t colorspace);
00075   virtual ~LumaQualifier() {};
00076
00077   virtual int   get(fawkes::point_t pixel);
00078 };
00079
00080
00081 class SkyblueQualifier: public Qualifier
00082 {
00083  public:
00084   SkyblueQualifier() {};
00085   SkyblueQualifier(unsigned char* buffer, unsigned int width,
00086                    unsigned int height, colorspace_t colorspace);
00087   virtual ~SkyblueQualifier() {};
00088
00089   virtual int   get(fawkes::point_t pixel);
00090
00091
00092  private:
00093   static const unsigned int threshold_ = 128;
00094 };
00095
00096
00097 class YellowQualifier: public Qualifier
00098 {
00099  public:
00100   YellowQualifier() {};
00101   YellowQualifier(unsigned char* buffer, unsigned int width,
00102                   unsigned int height, colorspace_t colorspace);
00103   virtual ~YellowQualifier() {};
00104
00105   virtual int   get(fawkes::point_t pixel);
00106
00107
00108  private:
00109   static const unsigned int threshold_ = 100;
00110 };
00111
00112 #endif // __FIREVISION_APPS_NAO_LOC_QUALIFIERS_H_