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
29namespace firevision {
30
31/* The values of this enum-type have to be indexed subsequently,
32 beginning with 0. The last value has to be "H_SIZE = ...".
33 You may add further values at the end (but before H_SIZE!)
34 just continue the indexing properly.
35 NOTE: The indexing must be in correct order wrt the histograms
36 used in "genlut"
37 Do NOT change the order as this may invalidate already created
38 color maps.
39 */
40/** Hint about object. */
41typedef enum {
42 H_BALL = 0, /**< ball */
43 H_BACKGROUND = 1, /**< background */
44 H_ROBOT = 2, /**< robot */
45 H_FIELD = 3, /**< field */
46 H_GOAL_YELLOW = 4, /**< yellow goal */
47 H_GOAL_BLUE = 5, /**< blue goal */
48 H_LINE = 6, /**< line */
49 H_UNKNOWN = 7, /**< unknown */
50 H_ROBOT_OPP = 8, /**< opponents robot */
51 H_SIZE /**< size of enum (Has to be the last entry) */
52} hint_t;
53
54class ROI
55{
56public:
57 ROI();
58 ROI(const ROI &roi);
59 ROI(const ROI *roi);
60 ROI(unsigned int start_x,
61 unsigned int start_y,
62 unsigned int width,
63 unsigned int height,
64 unsigned int image_width,
65 unsigned int image_height);
66
68 void set_start(unsigned int x, unsigned int y);
69
70 void set_width(unsigned int width);
71 unsigned int get_width() const;
72
73 void set_height(unsigned int height);
74 unsigned int get_height() const;
75
76 void set_image_width(unsigned int image_width);
77 unsigned int get_image_width() const;
78
79 void set_image_height(unsigned int image_height);
80 unsigned int get_image_height() const;
81
82 void set_line_step(unsigned int step);
83 unsigned int get_line_step() const;
84
85 void set_pixel_step(unsigned int step);
86 unsigned int get_pixel_step() const;
87
88 unsigned int get_hint() const;
89 void set_hint(unsigned int);
90
91 bool contains(unsigned int x, unsigned int y);
92 ROI intersect(ROI const &roi) const;
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 bool operator<(const ROI &roi) const;
102 bool operator>(const ROI &roi) const;
103 bool operator==(const ROI &roi) const;
104 bool operator!=(const ROI &roi) const;
105 ROI &operator=(const ROI &roi);
106
107 unsigned int get_num_hint_points() const;
108
109 unsigned char *get_roi_buffer_start(unsigned char *buffer) const;
110
111 static ROI *full_image(unsigned int width, unsigned int height);
112
113public: // Public for quick access
114 /** ROI start */
116 /** ROI width */
117 unsigned int width;
118 /** ROI height */
119 unsigned int height;
120 /** width of image that contains this ROI */
121 unsigned int image_width;
122 /** height of image that contains this ROI */
123 unsigned int image_height;
124 /** line step */
125 unsigned int line_step;
126 /** pixel step */
127 unsigned int pixel_step;
128 /** ROI hint */
129 unsigned int hint;
130
131 /** ROI primary color */
132 color_t color;
133
134 /** Minimum estimate of points in ROI that are attributed to the ROI hint */
135 unsigned int num_hint_points;
136
137private:
138 static ROI *roi_full_image;
139};
140
141} // end namespace firevision
142
143#endif
Region of interest.
Definition: roi.h:55
void set_line_step(unsigned int step)
Set linestep.
Definition: roi.cpp:218
unsigned int height
ROI height.
Definition: roi.h:119
fawkes::upoint_t start
ROI start.
Definition: roi.h:115
unsigned char * get_roi_buffer_start(unsigned char *buffer) const
Get ROI buffer start.
Definition: roi.cpp:526
void set_pixel_step(unsigned int step)
Set pixel step.
Definition: roi.cpp:239
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:476
static ROI * full_image(unsigned int width, unsigned int height)
Get full image ROI for given size.
Definition: roi.cpp:565
bool operator<(const ROI &roi) const
Check if this ROI contains less hint points than the given ROI.
Definition: roi.cpp:454
ROI & operator+=(ROI &roi)
Merge two ROIs.
Definition: roi.cpp:427
unsigned int line_step
line step
Definition: roi.h:125
unsigned int get_line_step() const
Get linestep.
Definition: roi.cpp:228
void set_hint(unsigned int)
Set hint.
Definition: roi.cpp:270
unsigned int width
ROI width.
Definition: roi.h:117
void set_start(fawkes::upoint_t p)
Set upper left corner of ROI.
Definition: roi.cpp:119
void set_image_width(unsigned int image_width)
Set full image width.
Definition: roi.cpp:177
unsigned int get_width() const
Get width of ROI.
Definition: roi.cpp:149
void extend(unsigned int x, unsigned int y)
Extend ROI to include given pixel.
Definition: roi.cpp:369
unsigned int hint
ROI hint.
Definition: roi.h:129
unsigned int get_image_height() const
Get full image height.
Definition: roi.cpp:207
unsigned int image_width
width of image that contains this ROI
Definition: roi.h:121
color_t color
ROI primary color.
Definition: roi.h:132
unsigned int get_hint() const
Get hint.
Definition: roi.cpp:260
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:197
void set_width(unsigned int width)
Set width of ROI.
Definition: roi.cpp:140
void set_height(unsigned int height)
Set height of ROI.
Definition: roi.cpp:158
unsigned int pixel_step
pixel step
Definition: roi.h:127
void grow(unsigned int margin)
Grow this ROI by a given margin.
Definition: roi.cpp:393
unsigned int get_image_width() const
Get full image width.
Definition: roi.cpp:187
ROI intersect(ROI const &roi) const
Intersect this ROI with another.
Definition: roi.cpp:297
bool neighbours(unsigned int x, unsigned int y, unsigned int margin) const
Check if this ROI neighbours a pixel.
Definition: roi.cpp:331
unsigned int get_height() const
Get height of ROI.
Definition: roi.cpp:167
bool operator>(const ROI &roi) const
Check if this ROI contains more hint points than the given ROI.
Definition: roi.cpp:464
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:492
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:549
ROI & operator=(const ROI &roi)
Assign the given ROI data to this ROI.
Definition: roi.cpp:502
unsigned int num_hint_points
Minimum estimate of points in ROI that are attributed to the ROI hint.
Definition: roi.h:135
ROI()
Constructor.
Definition: roi.cpp:47
bool contains(unsigned int x, unsigned int y)
Check if this ROI contains the given coordinates.
Definition: roi.cpp:281
unsigned int get_pixel_step() const
Get pixel step.
Definition: roi.cpp:249
unsigned int image_height
height of image that contains this ROI
Definition: roi.h:123
Point with cartesian coordinates as unsigned integers.
Definition: types.h:35