00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __GT2005RobotSpecialist_h_
00010 #define __GT2005RobotSpecialist_h_
00011
00012 #include "GT2005Types.h"
00013
00014 #ifdef oo7
00015
00016 #define RS_DEBUG
00017
00018
00019 #define RS_DEBUG_FEET
00020
00021
00022
00023 #define RS_DEBUG_SHOW_COLORSPACE_INFO
00024 #define RS_DEBUG_SHOW_CONNECTIONS
00025
00026
00027 #define RS_DEBUG_SHOW_BOUNDINGBOX
00028
00029
00030
00031 #endif
00032
00033 #include "Tools/Debugging/DebugDrawings.h"
00034 #include "Tools/Math/Geometry.h"
00035 #include "Tools/List.h"
00036 #include "Tools/Debugging/DebugImages.h"
00037 #include "Representations/Perception/ColorTable.h"
00038 #include "Representations/Perception/Image.h"
00039 #include "Representations/Perception/CameraMatrix.h"
00040 #include "Representations/Perception/BallPercept.h"
00041 #include "Representations/Perception/LinesPercept.h"
00042 #include "Representations/Perception/PlayersPercept.h"
00043 #include "Representations/Perception/MSHSinglePlayerPercept.h"
00044 #include "Modules/ImageProcessor/ImageProcessorTools/ColorCorrector.h"
00045 #include "Modules/ImageProcessor/ImageProcessorTools/BresenhamLineScan.h"
00046 #include "Modules/ImageProcessor/ImageProcessorTools/ImageProcessorUtilityClasses.h"
00047 #include "GT2005ImageProcessorTools.h"
00048
00049
00050 #include "GT2005Clustering.h"
00051
00052 #include "GT2005ColorSpace.h"
00053
00054
00055 #define RS_FOOT_THRESHOLD 8
00056 #define RS_FOOT_GRADIENT 5
00057 #define RS_NUM_SCAN_LINES 30.0
00058
00059 #define RS_NO_GREEN_PIXEL_THRESHOLD 5
00060 #define RS_NGP_TH_START 10
00061 #define RS_NGP_TH_STOP 2
00062
00063 #define RS_NUM_CANDIDATES 256
00064
00065
00066 struct RobotCandidate
00067 {
00068 Vector2<int> footPoint;
00069 Vector2<int> candidateStart;
00070 Vector2<int> candidateStop;
00071 colorClass color;
00072 int lineID;
00073 };
00074
00075 struct CandidateCluster
00076 {
00077 int startPosition;
00078 int stopPosition;
00079 };
00080
00081
00082
00083
00084 class GT2005RobotSpecialist
00085 {
00086 public:
00087 GT2005RobotSpecialist(const ColorCorrector& colorCorrector_, const Image& image_, const ImageInfo& imageInfo_, const ColorTable& colorTable_, const CameraMatrix& cameraMatrix_, const CameraMatrix& prevCameraMatrix_, LinesPercept& linesPercept_, PlayersPercept &playersPercept_, const RobotPose& robotPose_, const List<GreenChangeEvent>& greenChangeEvents_);
00088
00089
00090
00091
00092 void reset
00093 (
00094 );
00095
00096
00097
00098
00099 void scan
00100 (
00101 );
00102
00103
00104
00105
00106 void scan(
00107 Vector2<int> startPoint
00108 );
00109
00110
00111
00112
00113 void scan (
00114 Vector2<int> startPoint,
00115 Vector2<int> endPoint
00116 );
00117
00118
00119
00120
00121 void addCandidate (
00122 RobotCandidate candidate
00123 );
00124
00125 bool findNearestFootPoint (
00126 Vector2<int> &footPoint
00127 );
00128
00129
00130
00131
00132 void clusterCandidates (
00133 )
00134 {
00135 clusterCandidates (red);
00136 clusterCandidates (blue);
00137 };
00138
00139 void clusterCandidates (
00140 colorClass color
00141 );
00142
00143
00144
00145
00146 void generatePercept (
00147 CandidateCluster cluster
00148 );
00149
00150
00151
00152
00153 int noColorPixelsBetween (
00154 Vector2<int>,
00155 Vector2<int>,
00156 colorClass
00157 );
00158
00159 ColorSpace generateColorspace (
00160 Vector2<int>,
00161 Vector2<int>
00162 );
00163
00164 unsigned int filterPercepts (
00165 ColorSpace colorSpace,
00166 colorClass candidateColor
00167 );
00168
00169 void addPercept (
00170 PerceptInfo &perceptInfo
00171 );
00172
00173
00174
00175
00176 void dbg_PrintGreenchanges (
00177 );
00178
00179 private:
00180 const ColorCorrector& colorCorrector;
00181
00182 const Image& image;
00183 const ImageInfo& imageInfo;
00184 const ColorTable& colorTable;
00185 const CameraMatrix& cameraMatrix;
00186 const CameraMatrix& prevCameraMatrix;
00187 const RobotPose& robotPose;
00188 const List<GreenChangeEvent>& greenChangeEvents;
00189
00190 LinesPercept& linesPercept;
00191 PlayersPercept& playersPercept;
00192
00193
00194 RobotCandidate candidates[RS_NUM_CANDIDATES];
00195 unsigned char topIndex, bottomIndex;
00196
00197 List<GreenChangeEvent>::Pos footIterator;
00198
00199
00200 int noRedCount, noBlueCount;
00201 Vector2<int> lastRed, firstRed, closestRed, lastBlue, firstBlue, closestBlue;
00202
00203
00204 int distanceOnField (Vector2<int>, Vector2<int>, CameraMatrix, CameraInfo);
00205 int generateBoundings (
00206 CandidateCluster cluster,
00207 GT2005Rectangle &body,
00208 GT2005Rectangle &foot,
00209 Vector2<int> &footAVG
00210 );
00211 };
00212
00213 #endif// __BallSpecialist_h_