00001
00002
00003
00004
00005
00006
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
00026
00027
00028 class RBridgeSpecialist :public RasterSpecialist
00029
00030 {
00031
00032 public:
00033
00034
00035
00036 struct Rectangle {
00037
00038 Vector2<double> upperLeft;
00039
00040 Vector2<double> upperRight;
00041
00042 Vector2<double> bottomLeft;
00043
00044 Vector2<double> bottomRight;
00045
00046 Vector2<double> center;
00047 };
00048
00049
00050
00051 struct SegmentInfo {
00052
00053 SegmentInfo();
00054
00055
00056 double lmValidityYellow;
00057
00058 double lmValidityOrange;
00059
00060 Rectangle rect;
00061
00062 int yellow;
00063
00064 int skyblue;
00065
00066 int orange;
00067
00068 int size;
00069
00070 colorClass leftColor;
00071
00072 colorClass rightColor;
00073
00074 list<LinePair>* segment;
00075 };
00076
00077 typedef Geometry::Line Line;
00078 typedef vector<list<RasterSpecialist::LinePair> > SVector;
00079
00080
00081
00082
00083
00084
00085
00086
00087 RBridgeSpecialist(RasterImageProcessor &processor,RasterStrategy &strategy);
00088
00089 virtual ~RBridgeSpecialist();
00090
00091
00092
00093
00094
00095 void invokeOnPostScan(int x, int y);
00096
00097 void executePostProcessing();
00098
00099
00100
00101
00102 void invokeOnPreScan(int x,int y);
00103
00104
00105
00106 virtual int getType();
00107
00108 virtual void init();
00109
00110 private:
00111
00112 colorClass lineColor;
00113
00114 RasterStrategy *strategy;
00115
00116 REdgeDetection edgeScanner;
00117
00118 std::list<LinePair> lst_pts;
00119
00120 Geometry::Line horizon;
00121
00122 Geometry::Line pHorizon;
00123
00124 Vector2 <int> left_border;
00125
00126 std::vector<list<LinePair> > segments_img;
00127
00128 std::vector<SegmentInfo> infos_img;
00129
00130
00131 void createBBox();
00132
00133
00134
00135
00136 void countColors(SegmentInfo& si, list<LinePair>& segment);
00137
00138
00139
00140
00141 void findBridgeMark(SegmentInfo& si);
00142
00143
00144
00145
00146
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
00169
00170
00171
00172 void createValidities(SegmentInfo& info);
00173 };
00174
00175 #endif