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

Modules/ImageProcessor/ImageProcessorTools/GoalRecognizer.h

Go to the documentation of this file.
00001 /**
00002 * @file GoalRecognizer.h
00003 *
00004 * Definition of class GoalRecognizer
00005 *
00006 * @author <a href="mailto:juengel@informatik.hu-berlin.de">Matthias Juengel</a>
00007 */
00008 
00009 #ifndef __GoalRecognizer_h_
00010 #define __GoalRecognizer_h_
00011 
00012 #include "Representations/Perception/Image.h"
00013 #include "Representations/Perception/CameraMatrix.h"
00014 #include "Representations/Perception/ColorTable.h"
00015 #include "Representations/Perception/ObstaclesPercept.h"
00016 #include "Representations/Perception/LandmarksPercept.h"
00017 
00018 
00019 #include "Tools/Math/Geometry.h"
00020 #include "Tools/Debugging/DebugImages.h"
00021 
00022 /**
00023 * @class GoalRecognizer
00024 *
00025 * The goal recognizer recognizes the goals in the image.
00026 *
00027 * The recognizer scans horizontal lines in the image left to right.
00028 * Indications for a goal are grouped and checked vertical.
00029 *
00030 * @author <a href="mailto:juengel@informatik.hu-berlin.de">Matthias Juengel</a>
00031 */ 
00032 
00033 class GoalRecognizer //: public ImageProcessorInterfaces
00034 {
00035 public:
00036   GoalRecognizer(
00037     const Image& image, 
00038     const CameraMatrix& cameraMatrix, 
00039     const ColorTable& colorTable, 
00040     ObstaclesPercept& obstaclesPercept,
00041     LandmarksPercept& landmarksPercept
00042     );
00043 
00044   GoalRecognizer(
00045     const Image& image, 
00046     const CameraMatrix& cameraMatrix, 
00047     const ColorTable& colorTable, 
00048     int goalIndicationAboveHorizon,
00049     int goalIndicationBelowHorizon,
00050     ObstaclesPercept& obstaclesPercept,
00051     LandmarksPercept& landmarksPercept
00052     );
00053   
00054   ~GoalRecognizer();
00055 
00056   void getGoalPercept(LandmarksPercept& landmarksPercept);
00057 
00058   struct ColoredPartsCheck
00059   {
00060     Vector2<int> firstPoint;
00061     Vector2<int> lastPoint;
00062     int rangeOfColor;
00063     int numberOfColoredPixels;
00064     
00065     enum{maxNumberOfParts = 20};
00066     
00067     int numberOfLargeParts;
00068     int sizeOfLargePart[maxNumberOfParts];
00069     Vector2<int> largePartBegin[maxNumberOfParts];
00070     Vector2<int> largePartEnd[maxNumberOfParts];
00071     Vector2<double> largePartBeginAngles[maxNumberOfParts];
00072     Vector2<double> largePartEndAngles[maxNumberOfParts];
00073     bool largePartBeginIsOnBorder[maxNumberOfParts];
00074     bool largePartEndIsOnBorder[maxNumberOfParts];
00075     
00076     ColoredPartsCheck() 
00077     {
00078       numberOfLargeParts = 0;
00079     }
00080     
00081     bool determineLargePart(int size, bool beginIsOnBorder, bool endIsOnBorder, CameraMatrix cameraMatrix, CameraInfo cameraInfo)
00082     {
00083       bool foundLargePart = false;
00084 //      if(numberOfColoredPixels > 3)
00085       {
00086         if(rangeOfColor > size)
00087         {
00088           sizeOfLargePart[numberOfLargeParts] = rangeOfColor;
00089           largePartBegin[numberOfLargeParts].x = firstPoint.x;
00090           largePartBegin[numberOfLargeParts].y = firstPoint.y;
00091           largePartEnd[numberOfLargeParts].x = lastPoint.x;
00092           largePartEnd[numberOfLargeParts].y = lastPoint.y;
00093           largePartBeginIsOnBorder[numberOfLargeParts] = beginIsOnBorder;
00094           largePartEndIsOnBorder[numberOfLargeParts] = endIsOnBorder;
00095           
00096           Vector2<double> minAngles, maxAngles;
00097           Geometry::calculateAnglesForPoint(largePartBegin[numberOfLargeParts], cameraMatrix, cameraInfo, largePartBeginAngles[numberOfLargeParts]);
00098           Geometry::calculateAnglesForPoint(largePartEnd[numberOfLargeParts], cameraMatrix, cameraInfo, largePartEndAngles[numberOfLargeParts]);
00099           
00100           numberOfLargeParts++;
00101           foundLargePart = true;
00102           LINE(imageProcessor_flagsAndGoals, firstPoint.x, firstPoint.y, lastPoint.x, lastPoint.y,
00103             2, Drawings::ps_solid, Drawings::pink);
00104         }
00105         
00106         if(numberOfLargeParts >= maxNumberOfParts)
00107         {
00108           numberOfLargeParts = maxNumberOfParts-1;
00109         }
00110       }
00111       return foundLargePart;
00112     }
00113   };
00114 
00115 private:
00116   
00117   /** Calculates the scan lines near the horizon for the goals */
00118   void calculateScanLinesParallelToHorizon();
00119   
00120   /** Calculates the scan lines near the horizon for the goals */
00121   void calculateScanLinesParallelToHorizon(
00122     int distanceAboveHorizon,
00123     int distanceBelowHorizon,
00124     int numberOfScanLines
00125     );
00126   
00127   /** Scans horizontal for goals */
00128   void scanHorizontalForGoals();
00129 
00130   /** Calculates the vertical scan lines for the goals */
00131   void calculateVerticalGoalScanLines();
00132 
00133   /** Scans vertical for goals */
00134   void scanLinesForGoals();
00135 
00136   DECLARE_DEBUG_IMAGE(imageProcessorGoals);
00137 
00138   /** A reference to the image that is scanned for a goal */
00139   const Image& image;
00140 
00141   /** A reference to the camera matrix that describes position and rotation of the camera when the image was aquired */
00142   const CameraMatrix& cameraMatrix;
00143 
00144   /** A reference to the color table */
00145   const ColorTable& colorTable;
00146 
00147   int goalIndicationAboveHorizon;
00148   int goalIndicationBelowHorizon;
00149   bool useFixedScanLines;
00150 
00151   /** A reference to the obstacles percept */
00152   ObstaclesPercept& obstaclesPercept;
00153 
00154   /** A reference to the obstacles percept */
00155   LandmarksPercept& landmarksPercept;
00156 
00157   /** The color class of the opponent goal */
00158   colorClass colorOfOpponentGoal;
00159 
00160   /** The color class of the own goal */
00161   colorClass colorOfOwnGoal;
00162 
00163   /** A representation of the horizon */
00164   Geometry::Line horizonLine, verticalLine;
00165 
00166   /** The number of horizontal scan lines */
00167   int numberOfHorizontalScanLines;
00168 
00169   enum{maxNumberOfHorizontalScanLines = 32};
00170   enum{maxNumberOfGoalScanLines = 255};
00171 
00172   /** representation of the left points of the horizontal scan lines */
00173   Vector2<int> leftPoint[maxNumberOfHorizontalScanLines];
00174   
00175   /** representation of the right points of the horizontal scan lines */
00176   Vector2<int> rightPoint[maxNumberOfHorizontalScanLines];
00177 
00178   /** the number of indications for goals */
00179   int numberOfGoalIndications;
00180 
00181   /** left point of an indications for a goal */
00182   Vector2<int> goalIndicationLeft[maxNumberOfGoalScanLines];
00183   
00184   /** left point of an indications for a goal */
00185   Vector2<int> goalIndicationCenter[maxNumberOfGoalScanLines];
00186   
00187   /** right point of an indication for a goal */
00188   Vector2<int> goalIndicationRight[maxNumberOfGoalScanLines];
00189 
00190   /** true if the left end of the goal indication is on the border of the image */
00191   bool leftOfGoalIndicationIsOnBorder[maxNumberOfGoalScanLines];
00192   
00193   /** true if the right end of the goal indication is on the border of the image */
00194   bool rightOfGoalIndicationIsOnBorder[maxNumberOfGoalScanLines];
00195 
00196   /** the color class of the goal indication */
00197   colorClass colorOfGoalIndication[maxNumberOfGoalScanLines];
00198 
00199   /** The number of vertical scan lines where a goal is searched*/
00200   int numberOfGoalScanLines;
00201 
00202   /** representation of the top points of the goal scan lines */
00203   Vector2<int> topGoalPoint[maxNumberOfGoalScanLines];
00204   
00205   /** representation of the bottom points of the goal scan lines */
00206   Vector2<int> bottomGoalPoint[maxNumberOfGoalScanLines];
00207   
00208   bool scanLineToCheckBestAngle[maxNumberOfGoalScanLines];
00209   
00210   /** */
00211   int indexOfGoalIndication[maxNumberOfGoalScanLines];
00212   
00213   /** */
00214   colorClass colorOfGoalScanLine[maxNumberOfGoalScanLines];
00215 
00216 };
00217 
00218 #endif
00219 
00220 /*
00221 * Change log :
00222 * 
00223 * $Log: GoalRecognizer.h,v $
00224 * Revision 1.1.1.1  2004/05/22 17:19:50  cvsadm
00225 * created new repository GT2004_WM
00226 *
00227 * Revision 1.4  2003/12/15 11:47:02  juengel
00228 * Introduced CameraInfo
00229 *
00230 * Revision 1.3  2003/11/26 11:43:00  juengel
00231 * new scan line calculation method added
00232 *
00233 * Revision 1.2  2003/11/07 11:24:59  juengel
00234 * ColoredPartsCheck is public now.
00235 *
00236 * Revision 1.1  2003/10/06 14:10:14  cvsadm
00237 * Created GT2004 (M.J.)
00238 *
00239 * Revision 1.5  2003/09/26 15:27:49  juengel
00240 * Renamed DataTypes to representations.
00241 *
00242 * Revision 1.4  2003/09/01 10:16:17  juengel
00243 * DebugDrawings clean-up 2
00244 * DebugImages clean-up
00245 * MessageIDs clean-up
00246 * Stopwatch clean-up
00247 *
00248 * Revision 1.3  2003/08/30 10:19:53  juengel
00249 * DebugDrawings clean-up 1
00250 *
00251 * Revision 1.2  2003/07/29 12:46:28  juengel
00252 * Moved calculateHorizon to Geometry
00253 *
00254 * Revision 1.1  2003/07/21 13:40:24  juengel
00255 * Moved ColorTableAuto and GoalRecognizer to ImageProcessorTools.
00256 *
00257 * Revision 1.1.1.1  2003/07/02 09:40:24  cvsadm
00258 * created new repository for the competitions in Padova from the 
00259 * tamara CVS (Tuesday 2:00 pm)
00260 *
00261 * removed unused solutions
00262 *
00263 * Revision 1.1  2003/06/12 16:49:50  juengel
00264 * Added GoalRecognizer.
00265 *
00266 *
00267 */

Generated on Thu Sep 23 19:57:29 2004 for GT2004 by doxygen 1.3.6