00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef GT2004GoalRecognizer_h_
00010 #define GT2004GoalRecognizer_h_
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 class GT2004GoalRecognizer
00023 {
00024 public:
00025 GT2004GoalRecognizer(
00026 const Image& image,
00027 const CameraMatrix& cameraMatrix,
00028 const CameraMatrix& prevCameraMatrix,
00029 const ColorTable& colorTable,
00030 const ColorCorrector& colorCorrector,
00031 ObstaclesPercept& obstaclesPercept,
00032 LandmarksPercept& landmarksPercept
00033 );
00034
00035 ~GT2004GoalRecognizer();
00036
00037 void execute();
00038
00039 struct ColoredPartsCheck
00040 {
00041 Vector2<int> firstPoint;
00042 Vector2<int> lastPoint;
00043 int rangeOfColor;
00044 int numberOfColoredPixels;
00045
00046 enum{maxNumberOfParts = 20};
00047
00048 int numberOfLargeParts;
00049 int sizeOfLargePart[maxNumberOfParts];
00050 Vector2<int> largePartBegin[maxNumberOfParts];
00051 Vector2<int> largePartEnd[maxNumberOfParts];
00052 Vector2<double> largePartBeginAngles[maxNumberOfParts];
00053 Vector2<double> largePartEndAngles[maxNumberOfParts];
00054 bool largePartBeginIsOnBorder[maxNumberOfParts];
00055 bool largePartEndIsOnBorder[maxNumberOfParts];
00056
00057 ColoredPartsCheck()
00058 {
00059 numberOfLargeParts = 0;
00060 }
00061
00062 bool determineLargePart(int size, bool beginIsOnBorder, bool endIsOnBorder, CameraMatrix cameraMatrix, CameraInfo cameraInfo)
00063 {
00064 bool foundLargePart = false;
00065
00066 {
00067 if(rangeOfColor > size)
00068 {
00069 sizeOfLargePart[numberOfLargeParts] = rangeOfColor;
00070 largePartBegin[numberOfLargeParts].x = firstPoint.x;
00071 largePartBegin[numberOfLargeParts].y = firstPoint.y;
00072 largePartEnd[numberOfLargeParts].x = lastPoint.x;
00073 largePartEnd[numberOfLargeParts].y = lastPoint.y;
00074 largePartBeginIsOnBorder[numberOfLargeParts] = beginIsOnBorder;
00075 largePartEndIsOnBorder[numberOfLargeParts] = endIsOnBorder;
00076
00077 Vector2<double> minAngles, maxAngles;
00078 Geometry::calculateAnglesForPoint(largePartBegin[numberOfLargeParts], cameraMatrix, cameraInfo, largePartBeginAngles[numberOfLargeParts]);
00079 Geometry::calculateAnglesForPoint(largePartEnd[numberOfLargeParts], cameraMatrix, cameraInfo, largePartEndAngles[numberOfLargeParts]);
00080
00081 numberOfLargeParts++;
00082 foundLargePart = true;
00083 LINE(imageProcessor_flagsAndGoals, firstPoint.x, firstPoint.y, lastPoint.x, lastPoint.y,
00084 2, Drawings::ps_solid, Drawings::pink);
00085 }
00086
00087 if(numberOfLargeParts >= maxNumberOfParts)
00088 {
00089 numberOfLargeParts = maxNumberOfParts-1;
00090 }
00091 }
00092 return foundLargePart;
00093 }
00094 };
00095
00096 private:
00097
00098
00099 void calculateScanLinesParallelToHorizon();
00100
00101
00102 void calculateScanLinesParallelToHorizon(
00103 int distanceAboveHorizon,
00104 int distanceBelowHorizon,
00105 int numberOfScanLines
00106 );
00107
00108
00109 void scanHorizontalForGoals();
00110
00111
00112 void calculateVerticalGoalScanLines();
00113
00114
00115 void scanLinesForGoals();
00116
00117 DECLARE_DEBUG_IMAGE(imageProcessorGoals);
00118
00119
00120 const Image& image;
00121
00122
00123 const CameraMatrix& cameraMatrix;
00124
00125
00126 const CameraMatrix& prevCameraMatrix;
00127
00128
00129 const ColorTable& colorTable;
00130
00131 int goalIndicationAboveHorizon;
00132 int goalIndicationBelowHorizon;
00133 bool useFixedScanLines;
00134
00135
00136 ObstaclesPercept& obstaclesPercept;
00137
00138
00139 LandmarksPercept& landmarksPercept;
00140
00141
00142 const ColorCorrector& colorCorrector;
00143
00144
00145 colorClass colorOfOpponentGoal;
00146
00147
00148 colorClass colorOfOwnGoal;
00149
00150
00151 Geometry::Line horizonLine, verticalLine;
00152
00153
00154 int numberOfHorizontalScanLines;
00155
00156 enum{maxNumberOfHorizontalScanLines = 32};
00157 enum{maxNumberOfGoalScanLines = 255};
00158
00159
00160 Vector2<int> leftPoint[maxNumberOfHorizontalScanLines];
00161
00162
00163 Vector2<int> rightPoint[maxNumberOfHorizontalScanLines];
00164
00165
00166 int numberOfGoalIndications;
00167
00168
00169 Vector2<int> goalIndicationLeft[maxNumberOfGoalScanLines];
00170
00171
00172 Vector2<int> goalIndicationCenter[maxNumberOfGoalScanLines];
00173
00174
00175 Vector2<int> goalIndicationRight[maxNumberOfGoalScanLines];
00176
00177
00178 bool leftOfGoalIndicationIsOnBorder[maxNumberOfGoalScanLines];
00179
00180
00181 bool rightOfGoalIndicationIsOnBorder[maxNumberOfGoalScanLines];
00182
00183
00184 colorClass colorOfGoalIndication[maxNumberOfGoalScanLines];
00185
00186
00187 int numberOfGoalScanLines;
00188
00189
00190 Vector2<int> topGoalPoint[maxNumberOfGoalScanLines];
00191
00192
00193 Vector2<int> bottomGoalPoint[maxNumberOfGoalScanLines];
00194
00195 bool scanLineToCheckBestAngle[maxNumberOfGoalScanLines];
00196
00197
00198 int indexOfGoalIndication[maxNumberOfGoalScanLines];
00199
00200
00201 colorClass colorOfGoalScanLine[maxNumberOfGoalScanLines];
00202
00203 };
00204
00205 #endif // GT2004GoalRecognizer
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221