Fawkes API Fawkes Development Version

roi.h

00001 
00002 /***************************************************************************
00003  *  roi.h - Header for Region Of Interest (ROI) representation
00004  *
00005  *  Generated: Tue Mai 03 19:46:44 2005
00006  *  Copyright  2005-2007  Tim Niemueller [www.niemueller.de]
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_FVUTILS_ROI_H_
00025 #define __FIREVISION_FVUTILS_ROI_H_
00026 
00027 #include <fvutils/base/types.h>
00028 
00029 namespace firevision {
00030 #if 0 /* just to make Emacs auto-indent happy */
00031 }
00032 #endif
00033 
00034 /* The values of this enum-type have to be indexed subsequently,
00035    beginning with 0. The last value has to be "H_SIZE = ...".
00036    You may add further values at the end (but before H_SIZE!)
00037    just continue the indexing properly.
00038    NOTE: The indexing must be in correct order wrt the histograms
00039    used in "genlut"
00040    Do NOT change the order as this may invalidate already created
00041    color maps.
00042  */
00043 /** Hint about object. */
00044 typedef enum {
00045   H_BALL          = 0,  /**< ball */
00046   H_BACKGROUND    = 1,  /**< background */
00047   H_ROBOT         = 2,  /**< robot */
00048   H_FIELD         = 3,  /**< field */
00049   H_GOAL_YELLOW   = 4,  /**< yellow goal */
00050   H_GOAL_BLUE     = 5,  /**< blue goal */
00051   H_LINE          = 6,  /**< line */
00052   H_UNKNOWN       = 7,  /**< unknown */
00053   H_ROBOT_OPP     = 8,  /**< opponents robot */
00054   H_SIZE                /**< size of enum (Has to be the last entry) */
00055 } hint_t;
00056 
00057 
00058 class ROI {
00059  public:
00060 
00061   ROI();
00062   ROI(const ROI &roi);
00063   ROI(const ROI *roi);
00064   ROI(unsigned int start_x, unsigned int start_y,
00065       unsigned int width, unsigned int height,
00066       unsigned int image_width, unsigned int image_height);
00067 
00068   void         set_start(fawkes::point_t p);
00069   void         set_start(unsigned int x, unsigned int y);
00070 
00071   void         set_width(unsigned int width);
00072   unsigned int get_width() const;
00073 
00074   void         set_height(unsigned int height);
00075   unsigned int get_height() const;
00076 
00077   void         set_image_width(unsigned int image_width);
00078   unsigned int get_image_width() const;
00079 
00080   void         set_image_height(unsigned int image_height);
00081   unsigned int get_image_height() const;
00082 
00083   void         set_line_step(unsigned int step);
00084   unsigned int get_line_step() const;
00085 
00086   void         set_pixel_step(unsigned int step);
00087   unsigned int get_pixel_step() const;
00088 
00089   hint_t       get_hint() const;
00090   void         set_hint(hint_t hint);
00091 
00092   bool         contains(unsigned int x, unsigned int y);
00093 
00094   bool         neighbours(unsigned int x, unsigned int y, unsigned int margin) const;
00095   bool         neighbours(ROI *roi, unsigned int margin) const;
00096 
00097   void         extend(unsigned int x, unsigned int y);
00098   ROI&         operator+=(ROI &roi);
00099   void         grow(unsigned int margin);
00100 
00101 
00102   bool         operator<(const ROI &roi) const;
00103   bool         operator>(const ROI &roi) const;
00104   bool         operator==(const ROI &roi) const;
00105   bool         operator!=(const ROI &roi) const;
00106   ROI&         operator=(const ROI &roi);
00107 
00108   unsigned int get_num_hint_points() const;
00109 
00110 
00111   unsigned char*  get_roi_buffer_start(unsigned char *buffer) const;
00112 
00113   static ROI * full_image(unsigned int width, unsigned int height);
00114 
00115 
00116  public: // Public for quick access
00117   /** ROI start */
00118   fawkes::point_t start;
00119   /** ROI width */
00120   unsigned int width;
00121   /** ROI height */
00122   unsigned int height;
00123   /** width of image that contains this ROI */
00124   unsigned int image_width;
00125   /** height of image that contains this ROI */
00126   unsigned int image_height;
00127   /** line step */
00128   unsigned int line_step;
00129   /** pixel step */
00130   unsigned int pixel_step;
00131   /** ROI hint */
00132   hint_t       hint;
00133 
00134   /** Minimum estimate of points in ROI that are attributed to the ROI hint */
00135   unsigned int num_hint_points;
00136 
00137  private:
00138   static ROI  *roi_full_image;
00139 
00140 };
00141 
00142 } // end namespace firevision
00143 
00144 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends