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

# Modules/ImageProcessor/GT2005ImageProcessor/GT2005CenterCircleFinder.h

Go to the documentation of this file.

    00001
    00002 #ifndef _GT2005CenterCircleFinder_h_
    00003 #define _GT2005CenterCircleFinder_h_
    00004
    00005 #include "Tools/Math/Vector2.h"
    00006 #include "Representations/Perception/Image.h"
    00007 #include "Tools/Math/Geometry.h"
    00008 #include "Representations/Perception/CameraMatrix.h"
    00009 #include "GT2005ImageProcessorTools.h"
    00010
    00011 class GT2005CenterCircleFinder
    00012 {
    00013 public:
    00014   enum{
    00015       maxNumberOfCandidatesPossible = 90,         //size of the array candidatePoints
    00016       houghDimensionX = 100,  //size of the 2-dim. array houghSpace in x-direction
    00017       houghDimensionY = 50,   //size of the 2-dim. array houghSpace in y-direction
    00018       radius = 180,         //the radius of the center-circle in mm
    00019       areaOfInterestX = 3000, //areaOfInterest defines the area (relative to the robot) around the center-circle. this area will be divided
    00020       areaOfInterestY = 2000, //through a grid of the size: houghDimensionX * houghDimensionY (both in [mm])
    00021       mEntry = 4,             //the minimum number of entries in a houghSpace-cell needed, in order to be able to assume that the
    00022       mEntry2 = 15,
    00023       mEntry3 = 11,               //coordinates of the cell (x,y) is the midpoint of the center-circle.
    00024       scanLength = 140,
    00025       minNumberOfPositives = 7, //number of positives scan tests
    00026       minNumberOfPositivesForDistanceCheck = 4,
    00027       enoughPros = 45,
    00028       maximalDistanceAllowedBetweenMidAndBorder = 290,
    00029       maxNumberOfCandidatesMaxEntry = 150,
    00030       acceptedAvgDistance  = 200,
    00031       onlyWhiteAllowed = 2,
    00032       numberOfScanLines = 8,
    00033       neededWhiteCount = 2
    00034       };
    00035
    00036
    00037
    00038   GT2005CenterCircleFinder(const ColorCorrector& colorCorrector, const ColorTable& cTable);
    00039
    00040   //reset: set numberOfCandidates to zero, initialize houghSpace and flagY
    00041   void reset();
    00042
    00043   //candidates which are inside the area of interest, will be added to the array candidatePoints
    00044   void addCandidate(Vector2<int>& candiOnField, Vector2<int>& candiOfImage);
    00045
    00046   //determineCirclePoint() uses Hough-Transformation, in order to determine the midpoint of the center-circle
    00047   void determineCirclePoint(const CameraMatrix& cameraMatrix, const Image& image, const RobotPose& robotPose, const CameraMatrix& prevCameraMatrix);
    00048
    00049   bool circleFound;
    00050
    00051   bool getCircle(Vector2<double>& mid);
    00052
    00053   //Löschen!!!
    00054   bool circle(Vector2<double>& mid)
    00055   {
    00056     if(circleFound)
    00057       mid = midPoint;
    00058     return(circleFound);
    00059   }
    00060
    00061   //Löschen!!!
    00062
    00063
    00064 private:
    00065   struct Candidate
    00066   {
    00067     Vector2<double> pointOnField;
    00068     Vector2<int> pointOfImage;
    00069   };
    00070   struct multipleCandidate
    00071   {
    00072     Vector2<double> pointOnField;
    00073     int count;
    00074     double avgDistance;
    00075   };
    00076
    00077    Vector2<double> midPoint;
    00078
    00079   //candidatePoints manages the possible center-circle candidates
    00080   Candidate candidatePoints[maxNumberOfCandidatesPossible];
    00081
    00082   //number of entries in candidatePoints
    00083   int numberOfCandidates;
    00084
    00085   //the grid that will divide the area of interest. it´s origin (houghDimension[0][0]) is at the coordinates:
    00086   //houghDimensionX/2, houghDimensionY/2
    00087   int houghSpace[houghDimensionX][houghDimensionY];
    00088
    00089   //flagY[i] marks, if there is an entry in the 2-dim. array houghSpace[houghDimensionX][i] is made, so that not the whole area of interest has
    00090   //to be checked for maximum entries
    00091   bool flagY[houghDimensionY];
    00092
    00093   //houghStepX = areaOfInterestX / houghDimensionX, so the areaOfInterestX should be divisible through houghStepX.
    00094   int houghStepX;
    00095   int houghStepY;
    00096
    00097   //max Quantization error in x-direction = houghStepX/2
    00098   //max Quantization error in y-direction = houghStepY/2
    00099   double maxQuantizationErrorX;
    00100   double maxQuantizationErrorY;
    00101
    00102   //for fading away the drawings of the circle, dependent on the time the midpoint was last seen
    00103   int timeTillLastSeen;
    00104   Vector2<double> midPointLastSeenField;
    00105   Vector2<int> midPointLastSeenFieldInt;
    00106
    00107   double lineThicknessRateAllowed;
    00108
    00109
    00110   //transforms the indices of the array houghSpace to corresponding field-coordinates.
    00111   //@xDirection: xDirection is true, if arrayIndex is a x-index
    00112   //@fieldPosition: that is calculated field-position
    00113   void transformArrayToField(int arrayIndex, bool xDirection, int& fieldPosition);
    00114
    00115   //transforms the field-position inside the area of interest to the correspoinding array-index.
    00116   //@xDirection: xDirection is true, if arrayIndex is a x-index
    00117   //@arrayIndex: that is the calculated array-index
    00118   void transformFieldToArray(double fieldPos, bool xDirection, int& arrayIndex);
    00119
    00120   //checks the midpoint-candidate, given by the hough transformation
    00121   void checkCircleMidpoint(Vector2<double> candidate, int absMaxEntry, const CameraMatrix& cameraMatrix, const Image& image, const RobotPose& robotPose, const CameraMatrix& prevCameraMatrix);
    00122
    00123   //same as checkCircleMidpoint, but with more than one candidate
    00124   void  checkCircleMidpoint2(int maxEntry, int NumberOfEntriesMaxEntry, multipleCandidate maxEntryFieldCoord[maxNumberOfCandidatesMaxEntry],                                const CameraMatrix& cameraMatrix,const Image& image, const RobotPose& robotPose,                                                               const CameraMatrix& prevCameraMatrix);
    00125
    00126   bool scanSurrounding(Vector2<int> start, Vector2<double> startOnField, const CameraMatrix& cameraMatrix, const Image& image, const RobotPose& robotPose, const CameraMatrix& prevCameraMatrix);
    00127
    00128  void scan(Vector2<int> start, Vector2<double> startOnField, Vector2<int> end, Vector2<int> step, int& positiveInNumberOfDirection, const CameraMatrix& cameraMatrix, const Image& image, const RobotPose& robotPose, const CameraMatrix& prevCameraMatrix,double& distance,                                         bool& positiv);
    00129
    00130   //cameraMatrix and image will only be used, in order to transform the results from field-coordinates to image-coordinates, which will
    00131   //display the result
    00132   const ColorCorrector& colorCorrector; //needed for scanning
    00133   const ColorTable& colorTable;
    00134
    00135
    00136
    00137 };
    00138
    00139
    00140 #endif //_GT2005CenterCircleFinder_h_
    00141
    00142
    00143
    00144