Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Modules/ImageProcessor/SlamImageProcessor/SlamGoalRecognizer.h

Go to the documentation of this file.

    00001 /**
    00002 * @file SlamGoalRecognizer.h
    00003 *
    00004 * Definition of class SlamGoalRecognizer
    00005 *
    00006 * @author <a href="mailto:juengel@informatik.hu-berlin.de">Matthias Juengel</a>
    00007 */
    00008
    00009 #ifndef SlamGoalRecognizer_h_
    00010 #define SlamGoalRecognizer_h_
    00011
    00012 /**
    00013 * @class SlamGoalRecognizer
    00014 *
    00015 * The goal recognizer recognizes the goals in the image.
    00016 *
    00017 * The recognizer scans horizontal lines in the image left to right.
    00018 * Indications for a goal are grouped and checked vertical.
    00019 *
    00020 * @author <a href="mailto:juengel@informatik.hu-berlin.de">Matthias Juengel</a>
    00021 */
    00022 class SlamGoalRecognizer
    00023 {
    00024 public:
    00025   SlamGoalRecognizer(
    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   ~SlamGoalRecognizer();
    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 //      if(numberOfColoredPixels > 3)
    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   /** Calculates the scan lines near the horizon for the goals */
    00099   void calculateScanLinesParallelToHorizon();
    00100
    00101   /** Calculates the scan lines near the horizon for the goals */
    00102   void calculateScanLinesParallelToHorizon(
    00103     int distanceAboveHorizon,
    00104     int distanceBelowHorizon,
    00105     int numberOfScanLines
    00106     );
    00107
    00108   /** Scans horizontal for goals */
    00109   void scanHorizontalForGoals();
    00110
    00111   /** Calculates the vertical scan lines for the goals */
    00112   void calculateVerticalGoalScanLines();
    00113
    00114   /** Scans vertical for goals */
    00115   void scanLinesForGoals();
    00116
    00117   DECLARE_DEBUG_IMAGE(imageProcessorGoals);
    00118
    00119   /** A reference to the image that is scanned for a goal */
    00120   const Image& image;
    00121
    00122   /** A reference to the camera matrix that describes position and rotation of the camera when the image was aquired */
    00123   const CameraMatrix& cameraMatrix;
    00124
    00125   /** A reference to the previous camera matrix that describes position and rotation of the camera when the image was aquired */
    00126   const CameraMatrix& prevCameraMatrix;
    00127
    00128   /** A reference to the color table */
    00129   const ColorTable& colorTable;
    00130
    00131   int goalIndicationAboveHorizon;
    00132   int goalIndicationBelowHorizon;
    00133   bool useFixedScanLines;
    00134
    00135   /** A reference to the obstacles percept */
    00136   ObstaclesPercept& obstaclesPercept;
    00137
    00138   /** A reference to the obstacles percept */
    00139   LandmarksPercept& landmarksPercept;
    00140
    00141   /** A reference to the color corrector */
    00142   const ColorCorrector& colorCorrector;
    00143
    00144   /** The color class of the opponent goal */
    00145   colorClass colorOfOpponentGoal;
    00146
    00147   /** The color class of the own goal */
    00148   colorClass colorOfOwnGoal;
    00149
    00150   /** A representation of the horizon */
    00151   Geometry::Line horizonLine, verticalLine;
    00152
    00153   /** The number of horizontal scan lines */
    00154   int numberOfHorizontalScanLines;
    00155
    00156   enum{maxNumberOfHorizontalScanLines = 32};
    00157   enum{maxNumberOfGoalScanLines = 255};
    00158
    00159   /** representation of the left points of the horizontal scan lines */
    00160   Vector2<int> leftPoint[maxNumberOfHorizontalScanLines];
    00161
    00162   /** representation of the right points of the horizontal scan lines */
    00163   Vector2<int> rightPoint[maxNumberOfHorizontalScanLines];
    00164
    00165   /** the number of indications for goals */
    00166   int numberOfGoalIndications;
    00167
    00168   /** left point of an indications for a goal */
    00169   Vector2<int> goalIndicationLeft[maxNumberOfGoalScanLines];
    00170
    00171   /** left point of an indications for a goal */
    00172   Vector2<int> goalIndicationCenter[maxNumberOfGoalScanLines];
    00173
    00174   /** right point of an indication for a goal */
    00175   Vector2<int> goalIndicationRight[maxNumberOfGoalScanLines];
    00176
    00177   /** true if the left end of the goal indication is on the border of the image */
    00178   bool leftOfGoalIndicationIsOnBorder[maxNumberOfGoalScanLines];
    00179
    00180   /** true if the right end of the goal indication is on the border of the image */
    00181   bool rightOfGoalIndicationIsOnBorder[maxNumberOfGoalScanLines];
    00182
    00183   /** the color class of the goal indication */
    00184   colorClass colorOfGoalIndication[maxNumberOfGoalScanLines];
    00185
    00186   /** The number of vertical scan lines where a goal is searched*/
    00187   int numberOfGoalScanLines;
    00188
    00189   /** representation of the top points of the goal scan lines */
    00190   Vector2<int> topGoalPoint[maxNumberOfGoalScanLines];
    00191
    00192   /** representation of the bottom points of the goal scan lines */
    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 // SlamGoalRecognizer