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
void set_start(fawkes::point_t p)
Set upper left corner of ROI.
Definition: roi.cpp:124
unsigned int get_image_height() const
Get full image height.
Definition: roi.cpp:221
void set_height(unsigned int height)
Set height of ROI.
Definition: roi.cpp:167
fawkes::point_t start
ROI start.
Definition: roi.h:118
ROI()
Constructor.
Definition: roi.cpp:51
unsigned int get_line_step() const
Get linestep.
Definition: roi.cpp:244
void grow(unsigned int margin)
Grow this ROI by a given margin.
Definition: roi.cpp:382
unsigned int width
ROI width.
Definition: roi.h:120
ROI & operator+=(ROI &roi)
Merge two ROIs.
Definition: roi.cpp:418
bool neighbours(unsigned int x, unsigned int y, unsigned int margin) const
Check if this ROI neighbours a pixel.
Definition: roi.cpp:326
void set_pixel_step(unsigned int step)
Set pixel step.
Definition: roi.cpp:256
Region of interest.
Definition: roi.h:58
unsigned int get_pixel_step() const
Get pixel step.
Definition: roi.cpp:267
ROI & operator=(const ROI &roi)
Assign the given ROI data to this ROI.
Definition: roi.cpp:495
unsigned int get_width() const
Get width of ROI.
Definition: roi.cpp:157
void set_image_height(unsigned int image_height)
Set full image height Set the height of the image that contains this ROI.
Definition: roi.cpp:210
unsigned char * get_roi_buffer_start(unsigned char *buffer) const
Get ROI buffer start.
Definition: roi.cpp:519
unsigned int image_width
width of image that contains this ROI
Definition: roi.h:124
bool operator==(const ROI &roi) const
Check if this ROI marks the same region for the same object and an image of the same base size and st...
Definition: roi.cpp:461
unsigned int get_num_hint_points() const
Gives an estimate of the number of points in this ROI that are classified to the given hint It is: nu...
Definition: roi.cpp:543
static ROI * full_image(unsigned int width, unsigned int height)
Get full image ROI for given size.
Definition: roi.cpp:560
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
void set_image_width(unsigned int image_width)
Set full image width.
Definition: roi.cpp:188
unsigned int get_hint() const
Get hint.
Definition: roi.cpp:279
bool contains(unsigned int x, unsigned int y)
Check if this ROI contains the given coordinates.
Definition: roi.cpp:302
unsigned int hint
ROI hint.
Definition: roi.h:132
unsigned int height
ROI height.
Definition: roi.h:122
void set_hint(unsigned int)
Set hint.
Definition: roi.cpp:290
bool operator>(const ROI &roi) const
Check if this ROI contains more hint points than the given ROI.
Definition: roi.cpp:448
bool operator!=(const ROI &roi) const
Check if this ROI does not mark the same region for the same object and an image of the same base siz...
Definition: roi.cpp:484
void set_line_step(unsigned int step)
Set linestep.
Definition: roi.cpp:233
unsigned int line_step
line step
Definition: roi.h:128
unsigned int get_height() const
Get height of ROI.
Definition: roi.cpp:177
unsigned int num_hint_points
Minimum estimate of points in ROI that are attributed to the ROI hint.
Definition: roi.h:138
void extend(unsigned int x, unsigned int y)
Extend ROI to include given pixel.
Definition: roi.cpp:366
unsigned int pixel_step
pixel step
Definition: roi.h:130
color_t color
ROI primary color.
Definition: roi.h:135
unsigned int get_image_width() const
Get full image width.
Definition: roi.cpp:199
bool operator<(const ROI &roi) const
Check if this ROI contains less hint points than the given ROI.
Definition: roi.cpp:437
void set_width(unsigned int width)
Set width of ROI.
Definition: roi.cpp:147