00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __SlamImageProcessor_h_
00011 #define __SlamImageProcessor_h_
00012
00013
00014 #include "../GT2005ImageProcessor/GT2005BallSpecialist.h"
00015 #include "../GT2005ImageProcessor/GT2005Clustering.h"
00016 #include "../GT2005ImageProcessor/GT2005LineFinder_DeterministicApproach.h"
00017
00018
00019 #include "Modules/ImageProcessor/ImageProcessor.h"
00020 #include "Tools/Debugging/DebugDrawings.h"
00021 #include "Tools/Math/Geometry.h"
00022 #include "Tools/Debugging/DebugImages.h"
00023 #include "Tools/RingBuffer.h"
00024 #include "Modules/ImageProcessor/ImageProcessorTools/ColorCorrector.h"
00025 #include "SlamImageProcessorTools.h"
00026 #include "SlamGoalRecognizer.h"
00027 #include "SlamBeaconDetector.h"
00028 #include "SlamEdgeSpecialist.h"
00029 #include "SlamBorderFinder.h"
00030 #include "Tools/Actorics/RobotDimensions.h"
00031 #include "Tools/RobotConfiguration.h"
00032 #include "Tools/Math/Common.h"
00033
00034 struct PinkCaracteristic
00035 {
00036 double pixel;
00037 int count;
00038 };
00039
00040 #define NUM_PINK 16
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 class SlamImageProcessor : public ImageProcessor
00063 {
00064 public:
00065
00066
00067
00068
00069 SlamImageProcessor(const ImageProcessorInterfaces& interfaces);
00070
00071
00072 virtual void execute();
00073
00074
00075
00076
00077 virtual bool handleMessage(InMessage& message);
00078
00079 private:
00080 PinkCaracteristic pinkCaracteristic[NUM_PINK];
00081
00082 double filterWeight;
00083
00084 double averageY;
00085 double averageU;
00086 double averageV;
00087
00088 int averageCount;
00089
00090 double xFactor,
00091 yFactor;
00092 int yThreshold;
00093 int vThreshold;
00094 int orangeCount,
00095 noOrangeCount,
00096 noRedCount,
00097 noBlueCount,
00098 noGoalCount,
00099 closestBottom;
00100 Vector2<int> firstRed,
00101 closestRed,
00102 lastRed,
00103 firstBlue,
00104 closestBlue,
00105 lastBlue,
00106 firstFlag,
00107 lastFlag;
00108 bool goalAtBorder;
00109 int longestBallRun;
00110 Vector2<int> ballCandidate;
00111 GT2005Clustering ballClustering;
00112 GT2005LineFinder_DeterministicApproach lineFinder;
00113
00114
00115 ImageInfo imageInfo;
00116
00117 CameraMatrix cmTricot,
00118 prevCmTricot;
00119
00120 ColorCorrector colorCorrector;
00121
00122 SlamBeaconDetector beaconDetector;
00123
00124 SlamGoalRecognizer goalRecognizer;
00125
00126 GT2005BallSpecialist ballSpecialist;
00127
00128 SlamEdgeSpecialist edgeSpecialist;
00129
00130 SlamBorderFinder borderFinder;
00131
00132
00133 int count;
00134
00135
00136
00137
00138 void scanColumns();
00139
00140
00141
00142
00143 void scanRows();
00144
00145
00146
00147
00148
00149
00150
00151
00152 void scan(const Vector2<int>& start, const Vector2<int>& end,
00153 bool vertical, bool noLines);
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 void clusterRobots(const unsigned char* bottomPoint, bool redFound, bool blueFound);
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 void filterPercepts();
00176
00177
00178
00179
00180 void filterLinesPercept(LinesPercept& percept, int type, const CameraMatrix& cameraMatrix, const CameraMatrix& prevCameraMatrix, const Image& image);
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 bool calcEdgeAngle(
00196 double& angleInImage,
00197 double& angleOnField,
00198 const Vector2<int>& pointInImage,
00199 const Vector2<int>& pointOnField,
00200 double scanAngle,
00201 const RingBuffer<const unsigned char*,7>& pixelBuffer,
00202 const bool againstScanline = false,
00203 const bool borderOrLine = true,
00204 int channel = 0);
00205
00206
00207
00208
00209
00210
00211 Vector2<int> getCoords(const unsigned char* p) const
00212 {
00213 const int diff(p - &image.image[0][0][0]);
00214 return Vector2<int>(diff % cameraResolutionWidth_ERS7, diff / (cameraResolutionWidth_ERS7 * 6));
00215 }
00216
00217
00218
00219 const unsigned char* last;
00220 Drawings::Color lineColor;
00221 void plot(const unsigned char* p,Drawings::Color color);
00222
00223
00224 double angleBetweenDirectionOfViewAndGround;
00225
00226 int numberOfScannedPixels;
00227 bool prevCameraMatrixUninitialized;
00228
00229 Matrix2x2<double> rotation2x2;
00230
00231 DECLARE_DEBUG_IMAGE(imageProcessorPlayers);
00232 DECLARE_DEBUG_IMAGE(imageProcessorGeneral);
00233 DECLARE_DEBUG_COLOR_CLASS_IMAGE(segmentedImage1);
00234 DECLARE_DEBUG_IMAGE(imageProcessorBall);
00235 DECLARE_DEBUG_IMAGE(imageProcessorGradients);
00236
00237 N_DECLARE_DEBUG_IMAGE(colorCorrected);
00238 N_DECLARE_DEBUG_IMAGE(colorCorrectedAsJpeg);
00239 N_DECLARE_DEBUG_COLOR_CLASS_IMAGE(segmented);
00240 N_DECLARE_DEBUG_IMAGE(ball);
00241 N_DECLARE_DEBUG_IMAGE(edgeDetection);
00242 N_DECLARE_DEBUG_GRAY_SCALE_IMAGE(scanLines);
00243 };
00244
00245 #endif// __SlamImageProcessor_h_