00001 00002 // REnemySpecialist.h: Schnittstelle für die Klasse REnemySpecialist. 00003 // 00004 ////////////////////////////////////////////////////////////////////// 00005 00006 #ifndef RENEMYSPECIALIST_H 00007 #define RENEMYSPECIALIST_H 00008 00009 00010 #include "RasterSpecialist.h" 00011 #include "Tools/Math/Geometry.h" 00012 #include <vector> 00013 #include "Tools/Math/Vector2.h" 00014 #include "RasterStrategy.h" 00015 #include "RasterImageProcessor.h" 00016 #include "Modules/ImageProcessor/ImageProcessor.h" 00017 00018 00019 class REnemySpecialist :public RasterSpecialist 00020 { 00021 typedef const unsigned char* I_Pin; 00022 00023 public: 00024 REnemySpecialist(RasterImageProcessor &processor,RasterStrategy &strat); 00025 virtual ~REnemySpecialist(); 00026 void invokeOnPostScan(int x, int y); 00027 void executePostProcessing(); 00028 void invokeOnPreScan(int x,int y); 00029 virtual int getType(); 00030 virtual void init(); 00031 Vector2<int> calculateFarestPoint(std::list<LinePair> enemyLines); 00032 Vector2<int> calculateFarestPointCOG(int numberOfFootPoints,std::list<LinePair> enemyLines); 00033 Vector2<int> calculateFarestPointFastCOG(std::list<LinePair> enemyLines); 00034 Vector2<int> calculatePointOnFieldFromSegment(std::list<LinePair> enemyLines); 00035 00036 int maximums[2]; 00037 int maxCountSum; 00038 int countSum; 00039 int max; 00040 00041 private: 00042 static void sort(int footPointDistance[], Vector2<double> footPoint[], const int& start, const int& end); 00043 inline bool isCross(const LinePair& horizontal,const LinePair vertical) 00044 { 00045 return horizontal.v1.x <= vertical.v1.x 00046 && horizontal.v2.x >= vertical.v1.x 00047 && vertical.v2.y <= horizontal.v1.y 00048 && vertical.v1.y >= horizontal.v1.y; 00049 } 00050 RasterStrategy *strategy; 00051 std::vector<RasterSpecialist::LinePair> columns; 00052 std::vector<RasterSpecialist::LinePair> lines; 00053 Vector2< int> tempP; 00054 Geometry::Line horizon; /**< The horizon. */ 00055 00056 int leftBorderOfNewLp; 00057 }; 00058 00059 #endif 00060 00061 00062 00063 00064 00065 00066 00067 /* 00068 * Change log : 00069 * 00070 * $Log: REnemySpecialist.h,v $ 00071 * Revision 1.4 2004/09/06 12:02:26 schmidtb 00072 * commented almost all members, removed warnings in documentation 00073 00074 * did further code clean up 00075 * 00076 * Revision 1.3 2004/09/02 07:59:29 schmidtb 00077 * Added RasterImageProcessor to repository, because we used it for the OpenChallenge. 00078 * 00079 * Revision 1.17 2004/03/12 10:11:58 neubach 00080 * - added alternative footpointCalculation 00081 * 00082 * Revision 1.16 2004/03/01 11:00:18 neubach 00083 * - removed Debug-Outputs 00084 * - beautified Code 00085 * - faster 2 PointApproximation 00086 * 00087 * Revision 1.15 2004/02/10 17:01:50 koh 00088 * removed #ifdef TrikotErkennung, 00089 * enemySpecialist recognizes black color now 00090 * 00091 * Revision 1.14 2004/02/03 23:09:18 hyung 00092 * Array based on rasterWidth now 00093 * 00094 * ! somehow it seems that my code produces warnings for which I'm 00095 * very very sorry, but my compiler told me always 0 errors, 0 warnings.... 00096 * does somebody know the reason? 00097 * 00098 * Revision 1.13 2004/02/03 21:35:31 kerdels 00099 * warnings removed 00100 * 00101 * Revision 1.12 2004/02/03 21:18:27 hyung 00102 * some minor changes, 00103 * 00104 * size of Segmentborder-Array (TrikotErkennung) basically adaptive to rip-resolution 00105 * 00106 * Revision 1.11 2004/02/02 10:47:39 neubach 00107 * - removed Warnings 00108 * - added calculateFarestPointCOG-Method, which improves approximation of EnemyPositions via Center of Gravity Method for n footPoints 00109 * 00110 * Revision 1.10 2004/01/31 11:45:02 hyung 00111 * modified enemyValidity-calculation; 00112 * established basical enviroment for TrikotErkennung, based on Arrays and Lists, changes will take affect only #ifdef TrikotErkennung! 00113 * 00114 * Revision 1.9 2004/01/23 10:40:53 neubach 00115 * - freezed alternative "Trikoterkennung" and other cosmetic changes 00116 * 00117 * Revision 1.8 2004/01/23 10:13:17 neubach 00118 * - ball should no longer be misinterpreted as enemy 00119 * 00120 * Revision 1.7 2004/01/21 03:25:36 hyung 00121 * TrikotErkennung update 00122 * 00123 * Revision 1.6 2004/01/16 09:08:42 neubach 00124 * - support for processing >1 enemy-segments (buggy) 00125 * 00126 * Revision 1.5 2004/01/07 10:21:57 neubach 00127 * - prepared code for processing >1 segments 00128 * 00129 * Revision 1.4 2003/12/16 10:29:17 neubach 00130 * - added calculation of farest point (from horizon) for a playerSegment 00131 * - added conversion point on cameraPicture -> point on Field 00132 * 00133 * Revision 1.3 2003/12/15 13:55:32 schmidtb 00134 * Merged and patched new version of RasterImageProcessor. 00135 * 00136 * Revision 1.2 2003/12/08 15:02:55 schmidtb 00137 * new version of RIP 00138 * 00139 * 00140 * 00141 */ 00142 00143