roi.h
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
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 typedef enum {
00040 H_BALL = 0,
00041 H_BACKGROUND = 1,
00042 H_ROBOT = 2,
00043 H_FIELD = 3,
00044 H_GOAL_YELLOW = 4,
00045 H_GOAL_BLUE = 5,
00046 H_LINE = 6,
00047 H_UNKNOWN = 7,
00048 H_ROBOT_OPP = 8,
00049 H_SIZE
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:
00112
00113 fawkes::point_t start;
00114
00115 unsigned int width;
00116
00117 unsigned int height;
00118
00119 unsigned int image_width;
00120
00121 unsigned int image_height;
00122
00123 unsigned int line_step;
00124
00125 unsigned int pixel_step;
00126
00127 hint_t hint;
00128
00129
00130 unsigned int num_hint_points;
00131
00132 private:
00133 static ROI *roi_full_image;
00134
00135 };
00136
00137 #endif