ObjRec.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 ObjRec_H_DEFINED
00039 #define ObjRec_H_DEFINED
00040
00041 #include "Component/ModelComponent.H"
00042 #include "Component/ModelParam.H"
00043 #include "Image/Image.H"
00044 #include "Image/Pixels.H"
00045
00046 class ObjRec : public ModelComponent
00047 {
00048 struct EdgeState
00049 {
00050 Point2D<int> pos;
00051 float ori;
00052 PixRGB<byte> color;
00053 float prob;
00054 };
00055 struct LineState
00056 {
00057 Point2D<int> pos;
00058 float ori;
00059 float length;
00060 PixRGB<byte> color;
00061 float prob;
00062 };
00063
00064 struct SquareState
00065 {
00066 Point2D<int> pos;
00067 float ori;
00068 float size;
00069 PixRGB<byte> color;
00070 float prob;
00071 };
00072
00073
00074 struct WorldState
00075 {
00076 Image<float> edgeProb;
00077 std::vector<EdgeState> edges;
00078 std::vector<LineState> lines;
00079 std::vector<SquareState> squares;
00080 };
00081
00082 public:
00083
00084 ObjRec(OptionManager& mgr,
00085 const std::string& descrName = "ObjRec",
00086 const std::string& tagName = "ObjRec");
00087 ~ObjRec();
00088
00089
00090 void start2();
00091
00092 double predictWorld(const Image<PixRGB<byte> > &worldImg);
00093 Image<PixRGB<byte> > getWorldPredictImage();
00094
00095 void setImageDims(const Dims &dims);
00096
00097
00098 void initialProposal ();
00099 void initialProposal(const Image<PixRGB<byte> > &worldImg);
00100 double getPosterior(WorldState &worldState);
00101 double getLikelihood(WorldState &worldState);
00102 double getEdgeLikelihood(WorldState &worldState);
00103 double getLineLikelihood(WorldState &worldState);
00104 double getSquareLikelihood(WorldState &worldState);
00105
00106
00107 void generateNewState(WorldState &worldState);
00108 void generateNewEdgeState(WorldState &worldState);
00109 void generateNewLineState(WorldState &worldState);
00110 void generateNewSquareState(WorldState &worldState);
00111
00112 double sampleOriFromEdgeSpace(WorldState &worldState);
00113 Point2D<int> samplePosFromEdgeSpace(WorldState &worldState);
00114
00115 double sampleOriFromLineSpace(WorldState &worldState);
00116 Point2D<int> samplePosFromLineSpace(WorldState &worldState);
00117 double sampleSizeFromLineSpace(WorldState &worldState);
00118
00119 double sampleLengthFromSquareSpace(WorldState &worldState);
00120
00121 double evalNewEdgesWorld(WorldState &oldWorldState, WorldState &newWorldState);
00122 double evalNewLinesWorld(WorldState &oldWorldState, WorldState &newWorldState);
00123 double evalNewSquaresWorld(WorldState &oldWorldState, WorldState &newWorldState);
00124
00125 void normalizeWorld(WorldState &worldState);
00126
00127
00128 Image<PixRGB<byte> > showWorld(WorldState &worldState);
00129 Image<PixRGB<byte> > showEdgesWorld(WorldState &worldState);
00130 Image<PixRGB<byte> > showLinesWorld(WorldState &worldState);
00131 Image<PixRGB<byte> > showSquaresWorld(WorldState &worldState);
00132
00133
00134
00135 double evalLikelihood(const Image<PixRGB<byte> > &worldImg, const Point2D<int> &pos, double angle, double length);
00136
00137
00138 double edgesProb(const Image<PixRGB<byte> > &worldImg);
00139 double edgesLiklyProb(const Image<PixRGB<byte> > &worldImg);
00140 double edgesPriorProb();
00141
00142 void houghLines();
00143
00144 void samplePosterior(const Image<float> &posterior, Point2D<int> &loc, int stop=1000);
00145
00146 void train(const Image<PixRGB<byte> > &img, const std::string label);
00147 std::string test(const Image<PixRGB<byte> > &img);
00148
00149
00150 private:
00151
00152 Dims itsImageDims;
00153 Image<PixRGB<byte> > itsPredictWorldImg;
00154 Image<PixRGB<byte> > itsCurrentWorldImg;
00155
00156 std::vector<Image<float> > itsGabors;
00157
00158 WorldState itsWorldState;
00159 bool itsInitProposal;
00160
00161 };
00162
00163 #endif
00164
00165
00166
00167
00168
00169