00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
00031 }
00032 #endif
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 typedef enum {
00045 H_BALL = 0,
00046 H_BACKGROUND = 1,
00047 H_ROBOT = 2,
00048 H_FIELD = 3,
00049 H_GOAL_YELLOW = 4,
00050 H_GOAL_BLUE = 5,
00051 H_LINE = 6,
00052 H_UNKNOWN = 7,
00053 H_ROBOT_OPP = 8,
00054 H_SIZE
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:
00117
00118 fawkes::point_t start;
00119
00120 unsigned int width;
00121
00122 unsigned int height;
00123
00124 unsigned int image_width;
00125
00126 unsigned int image_height;
00127
00128 unsigned int line_step;
00129
00130 unsigned int pixel_step;
00131
00132 hint_t hint;
00133
00134
00135 unsigned int num_hint_points;
00136
00137 private:
00138 static ROI *roi_full_image;
00139
00140 };
00141
00142 }
00143
00144 #endif