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

Modules/ImageProcessor/SlamImageProcessor/SlamBeaconDetector.h

Go to the documentation of this file.
00001 /**
00002 * @file SlamBeaconDetector.h
00003 * 
00004 * Declaration of class SlamBeaconDetector.
00005 *
00006 * @author <a href="mailto:timlaue@tzi.de">Tim Laue</a>
00007 * @author <a href="mailto:walter.nistico@uni-dortmund.de">Walter Nistico</a>
00008 */ 
00009 
00010 #ifndef SlamBeaconDetector_h_
00011 #define SlamBeaconDetector_h_
00012 
00013 #include "Tools/Math/Vector2.h"
00014 #include "Tools/Math/Matrix2x2.h"
00015 #include "SlamFlagSpecialist.h"
00016 #include "Modules/ImageProcessor/ImageProcessorTools/ImageProcessorUtilityClasses.h"
00017 #include "Modules/ImageProcessor/ImageProcessorTools/SUSANEdgeDetectionLite.h"
00018 #include "Modules/ImageProcessor/ImageProcessorTools/BresenhamLineScan.h"
00019 #include "Tools/ColorClasses.h"
00020 
00021 #include "Representations/Perception/SpecialPercept.h"
00022 #include "SlamFlagLocator.h"
00023 
00024 #define NUM_SECTORS     64
00025 #define NUM_SPECIAL_FLAGS 256
00026 
00027 #define MAX_NUMBER_OF_PINK_RUNS 20
00028 
00029 struct SpecialFlag
00030 {
00031   colorClass    sectors[NUM_SECTORS];
00032   double      direction;
00033   int       directionCount;
00034 
00035   Vector2<int>  position;
00036 
00037   int       index;
00038 };
00039 
00040 /**
00041 * @class SlamBeaconDetector
00042 *
00043 * A class for detecting beacons in images
00044 */
00045 class SlamBeaconDetector
00046 {
00047 public:
00048   
00049   enum {edgeThresholdU = 13, edgeThresholdV = 15};
00050 
00051   /** Constructor */ 
00052   SlamBeaconDetector(const Image& image, const CameraMatrix& cameraMatrix,
00053                        const CameraMatrix& prevCameraMatrix,
00054                        const ImageInfo& imageInf,
00055                        const ColorTable& colorTable, 
00056                        const ColorCorrector& colorCorrector,
00057              const RobotPose& robotPose,
00058                        LandmarksPercept& landmarksPercept,
00059              SpecialPercept& specialPercept);
00060 
00061   /** Executes the beacon detection*/
00062   void execute();
00063 
00064   /** Gains information about pink from the current color table*/
00065   void analyzeColorTable();
00066 
00067   double  direction;
00068   int   directionCount;
00069 
00070 private:
00071   int frameCount;
00072 
00073   int     numFlags;
00074   SpecialFlag specialFlags[NUM_SPECIAL_FLAGS];
00075   
00076   /** Edge detection operators (U and V components) used to find the boundaries of flags*/
00077   const SUSANEdgeDetectionLite edgeDetectionU;
00078   const SUSANEdgeDetectionLite edgeDetectionV;
00079 
00080   /** The image*/
00081   const Image& image;
00082   /** The camera matrix*/
00083   const CameraMatrix& cameraMatrix;
00084   /** The previous camera matrix*/
00085   const CameraMatrix& prevCameraMatrix;
00086   /** Additional Image information*/
00087   const ImageInfo& imageInf;
00088   /** The color table*/
00089   const ColorTable& colorTable;
00090 
00091   const RobotPose& robotPose;
00092 
00093   /** The landmarks percept*/
00094   LandmarksPercept& landmarksPercept;
00095   /** The special percept*/
00096   SpecialPercept& specialPercept;
00097   /** The number of possible beacons*/
00098   int numOfBeaconCandidates;
00099   /** The number of possible beacons after clustering*/
00100   int numOfClusteredBeaconCandidates;
00101   /** The list of candidates*/
00102   Run beaconCandidates[MAX_NUMBER_OF_PINK_RUNS];
00103   /** A buffer for transformed candidates*/
00104   TransformedRun transformedCandidates[MAX_NUMBER_OF_PINK_RUNS];
00105   /** The base offset for horizontal scan lines*/
00106   const double horizontalBaseOffset;
00107   /** The number of horizontal scan lines above the horizon*/
00108   const int numOfHorizontalScanLineAbove;
00109   /** The number of horizontal scan lines below the horizon*/
00110   const int numOfHorizontalScanLineBelow;
00111   /** The growth factor of the distance between two scan lines*/
00112   const double horizontalOffsetModifier;
00113   /** The maximum distance between the merged runs*/
00114   const int clusteringDistanceTolerance;
00115   /** The minimum length of a pink run*/
00116   const int minPinkRunLength;
00117   /** The maximum vertical distance of scanlines to be clustered, over the 
00118   * estimated merged horizontal distance (half beacon aspect ratio should be 1:1) */
00119   const double clusteringAspectRatio;
00120   /** The minimum value for the ratio of the 2 dimensions of the pink part of
00121   * the beacon, to be used for projection on the unknown colored part*/
00122   const double projectionAspectRatio;
00123   /** The maximum number of pixels which are examined after an edge response has been found
00124   * for determining the color beyond the edge*/
00125   const int edgeScanDepth;
00126   /** The minimum U channel value of a pink pixel*/
00127   unsigned char minPinkUValue;
00128   /** A confidence threshold used to determine if a target beacon, whose type is
00129   not completely clear, can be accepted or not */
00130   const double minFlagConfidence;
00131   /** A flag specialist*/
00132   SlamFlagSpecialist flagSpecialist;
00133   /** The color corrector*/
00134   const ColorCorrector& colorCorrector;
00135 
00136   double FindSimilarFlag(SpecialFlag &);
00137 
00138   /** Adds a pink run to the list of candidates
00139   * @param pinkRun A pink run
00140   * @return true, if the run has been appended
00141   */
00142   bool addCandidate(const Run& pinkRun);
00143 
00144   /** Scans along a line*/ 
00145   void scanForPink(const Vector2<int>& start, const Vector2<int>& end);
00146 
00147   /** Scans for one other beacon part*/
00148   bool scanForBeaconPart(const Vector2<int>& start, const Vector2<int>& end,
00149                          Vector2<int>& position, Vector2<int>& edge, colorClass& color); 
00150 
00151   /** Clusters the pink elements to find the pink beacon parts*/
00152   void clusterPinkBeaconParts();
00153 
00154   /** Tries to find a special landmark*/
00155   void findSpecial(const Vector2<int>& center, const double pinkRunWidth);
00156 
00157   /** Tries to characterize the surroundings of this flag */
00158   void characterizeNewFlag(const Vector2<int>& center);
00159 
00160   /** scan-method for characterizeNewFlag */
00161   SlamFlagLocator::flagCharacteristics scanForFlagCharacterization(const Vector2<int>& start, const Vector2<double>& direction);
00162 
00163   /** Tries to detect a beacon near a pink part*/
00164   void analyzeBeacon(const Vector2<double>& left, const Vector2<int>& center, const double pinkRunWidth);
00165   
00166   /** Looks for the vertical edges and the color type of a beacon */
00167   int scanForBeaconEdges(const Vector2<int>& position, const double pinkRunWidth,  
00168         Flag::FlagType& flagType, Vector2<int>& topEdge, Vector2<int>& bottomEdge);
00169 
00170   enum {lowReliability = 1, mediumReliability = 4, highReliability = 6};
00171 };
00172 
00173 #endif //SlamBeaconDetector_h_

Generated on Mon Mar 20 21:59:50 2006 for GT2005 by doxygen 1.3.6