Contours.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef Contours_H_DEFINED
00039 #define Contours_H_DEFINED
00040
00041 #include "Image/Image.H"
00042 #include "Image/ImageSet.H"
00043 #include "Image/Pixels.H"
00044 #include "Image/Layout.H"
00045 #include "plugins/SceneUnderstanding/V2.H"
00046 #include "plugins/SceneUnderstanding/TensorVoting.H"
00047 #include "Image/TensorOps.H"
00048 #include "Simulation/SimEvents.H"
00049 #include "Simulation/SimModule.H"
00050
00051 #include <vector>
00052 #include <string>
00053 class SimEventContoursBias;
00054
00055 class Contours : public SimModule
00056 {
00057 public:
00058 const static float UNKNOWN = -1.0F;
00059 const static float NOTDEFINED = -2.0F;
00060
00061 struct Contour
00062 {
00063 std::vector<Point2D<int> > points;
00064 std::vector<float> ori;
00065
00066 size_t size() const
00067 {
00068 return points.size();
00069 }
00070 };
00071
00072 struct ContourCmp
00073 {
00074 bool operator()(const Contour& c1, const Contour& c2)
00075 {
00076 return c1.size() > c2.size();
00077 }
00078 };
00079
00080
00081 Contours(OptionManager& mgr, const std::string& descrName = "Contours",
00082 const std::string& tagName = "Contours");
00083
00084
00085 ~Contours();
00086
00087 void evolve(SimEventQueue& q);
00088
00089 Layout<PixRGB<byte> > getDebugImage();
00090
00091 protected:
00092
00093 SIMCALLBACK_DECLARE(Contours, SimEventV2Output);
00094
00095
00096 SIMCALLBACK_DECLARE(Contours, SimEventContoursBias);
00097
00098
00099 SIMCALLBACK_DECLARE(Contours, SimEventSaveOutput);
00100
00101
00102 SIMCALLBACK_DECLARE(Contours, SimEventUserInput);
00103
00104
00105 OModelParam<bool> itsShowDebug;
00106
00107 std::vector<Point2D<int> > getPointList(TensorVoting& tv, Image<float>& contoursImg,
00108 Image<float>& edgesMag, Image<float>& edgesOri);
00109
00110 std::vector<Point2D<int> > getPointList(Image<float>& inMag, Image<float>& inOri,
00111 Image<float>& contoursImg);
00112
00113
00114 Contour followContour(int idx, Point2D<int> startLoc, Image<float>& contoursImg,
00115 const Image<float>& edgesMag, const Image<float>& edgesOri);
00116
00117 Point2D<int> findEdgeToFollow(const Point2D<int>& edgeLoc,
00118 const float origEdgeMag,
00119 const Image<float>& edgesMag, const Image<float>& edgesOri,
00120 const Image<float>& contoursImg,
00121 const Point2D<int>& pEdge);
00122
00123
00124
00125 private:
00126 std::vector<TensorVoting> itsTensorFields;
00127 std::vector<Contour> itsContours;
00128 std::vector<Contour> itsBiasContours;
00129
00130 int itsCurrentContour;
00131
00132 };
00133
00134
00135 class SimEventContoursOutput : public SimEvent
00136 {
00137 public:
00138 SimEventContoursOutput(SimModule* src,
00139 std::vector<Contours::Contour>& contour,
00140 Image<float>& img) :
00141 SimEvent(src), itsContours(contour), itsImg(img)
00142 {}
00143
00144 virtual ~SimEventContoursOutput(){}
00145 std::vector<Contours::Contour> getContours() { return itsContours; }
00146 Image<float> getImg() { return itsImg; }
00147
00148 private:
00149 const std::vector<Contours::Contour>& itsContours;
00150 const Image<float>& itsImg;
00151 };
00152
00153 class SimEventContoursBias : public SimEvent
00154 {
00155 public:
00156 SimEventContoursBias(SimModule* src,
00157 std::vector<Contours::Contour>& contour) :
00158 SimEvent(src), itsContours(contour)
00159 {}
00160
00161 virtual ~SimEventContoursBias(){}
00162 std::vector<Contours::Contour> getContours() { return itsContours; }
00163
00164 private:
00165 const std::vector<Contours::Contour>& itsContours;
00166 };
00167
00168
00169
00170
00171
00172
00173
00174
00175 #endif //