00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __GT2004FlagSpecialist_h_
00009 #define __GT2004FlagSpecialist_h_
00010
00011 #include "Tools/Debugging/DebugImages.h"
00012
00013 #include "Representations/Perception/ColorTable.h"
00014 #include "Representations/Perception/LandmarksPercept.h"
00015 #include "Representations/Perception/CameraMatrix.h"
00016 #include "Tools/Math/Geometry.h"
00017
00018
00019
00020
00021
00022 class GT2004FlagSpecialist
00023 {
00024 public:
00025 GT2004FlagSpecialist(const ColorCorrector&);
00026
00027
00028 void init(const Image& image);
00029
00030
00031 void searchFlags(
00032 const Image& image,
00033 const ColorTable& colorTable,
00034 const CameraMatrix& cameraMatrix,
00035 colorClass color,
00036 bool pinkIsTop,
00037 const Geometry::Line horizonLine,
00038 int x, int y);
00039
00040 void getFlagPercept(
00041 const CameraMatrix& cameraMatrix,
00042 const CameraMatrix& prevCameraMatrix,
00043 const CameraInfo& cameraInfo,
00044 const Geometry::Line horizonLine,
00045 LandmarksPercept& landmarksPercept
00046 );
00047
00048 private:
00049 const ColorCorrector& colorCorrector;
00050
00051 int imageWidth;
00052 int imageHeight;
00053
00054
00055 Vector2<int> north;
00056 Vector2<int> east;
00057 Vector2<int> south;
00058 Vector2<int> west;
00059 Vector2<int>start;
00060 Vector2<int>destination;
00061
00062 void estimateOffsetForFlags(
00063 LandmarksPercept& landmarksPercept,
00064 const Vector2<double>& cameraOffset
00065 );
00066
00067 enum {maxNumberOfBoundingBoxes = 6};
00068 enum {numberOfHorizontalScans = 5, numberOfVerticalScans = 3};
00069
00070 double boundingBoxTop[maxNumberOfBoundingBoxes][6];
00071 double boundingBoxBottom[maxNumberOfBoundingBoxes][6];
00072 double boundingBoxLeft[maxNumberOfBoundingBoxes][6];
00073 double boundingBoxRight[maxNumberOfBoundingBoxes][6];
00074
00075 bool boundingBoxTopValid[maxNumberOfBoundingBoxes][6];
00076 bool boundingBoxBottomValid[maxNumberOfBoundingBoxes][6];
00077 bool boundingBoxLeftValid[maxNumberOfBoundingBoxes][6];
00078 bool boundingBoxRightValid[maxNumberOfBoundingBoxes][6];
00079
00080 int numberOfBoundingBoxes[6];
00081
00082 int bestBoundingBox[6];
00083
00084 enum Direction{up, down, left, right};
00085 enum DebugType{initial, vertical, horizontal};
00086
00087 bool findEndOfFlag(
00088 const Image& image,
00089 const CameraInfo& bwCameraInfo,
00090 const ColorTable& colorTable,
00091 const Vector2<int> start,
00092 Vector2<double> horizonDirection,
00093 Direction direction,
00094 Vector2<int>& destination,
00095 colorClass color,
00096 bool pinkIsTop,
00097 bool startIsInTop,
00098 DebugType type,
00099 int& countPixel,
00100 int& countTop,
00101 int& countBottom
00102 );
00103
00104 public:
00105
00106 DECLARE_DEBUG_IMAGE(imageProcessorFlags);
00107 };
00108
00109
00110 #endif// __GT2004FlagSpecialist_h_
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123