Fawkes API  Fawkes Development Version
roi.h
1 
2 /***************************************************************************
3  * roi.h - Header for Region Of Interest (ROI) representation
4  *
5  * Generated: Tue Mai 03 19:46:44 2005
6  * Copyright 2005-2007 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __FIREVISION_FVUTILS_ROI_H_
25 #define __FIREVISION_FVUTILS_ROI_H_
26 
27 #include <fvutils/base/types.h>
28 
29 namespace firevision {
30 #if 0 /* just to make Emacs auto-indent happy */
31 }
32 #endif
33 
34 /* The values of this enum-type have to be indexed subsequently,
35  beginning with 0. The last value has to be "H_SIZE = ...".
36  You may add further values at the end (but before H_SIZE!)
37  just continue the indexing properly.
38  NOTE: The indexing must be in correct order wrt the histograms
39  used in "genlut"
40  Do NOT change the order as this may invalidate already created
41  color maps.
42  */
43 /** Hint about object. */
44 typedef enum {
45  H_BALL = 0, /**< ball */
46  H_BACKGROUND = 1, /**< background */
47  H_ROBOT = 2, /**< robot */
48  H_FIELD = 3, /**< field */
49  H_GOAL_YELLOW = 4, /**< yellow goal */
50  H_GOAL_BLUE = 5, /**< blue goal */
51  H_LINE = 6, /**< line */
52  H_UNKNOWN = 7, /**< unknown */
53  H_ROBOT_OPP = 8, /**< opponents robot */
54  H_SIZE /**< size of enum (Has to be the last entry) */
55 } hint_t;
56 
57 
58 class ROI {
59  public:
60 
61  ROI();
62  ROI(const ROI &roi);
63  ROI(const ROI *roi);
64  ROI(unsigned int start_x, unsigned int start_y,
65  unsigned int width, unsigned int height,
66  unsigned int image_width, unsigned int image_height);
67 
68  void set_start(fawkes::point_t p);
69  void set_start(unsigned int x, unsigned int y);
70 
71  void set_width(unsigned int width);
72  unsigned int get_width() const;
73 
74  void set_height(unsigned int height);
75  unsigned int get_height() const;
76 
77  void set_image_width(unsigned int image_width);
78  unsigned int get_image_width() const;
79 
80  void set_image_height(unsigned int image_height);
81  unsigned int get_image_height() const;
82 
83  void set_line_step(unsigned int step);
84  unsigned int get_line_step() const;
85 
86  void set_pixel_step(unsigned int step);
87  unsigned int get_pixel_step() const;
88 
89  unsigned int get_hint() const;
90  void set_hint(unsigned int);
91 
92  bool contains(unsigned int x, unsigned int y);
93 
94  bool neighbours(unsigned int x, unsigned int y, unsigned int margin) const;
95  bool neighbours(ROI *roi, unsigned int margin) const;
96 
97  void extend(unsigned int x, unsigned int y);
98  ROI& operator+=(ROI &roi);
99  void grow(unsigned int margin);
100 
101 
102  bool operator<(const ROI &roi) const;
103  bool operator>(const ROI &roi) const;
104  bool operator==(const ROI &roi) const;
105  bool operator!=(const ROI &roi) const;
106  ROI& operator=(const ROI &roi);
107 
108  unsigned int get_num_hint_points() const;
109 
110 
111  unsigned char* get_roi_buffer_start(unsigned char *buffer) const;
112 
113  static ROI * full_image(unsigned int width, unsigned int height);
114 
115 
116  public: // Public for quick access
117  /** ROI start */
119  /** ROI width */
120  unsigned int width;
121  /** ROI height */
122  unsigned int height;
123  /** width of image that contains this ROI */
124  unsigned int image_width;
125  /** height of image that contains this ROI */
126  unsigned int image_height;
127  /** line step */
128  unsigned int line_step;
129  /** pixel step */
130  unsigned int pixel_step;
131  /** ROI hint */
132  unsigned int hint;
133 
134  /** ROI primary color */
135  color_t color;
136 
137  /** Minimum estimate of points in ROI that are attributed to the ROI hint */
138  unsigned int num_hint_points;
139 
140  private:
141  static ROI *roi_full_image;
142 
143 };
144 
145 } // end namespace firevision
146 
147 #endif
fawkes::point_t start
ROI start.
Definition: roi.h:118
unsigned int width
ROI width.
Definition: roi.h:120
Region of interest.
Definition: roi.h:58
unsigned int image_width
width of image that contains this ROI
Definition: roi.h:124
Point with cartesian coordinates as unsigned integers.
Definition: types.h:34
unsigned int image_height
height of image that contains this ROI
Definition: roi.h:126
unsigned int hint
ROI hint.
Definition: roi.h:132
unsigned int height
ROI height.
Definition: roi.h:122
unsigned int line_step
line step
Definition: roi.h:128
unsigned int num_hint_points
Minimum estimate of points in ROI that are attributed to the ROI hint.
Definition: roi.h:138
unsigned int pixel_step
pixel step
Definition: roi.h:130
color_t color
ROI primary color.
Definition: roi.h:135