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