00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __GT2005LineFinder_DeterministicApproach_h_
00010 #define __GT2005LineFinder_DeterministicApproach_h_
00011
00012
00013 #include "Representations/Perception/Image.h"
00014 #include "Representations/Perception/LinesPercept.h"
00015 #include "Tools/Math/Geometry.h"
00016 #include "Tools/Math/Matrix2x2.h"
00017 #include "GT2005ImageProcessorTools.h"
00018 #include "Modules/ImageProcessor/ImageProcessorTools/ImageProcessorUtilityClasses.h"
00019 #include "Tools/Math/Common.h"
00020 #include "Modules/ImageProcessor/ImageProcessorTools/BresenhamLineScan.h"
00021 #include "Tools/ColorClasses.h"
00022
00023
00024 class GT2005LineFinder_DeterministicApproach
00025 {
00026 public:
00027 GT2005LineFinder_DeterministicApproach(const ColorCorrector& colorCorrector, const ColorTable& colorTable);
00028 ~GT2005LineFinder_DeterministicApproach(void);
00029
00030
00031
00032
00033
00034
00035 void considerLinePoint(
00036 Vector2<int> & pointOnLine,
00037 Vector2<double> & normalToLine);
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 void execute(
00048 LinesPercept & linesPercept,
00049 const CameraMatrix& cameraMatrix,
00050 const Image& image,
00051 const ImageInfo& imageInfo,
00052 const RobotPose & robotPose);
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 void execute(
00065 LinesPercept & linesPercept,
00066 const CameraMatrix& cameraMatrix,
00067 const Image& image,
00068 const ImageInfo& imageInfo,
00069 const RobotPose & robotPose,
00070 const bool circleFound,
00071 const Vector2<double> & circleOnField);
00072
00073
00074
00075
00076 void reset();
00077
00078
00079
00080
00081
00082 int getNumberOfLines();
00083
00084
00085
00086
00087
00088
00089
00090 void getLine(
00091 int number,
00092 Vector2<int> & pointOnLine,
00093 Vector2<double> & normalToLine);
00094
00095 enum {maxNumberOfLines = 6, maxNumberOfLinePoints = 60, pointsNeededForLine = 3};
00096
00097 private:
00098
00099
00100
00101 void findLineFragments();
00102
00103
00104
00105
00106
00107
00108
00109
00110 void findLines(
00111 LinesPercept & linesPercept,
00112 const CameraMatrix& cameraMatrix,
00113 const Image& image,
00114 const ImageInfo& imageInfo);
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 void findIntersections(
00125 LinesPercept & linesPercept,
00126 const CameraMatrix& cameraMatrix,
00127 const Image& image,
00128 const RobotPose & robotPose,
00129 const ImageInfo& imageInfo);
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 void addCrossingsPercept(
00144 const Vector2<double> & intersectionInImage,
00145 const Vector2<int> & intersectionOnField,
00146 int lineNumber1,
00147 int lineNumber2,
00148 LinesPercept & linesPercept,
00149 const Image& image,
00150 const ImageInfo& imageInfo,
00151 const CameraMatrix & cameraMatrix,
00152 const RobotPose & robotPose);
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162 bool handleCenterCircle(
00163 const CameraMatrix& cameraMatrix,
00164 const Image& image,
00165 const RobotPose & robotPose);
00166
00167
00168
00169
00170
00171
00172
00173
00174 bool handleCenterCircle(
00175 const Vector2<double> & centerOnField,
00176 const CameraMatrix& cameraMatrix,
00177 const Image& image);
00178
00179
00180
00181
00182
00183
00184
00185 void addCenterCirclePercept(
00186 LinesPercept & linesPercept,
00187 const CameraMatrix& cameraMatrix,
00188 const Image& image);
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 bool linesPerpendicularOnField(
00199 int lineNumber1,
00200 int lineNumber2,
00201 const CameraMatrix& cameraMatrix,
00202 const Image& image);
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213 bool calculateLineOnField(
00214 int lineNumber,
00215 Vector2<double> & base,
00216 Vector2<double> & direction,
00217 const CameraMatrix& cameraMatrix,
00218 const Image& image);
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230 bool calculateLineOnField(
00231 const Vector2<int> & baseInImage,
00232 const Vector2<double> & directionInImage,
00233 Vector2<double> & baseOnField,
00234 Vector2<double> & directionOnField,
00235 const CameraMatrix& cameraMatrix,
00236 const Image& image);
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248 void doVerificationScan(
00249 const Vector2<double> & crossingPoint,
00250 const Vector2<double> & directionToScanAt,
00251 const Vector2<double> & scanningDirection,
00252 int lineSize,
00253 LinesPercept::CrossingCharacteristic & result,
00254 const CameraMatrix& cameraMatrix,
00255 const Image& image);
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265 bool doVerificationScanForCircle(
00266 const Vector2<int> & circleOnFieldRelative,
00267 double orientation,
00268 const CameraMatrix& cameraMatrix,
00269 const Image& image);
00270
00271 struct LinePoint
00272 {
00273 Vector2<int> pointOnLine;
00274 Vector2<double> normalToLine;
00275 int belongsToLineNo;
00276 };
00277
00278 struct LineFragment
00279 {
00280 Vector2<int> base;
00281 Vector2<double> normal;
00282 bool lineFragmentAlreadyConsidered;
00283 Vector2<int> start;
00284 Vector2<int> end;
00285 double averageStep;
00286 int numberOfPoints;
00287 };
00288
00289
00290
00291 int numberOfLines;
00292
00293 LineFragment * lines;
00294
00295
00296
00297
00298 int numberOfLineFragments;
00299 bool lineFragmentAlreadyConsidered[maxNumberOfLines*2];
00300
00301 LineFragment * lineFragments;
00302
00303
00304
00305 Vector2<int> fromCircleFinder;
00306 bool foundByCircleFinder;
00307 Vector2<int> fromOwnHandling;
00308 bool foundByOwnHandling;
00309 double centerCircleOrientation;
00310 Vector2<double> lastSeenCircleGlobal;
00311 double lastSeenCircleOrientationGlobal;
00312 int framesSinceLastSeen;
00313 int frameCount, circleCount;
00314
00315
00316 const ColorCorrector& colorCorrector;
00317 const ColorTable& colorTable;
00318 LinePoint linePoints[maxNumberOfLinePoints];
00319 int numberOfLinePoints;
00320 double normDistance;
00321 double normProjection;
00322 double normProjectionPerpendicularToHorizon;
00323 };
00324
00325
00326 #endif // __GT2005LineFinder_DeterministicApproach_h_
00327