00001 00002 /** 00003 * @file Modules/ImageProcessor/RasterImageProcessor/RFieldSpecialist.h 00004 * 00005 * Declaration of RFieldSpecialist.h 00006 * 00007 * @author <A href="damd@free.fr">DEOM Damien</A> 00008 * 00009 */ 00010 00011 #ifndef RFIELDSPECIALIST_H 00012 #define RFIELDSPECIALIST_H 00013 00014 /** 00015 * @class RFieldSpecialist 00016 * 00017 * This class regognizes lines on the field, and the intersection of them. 00018 * The most important points are shown: corners, goal points ... 00019 */ 00020 00021 #include "RasterSpecialist.h" 00022 #include "RasterStrategy.h" 00023 #include "Modules/ImageProcessor/RasterImageProcessor/REdgeDetection.h" 00024 #include "Modules/ImageProcessor/ImageProcessorTools/SegmentationTools.h" 00025 #include "Tools/Location.h" 00026 00027 using namespace std; 00028 00029 00030 class RFieldSpecialist :public RasterSpecialist { 00031 00032 public: 00033 00034 typedef slist<LinePair2> lstLinePair; 00035 typedef slist<figure> lstFig; 00036 00037 //! The default constructor and destructor 00038 RFieldSpecialist(RasterImageProcessor &processor,RasterStrategy &strategy); 00039 virtual ~RFieldSpecialist(); 00040 00041 //! Returns the id of the specialist 00042 virtual int getType(); 00043 00044 /** 00045 * Clears the buffers of points 00046 * @see lst_pts 00047 * @see segments_img 00048 */ 00049 virtual void init(); 00050 00051 /** 00052 * Function called by a given Strategy class 00053 * Calling it one time stores the given coordinates in a temporar vector 00054 * Calling it a second time creates an horizontal linepair and stores 00055 * it in the linepair buffer 00056 * @see lst_pts 00057 */ 00058 void invokeOnPreScan(int x,int y); 00059 00060 //! unused in this specialist 00061 void invokeOnPostScan(int x, int y); 00062 00063 /** 00064 * Function called in the post scan section of the RDefaultStrategy 00065 * when a line has been recognized 00066 * @param type the type of the line 00067 * @param pt the first oint of the line 00068 * @param id the id of the scan line where the line has been found 00069 * 00070 * The point is then stored in a vector of points 00071 * @see segments_img 00072 */ 00073 void addLinePoint(LinesPercept::LineType type, point & pt, int& id); 00074 00075 /** 00076 * Processing phase of the points 00077 * @see lst_pts 00078 * @see segments_img 00079 */ 00080 void executePostProcessing(); 00081 00082 private: 00083 00084 //! a pointer to the strategy tha scan the image 00085 RasterStrategy *strategy; 00086 00087 //! the scanner for adjusting the incoming point coordinates 00088 REdgeDetection edgeScanner; 00089 00090 /** 00091 * this structure contains important parameters for the line recognition: 00092 * @param min_size minimum number of sub lines required to form a line. 00093 * @param step number of points to junp in order to form a sub line 00094 * @param tol_alpha angular tolerance related to the sub lines (in degrees). 00095 */ 00096 struct processParam { 00097 unsigned int min_size; 00098 unsigned int step_alpha; 00099 unsigned int tol_alpha; 00100 00101 processParam(): min_size(6), step_alpha(5), 00102 tol_alpha(20) {} 00103 }; 00104 00105 //! the default parameter set 00106 processParam* defaultParam; 00107 00108 /** 00109 * List of points stored during the horizontal scan 00110 */ 00111 lstFig lst_pts; 00112 00113 /** 00114 * Temporar points 00115 */ 00116 point temp; 00117 LinesPercept::LineType lineInside; 00118 00119 /** 00120 * id of the incoming line 00121 */ 00122 inline int id(LinesPercept::LineType); 00123 inline LinesPercept::LineType id(int i) ; 00124 00125 /** 00126 * line recognition 00127 * @param inputList input list containing the points to analyse 00128 * @param linePairList the list of recognized lines 00129 * @param param the 3 parameters defined above 00130 * @return a boolean that indicate if a line has been created 00131 */ 00132 bool makeLines(lstFig& inputList, lstLinePair& linePairList, const processParam* param); 00133 00134 /** 00135 * The resulting lines 00136 */ 00137 vector <lstLinePair> vecLines; 00138 00139 /** 00140 * The edges coming from the post scan method 00141 * @see RDefaulstrategy2 00142 */ 00143 vector <lstFig> segments_img; 00144 00145 /** 00146 * fusion spaced lines having the same angle value 00147 */ 00148 void fusionLines(lstLinePair& lst); 00149 00150 /** 00151 * id of the incoming goal line 00152 */ 00153 enum goal_line { 00154 NONE = 0, /*!< No line */ 00155 YELLOW, /*!< Yellow goal line */ 00156 SKYBLUE /*!< Skyblue goal line */ 00157 }; 00158 00159 /** 00160 * Computes the intersction of the lines and shows the result 00161 */ 00162 unsigned int analyzeLines(); 00163 00164 /** 00165 * open challenge related function 00166 * computes the angle of the ramp (must be a red line) and generate 00167 * the corresponding line percept 00168 */ 00169 void checkRamp(lstLinePair &ramp); 00170 00171 /** 00172 * debug related functions 00173 */ 00174 void drawCross(goal_line g, point& v); 00175 void drawCircle(goal_line g, point& v); 00176 void drawLine(goal_line g, LinePair2& lp); 00177 00178 }; 00179 00180 #endif 00181 00182 /* 00183 * Change log : 00184 * 00185 * $Log: RFieldSpecialist.h,v $ 00186 * Revision 1.8 2004/09/09 11:08:04 spranger 00187 * renamed GT2004EdgeDetection to REdgeDetection for consistency 00188 * 00189 * Revision 1.7 2004/09/08 14:39:02 wachter 00190 * - Fixed some doxygen-errors 00191 * 00192 * Revision 1.6 2004/09/07 16:01:15 deom 00193 * Documentation corrected 00194 * 00195 * Revision 1.5 2004/09/06 12:02:26 schmidtb 00196 * commented almost all members, removed warnings in documentation 00197 00198 * did further code clean up 00199 * 00200 * Revision 1.4 2004/09/02 09:31:19 deom 00201 * commented rfieldspecialist 00202 * 00203 * Revision 1.3 2004/09/02 07:59:29 schmidtb 00204 * Added RasterImageProcessor to repository, because we used it for the OpenChallenge. 00205 * 00206 * Revision 1.26 2004/06/04 12:43:05 deom 00207 * optimized 00208 * 00209 * Revision 1.25 2004/06/02 16:03:53 deom 00210 * merged different versions of FieldSpecialist 00211 * 00212 * Revision 1.24 2004/05/27 16:49:47 deom 00213 * new parameter set + some minor changes 00214 * 00215 * Revision 1.23 2004/05/22 19:03:40 deom 00216 * -now recognizes the red line 00217 * -all the data required for the positionning are computed 00218 * 00219 * Revision 1.17 2004/05/22 16:56:39 pg_dade 00220 * -now recognizes the red line 00221 * -all the data required for the positionning are computed 00222 * 00223 * Revision 1.16 2004/04/15 19:08:34 pg_besc 00224 * merged code 00225 * 00226 * Revision 1.20 2004/03/29 15:25:16 deom 00227 * - the basical segmentation tools are now fast completely debbuged. 00228 * - seem to work pretty good now 00229 * - somes parameters need to be tuned 00230 * 00231 * Revision 1.19 2004/03/23 15:50:26 deom 00232 * now uses two scan methods 00233 * 00234 * Revision 1.18 2004/03/21 21:59:06 deom 00235 * The new scan functions intergrated to RfieldSpecialist. The lines recognition works at 90% 00236 * 00237 * Revision 1.17 2004/03/20 10:47:28 roefer 00238 * Don't check in files that do not compile. 00239 * If you declare functions, implement them, too. 00240 * Global functions implemented in header files must be declared inline. 00241 * 00242 * Revision 1.16 2004/03/19 22:06:49 deom 00243 * now based on the segmentationTools class 00244 * 00245 * Revision 1.15 2004/03/15 01:17:36 deom 00246 * debugged, now recognizes all predetermined forms 00247 * 00248 * Revision 1.14 2004/03/14 12:51:58 deom 00249 * added an accurate scan method 00250 * 00251 * Revision 1.13 2004/03/12 14:39:13 deom 00252 * debugged 00253 * 00254 * Revision 1.12 2004/03/12 01:37:58 deom 00255 * added some functions required for the lines analysis 00256 * 00257 * Revision 1.11 2004/03/11 19:21:01 deom 00258 * pursued debugging and parametrisation 00259 * 00260 * Revision 1.10 2004/03/11 12:19:00 deom 00261 * debbuged RFieldspecialist 00262 * 00263 * Revision 1.9 2004/03/01 14:17:25 koh 00264 * added new strategy "RFlexibleStrategy" + new specialist "EnemyOnlySpecialist"; 00265 * changed references to "RDefaultStrategy" to references to "RasterStrategy" in RFieldSpecialist 00266 * added Geometry::Line horizon to "RasterStrategy" 00267 * 00268 * Revision 1.8 2004/03/01 12:14:41 wachter 00269 * Bug commented out. 00270 * 00271 * Revision 1.7 2004/02/29 20:06:16 deom 00272 * detects complex lines ( but need to be debuged) 00273 * 00274 * Revision 1.6 2004/02/22 19:12:54 deom 00275 * now recognize simple lines 00276 * 00277 * Revision 1.4 2004/02/16 05:00:48 deom 00278 * basical version that show edges 00279 * 00280 * Revision 1.3 2003/12/15 13:55:32 schmidtb 00281 * Merged and patched new version of RasterImageProcessor. 00282 * 00283 * Revision 1.2 2003/12/08 15:02:55 schmidtb 00284 * new version of RIP 00285 * 00286 * Revision 1.1 2003/12/04 09:50:26 schmidtb 00287 * Added RFieldSpecialist 00288 * 00289 * Revision 1.5 2003/12/02 21:59:02 schmidtb 00290 * New version of RasterImageProcessor 00291 * 00292 * Revision 1.4 2003/11/28 14:50:01 dueffert 00293 * bugs and warnings fixed 00294 * 00295 * Revision 1.3 2003/11/20 10:26:56 schmidtb 00296 * Ball Detection added 00297 * 00298 * Revision 1.2 2003/11/13 10:41:29 schmidtb 00299 * renewed RBallSpeciaslist and Strategy 00300 * 00301 * Revision 1.1 2003/11/12 13:13:20 schmidtb 00302 * new RasterImageProcessor added 00303 * 00304 * 00305 */