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

Modules/ImageProcessor/RasterImageProcessor/RBridgeSpecialist.h

Go to the documentation of this file.
00001 /**
00002 * @file RBridgeSpecialist.h
00003 * 
00004 * This file contains the definition of class RBridgeSpecialist.
00005 *
00006 * @author <a href="mailto:sadprofessor@web.de">Bernd Schmidt</a>
00007 */
00008 #ifndef RBridgeSpecialist_H
00009 #define RBridgeSpecialist_H
00010 
00011 
00012 #include "RasterSpecialist.h"
00013 #include "Tools/Math/Geometry.h"
00014 #include "Tools/Math/Vector2.h"
00015 #include "RasterStrategy.h"
00016 #include "Tools/Math/Vector3.h"
00017 #include <list>
00018 #include <vector>
00019 #include <algorithm>
00020 #include "Representations/Perception/LandmarksPercept.h"
00021 #include "Modules/ImageProcessor/RasterImageProcessor/REdgeDetection.h"
00022 
00023 using namespace std;
00024 
00025 /** @class RBridgeSpecialist
00026 *
00027 */
00028 class RBridgeSpecialist :public RasterSpecialist
00029 
00030 {
00031 
00032 public:
00033   
00034 /** @class Rectangle
00035 * Struct that represents a rectangle.*/
00036   struct Rectangle {
00037     /** Upper left point.*/
00038     Vector2<double> upperLeft;
00039     /** Upper right point.*/
00040     Vector2<double> upperRight;
00041     /** Bottom left point.*/
00042     Vector2<double> bottomLeft;
00043     /** Bottom right point.*/
00044     Vector2<double> bottomRight;
00045     /** Center point of the rectangle.*/
00046     Vector2<double> center;
00047   };
00048 
00049   /** @class SegmentInfo
00050   * This struct holds information about a segment in the image.*/
00051   struct SegmentInfo {
00052     /** Constructor */
00053     SegmentInfo();
00054     
00055     /** A vote for beacon with yellow.*/
00056     double lmValidityYellow;
00057     /** A vote for beacon with orange.*/
00058     double lmValidityOrange;
00059     /** The bounding box aligned to the horizon.*/
00060     Rectangle rect;
00061     /** Number of yellow pixels.*/
00062     int yellow;
00063     /** Number of skyblue pixels.*/
00064     int skyblue;
00065     /** Number of orange pixels.*/
00066     int orange;
00067     /** The number of pixels.*/
00068     int size;
00069     /** The left color of a bite-mark.*/
00070     colorClass leftColor;
00071     /** The right color of a bite-mark.*/
00072     colorClass rightColor;
00073     /** A pointer to the related region.*/
00074     list<LinePair>* segment;
00075   };
00076 
00077   typedef Geometry::Line Line;
00078   typedef vector<list<RasterSpecialist::LinePair> > SVector;
00079 
00080 
00081 
00082   /** Constructor
00083   *
00084   *   @param processor The image processor interfaces.
00085   *   @param strategy The strategy.
00086   */
00087   RBridgeSpecialist(RasterImageProcessor &processor,RasterStrategy &strategy);
00088   /** Destructor*/
00089   virtual ~RBridgeSpecialist();
00090   /** Invokes the specialist in the second scan stage at position (x,y) 
00091     * (this member should be replaced later).
00092     *   @param x The x coordinate.
00093     *   @param y The y coordinate.  
00094     */
00095   void invokeOnPostScan(int x, int y);
00096   /** Executes the detection algorithm. */
00097   void executePostProcessing();
00098   /** Invokes the specialist in the first scan stage at position (x,y)
00099     * (this member should be replaced later).
00100     *   @param x The x coordinate.
00101     *   @param y The y coordinate.*/
00102   void invokeOnPreScan(int x,int y);
00103   /** Returns the type of specialist.
00104   *   @return Type of specialist.
00105   */
00106   virtual int getType();
00107   /** Initializes the specialist.*/
00108   virtual void init();
00109 
00110 private:
00111   /** The color of the line behind the bite-marks.*/
00112   colorClass lineColor;
00113   /** The strategy.*/
00114   RasterStrategy *strategy;
00115   /** The edge scanner.*/
00116   REdgeDetection edgeScanner;
00117   /** The runs, which are the input data.*/
00118   std::list<LinePair> lst_pts;
00119   /** The calculated horizon.*/
00120   Geometry::Line horizon;
00121   /** A perpendicular to the horizon.*/
00122   Geometry::Line pHorizon;
00123   /** A Temporary variable.*/
00124   Vector2 <int> left_border;
00125   /** The regions, the runs are clustered to.*/
00126   std::vector<list<LinePair> > segments_img;
00127   /** Additional data to the regions.*/
00128   std::vector<SegmentInfo> infos_img;
00129 
00130   /** Builds the bounding boxes of the calculated regions.*/
00131   void createBBox();
00132   /** Counts the colors of segment si. And stores the result in si.
00133   *   @param si SegmentInfo of the region.
00134   *   @param segment List of runs.
00135   */
00136   void countColors(SegmentInfo& si, list<LinePair>& segment);
00137   /** Detects a bridgeMark, if the region is one. And stores it in
00138   *   the bite-point percept.
00139   *   @param si Additional data to the segment.
00140   */
00141   void findBridgeMark(SegmentInfo& si);
00142   /**
00143   *   Calculates the position of a mark, depending on its colors.
00144   *
00145   *   @param mark
00146   *   @return The position of the mark.
00147   */
00148   BitePoint::Position getPosition(SegmentInfo& mark);
00149 
00150 
00151   void calculateAnglesForPoint
00152   (
00153     const Vector2<double>& point, 
00154     const CameraMatrix& cameraMatrix, 
00155     const CameraInfo& cameraInfo, 
00156     Vector2<double>& angles
00157   );
00158 
00159 
00160   bool calculatePointOnField
00161   (
00162     const double x,
00163     const double y,
00164     const CameraMatrix& cameraMatrix,
00165     const CameraInfo& cameraInfo,
00166     Vector2<int>& pointOnField
00167   );
00168   /** Calculates the validities for the several kinds of marks.
00169   *   The result is stored in info.
00170   *   @param info input
00171   */
00172   void createValidities(SegmentInfo& info);
00173 };
00174 
00175 #endif

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