IT.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 IT_H_DEFINED
00039 #define IT_H_DEFINED
00040
00041 #include "Util/Types.H"
00042 #include "Image/Image.H"
00043 #include "Image/ImageSet.H"
00044 #include "Image/Pixels.H"
00045 #include "Image/Layout.H"
00046 #include "Image/Point3D.H"
00047 #include "plugins/SceneUnderstanding/Camera.H"
00048 #include "plugins/SceneUnderstanding/V4.H"
00049 #include "plugins/SceneUnderstanding/V4d.H"
00050 #include "plugins/SceneUnderstanding/V1.H"
00051 #include "Simulation/SimEvents.H"
00052 #include "Simulation/SimModule.H"
00053 #include <vector>
00054 #include <string>
00055 #include <google/dense_hash_map>
00056 using google::dense_hash_map;
00057
00058 class IT : public SimModule
00059 {
00060 public:
00061
00062 enum OBJECT_TYPE {HOUSE, WOMAN, HAT, MAN};
00063
00064 struct ObjectState
00065 {
00066 Point3D<float> pos;
00067 float rot;
00068 double prob;
00069 double weight;
00070 OBJECT_TYPE objectType;
00071 };
00072
00073 struct RTableEntry
00074 {
00075 Point2D<int> loc;
00076 float rot;
00077 V4::GEON_TYPE geonType;
00078 };
00079
00080 struct Object
00081 {
00082 std::vector<V4::GeonState> geons;
00083 OBJECT_TYPE objectType;
00084 std::vector<RTableEntry> rTable;
00085 };
00086
00087
00088 struct GHTAcc
00089 {
00090 Point2D<int> pos;
00091 int ang;
00092 int scale;
00093 OBJECT_TYPE objectType;
00094 float sum;
00095
00096 bool operator<(const GHTAcc& acc) const
00097 {
00098 return sum < acc.sum;
00099 }
00100
00101 };
00102
00103
00104 IT(OptionManager& mgr, const std::string& descrName = "IT",
00105 const std::string& tagName = "IT");
00106
00107
00108 ~IT();
00109
00110 void buildRTables();
00111 void init(Dims dims);
00112
00113 void setInput(const std::vector<V4::GeonState> &geonsState);
00114
00115 void evolve();
00116
00117 Layout<PixRGB<byte> > getDebugImage();
00118
00119 void getObjectLikelihood(ObjectState& objectState);
00120
00121 V4::GeonState findNearestGeon(const V4::GeonState& geonState);
00122 double getGeonDistance(const V4::GeonState& g1, const V4::GeonState& g2);
00123 void fixAngle(float& ang);
00124
00125
00126 void resampleParticles(std::vector<ObjectState>& objectParticles);
00127 void proposeParticles(std::vector<ObjectState>& objectParticles, const double Neff);
00128
00129 float evaluateObjectParticles(std::vector<ObjectState>& objectParticles);
00130
00131
00132 void GHT(std::vector<GHTAcc>& accRet, OBJECT_TYPE objectType);
00133 void voteForFeature(Image<float>& acc, int angIdx, std::vector<RTableEntry>& rTable);
00134 void normalizeAcc(std::vector<GHTAcc>& acc);
00135
00136 Image<float> showParticles(const std::vector<ObjectState>& objectParticles);
00137
00138 void showObject(Image<PixRGB<byte> > &img, Object& object, Point3D<float>& pos, float rot);
00139
00140 protected:
00141
00142 SIMCALLBACK_DECLARE(IT, SimEventV4Output);
00143
00144
00145 SIMCALLBACK_DECLARE(IT, SimEventSaveOutput);
00146
00147
00148 OModelParam<bool> itsShowDebug;
00149
00150
00151 private:
00152
00153 dense_hash_map<int, V4::GeonState> itsHashedGeonsState;
00154 std::vector<V4::GeonState> itsGeonsState;
00155
00156 Camera itsCamera;
00157
00158 std::vector<ObjectState> itsObjectsParticles;
00159
00160 float itsObjectsDist;
00161
00162 std::vector<Point2D<int> > rTable;
00163
00164 Image<float> itsHoughSpace;
00165
00166 std::vector<Object> itsObjects;
00167
00168 };
00169
00170
00171
00172
00173
00174
00175
00176 #endif //