00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef VLCBeaconDetector_h_
00011 #define VLCBeaconDetector_h_
00012
00013 #include "Tools/Math/Vector2.h"
00014 #include "Tools/Math/Matrix2x2.h"
00015 #include "VLCFlagSpecialist.h"
00016 #include "Modules/ImageProcessor/ImageProcessorTools/ImageProcessorUtilityClasses.h"
00017 #include "Modules/ImageProcessor/ImageProcessorTools/SUSANEdgeDetectionLite.h"
00018 #include "Modules/ImageProcessor/ImageProcessorTools/BresenhamLineScan.h"
00019
00020 #define MAX_NUMBER_OF_PINK_RUNS 20
00021
00022
00023
00024
00025
00026
00027 class VLCBeaconDetector
00028 {
00029 public:
00030
00031 enum {edgeThresholdU = 13, edgeThresholdV = 15};
00032
00033
00034 VLCBeaconDetector(const Image& image, const CameraMatrix& cameraMatrix,
00035 const CameraMatrix& prevCameraMatrix,
00036 const ImageInfo& imageInf,
00037 const ColorTable& colorTable,
00038 const ColorCorrector& colorCorrector,
00039 LandmarksPercept& landmarksPercept);
00040
00041
00042 void execute();
00043
00044
00045 void analyzeColorTable();
00046
00047
00048 void setBestColorTable(ColorTable * newBestColorTable)
00049 {
00050 bestColorTable = newBestColorTable;
00051 flagSpecialist.setBestColorTable(newBestColorTable);
00052
00053
00054 Vector3<int> nearPoint,farPoint;
00055 ((ColorTable64&) (*bestColorTable)).getBoxAroundColorClass(pink,nearPoint,farPoint);
00056 minPinkUValue = nearPoint.y;
00057 }
00058
00059
00060 private:
00061
00062
00063 const SUSANEdgeDetectionLite edgeDetectionU;
00064 const SUSANEdgeDetectionLite edgeDetectionV;
00065
00066
00067 const Image& image;
00068
00069 const CameraMatrix& cameraMatrix;
00070
00071 const CameraMatrix& prevCameraMatrix;
00072
00073 const ImageInfo& imageInf;
00074
00075 const ColorTable& colorTable;
00076
00077 LandmarksPercept& landmarksPercept;
00078
00079 int numOfBeaconCandidates;
00080
00081 Run beaconCandidates[MAX_NUMBER_OF_PINK_RUNS];
00082
00083 TransformedRun transformedCandidates[MAX_NUMBER_OF_PINK_RUNS];
00084
00085 const double horizontalBaseOffset;
00086
00087 const int numOfHorizontalScanLineAbove;
00088
00089 const int numOfHorizontalScanLineBelow;
00090
00091 const double horizontalOffsetModifier;
00092
00093 const int clusteringDistanceTolerance;
00094
00095 const int minPinkRunLength;
00096
00097
00098 const double clusteringAspectRatio;
00099
00100
00101 const double projectionAspectRatio;
00102
00103
00104 const int edgeScanDepth;
00105
00106 unsigned char minPinkUValue;
00107
00108
00109 const double minFlagConfidence;
00110
00111 VLCFlagSpecialist flagSpecialist;
00112
00113 const ColorCorrector& colorCorrector;
00114
00115
00116
00117
00118
00119 bool addCandidate(const Run& pinkRun);
00120
00121
00122 void scanForPink(const Vector2<int>& start, const Vector2<int>& end);
00123
00124
00125 bool scanForBeaconPart(const Vector2<int>& start, const Vector2<int>& end,
00126 Vector2<int>& position, Vector2<int>& edge, colorClass& color);
00127
00128
00129 void clusterPinkBeaconParts();
00130
00131
00132 void analyzeBeacon(const Vector2<double>& left, const double pinkRunWidth);
00133
00134
00135 int scanForBeaconEdges(const Vector2<int>& position, const double pinkRunWidth,
00136 Flag::FlagType& flagType, Vector2<int>& topEdge, Vector2<int>& bottomEdge);
00137
00138 enum {lowReliability = 1, mediumReliability = 4, highReliability = 6};
00139
00140
00141 ColorTable * bestColorTable;
00142
00143 };
00144
00145 #endif //VLCBeaconDetector_h_