FoeDetector.H
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 #include "Component/ModelComponent.H"
00039 #include "Component/ModelParam.H"
00040
00041 #include "Image/Image.H"
00042 #include "Image/Layout.H"
00043
00044 #include "Robots/Beobot2/Navigation/FOE_Navigation/SpatioTemporalEnergy.H"
00045 #include "Robots/Beobot2/Navigation/FOE_Navigation/MiddleTemporal.H"
00046 #include "Robots/Beobot2/Navigation/FOE_Navigation/MotionOps.H"
00047 #include "Raster/Raster.H"
00048
00049 #ifndef ROBOTS_BEOBOT2_NAVIGATION_FOENAVIGATION_FOEDETECTOR_H
00050 #define ROBOTS_BEOBOT2_NAVIGATION_FOENAVIGATION_FOEDETECTOR_H
00051
00052 #define FOE_METHOD_TEMPLATE 10000
00053 #define FOE_METHOD_AVERAGE 10001
00054
00055 class FoeDetector: public ModelComponent
00056 {
00057 public:
00058
00059 FoeDetector(OptionManager& mgr,
00060 const std::string& descrName = "FoeDetector",
00061 const std::string& tagName = "FoeDetector");
00062
00063 void reset(uint numPyrLevel, uint numDirs, uint numSpeeds);
00064
00065 ~FoeDetector();
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 Point2D<int> getFoe(Image<byte> lum,
00076 uint method = FOE_METHOD_TEMPLATE,
00077 bool tempFilter = true);
00078
00079
00080 Image<float> getFoeMap(Image<byte> lum,
00081 uint method = FOE_METHOD_TEMPLATE,
00082 bool tempFilter = true);
00083
00084
00085 Point2D<int> getFoe
00086 ( rutz::shared_ptr<OpticalFlow> flow,
00087 uint method = FOE_METHOD_TEMPLATE,
00088 bool tempFilter = true);
00089
00090
00091 Image<float> getFoeMap
00092 ( rutz::shared_ptr<OpticalFlow> flow,
00093 uint method = FOE_METHOD_TEMPLATE,
00094 bool tempFilter = true);
00095
00096
00097
00098 Point2D<int> getFoe
00099 ( std::vector <Image<float> > mtFeatures,
00100 std::vector <Image<float> > mtOptimalShift,
00101 uint method = FOE_METHOD_TEMPLATE,
00102 bool tempFilter = true);
00103
00104
00105
00106 Image<float> getFoeMap
00107 ( std::vector <Image<float> > mtFeatures,
00108 std::vector <Image<float> > mtOptimalShift,
00109 uint method = FOE_METHOD_TEMPLATE,
00110 bool tempFilter = true);
00111
00112
00113 Point2D<int> getFoe();
00114 Image<float> getFoeMap();
00115
00116
00117 void setObserverRotation(uint dir, float speed);
00118 void setObserverRotation(float di, float dj);
00119
00120
00121 Layout<byte> getMTfeaturesDisplay(Image<byte> image);
00122
00123 private:
00124
00125
00126 Point2D<int> getFoeTemplate(Image<byte> lum);
00127 Point2D<int> getFoeAvg(Image<byte> lum);
00128
00129
00130
00131 Point2D<int> temporalFilterFoeComputation();
00132
00133
00134
00135 void resetDirectionWeights(uint width, uint height);
00136
00137
00138
00139
00140
00141 void computeV1features();
00142
00143
00144
00145 float detectObserverStationarity();
00146
00147
00148
00149 void detectObserverRotation();
00150 float maxMean(Image<float> image);
00151
00152
00153
00154 void correctForObserverRotation();
00155
00156
00157
00158 Point2D<int> computeFoeTemplate();
00159 float computeFoeTemplateValue(uint foeI, uint foeJ);
00160 Point2D<int> computeFoeTemplate(rutz::shared_ptr<OpticalFlow> flow);
00161 float computeFoeTemplateValue
00162 (uint foeI, uint foeJ, rutz::shared_ptr<OpticalFlow> flow);
00163
00164
00165 float getDirectionWeight
00166 (Point2D<float> pt, Point2D<float> foe, float length, float mangle);
00167 float getDirectionWeight2(uint quad, uint dir);
00168
00169
00170
00171 Point2D<int> computeFoeAverage();
00172 Point2D<int> computeFoeAverage(rutz::shared_ptr<OpticalFlow> flow);
00173
00174
00175
00176 void print(Image<float> img,
00177 uint si, uint ei, uint sj, uint ej, bool stop);
00178 void display(Image<float> img, std::string info);
00179 void display(ImageSet<float> imgs, std::string info);
00180
00181
00182
00183
00184 std::vector<std::vector
00185 <rutz::shared_ptr<SpatioTemporalEnergyPyrBuilder<float> > > >
00186 itsSpatioTemporalPyrBuilders;
00187
00188
00189 rutz::shared_ptr<MiddleTemporal> itsMT;
00190
00191 std::vector<std::vector<std::vector<Image<float> > > > itsDirWeights;
00192
00193 uint itsNumPyrLevels;
00194 uint itsNumDirs;
00195 uint itsNumSpeeds;
00196
00197
00198
00199 Image<byte> itsCurrentImage;
00200
00201
00202 std::vector<std::vector<ImageSet<float> > > itsRawSpatioTemporalEnergy;
00203 std::vector<ImageSet<float> > itsSpatioTemporalEnergy;
00204
00205
00206
00207
00208
00209
00210 std::vector <Image<float> > itsMTfeatures;
00211 std::vector <Image<float> > itsMToptimalShift;
00212
00213
00214
00215 Image<float> itsFoeMap;
00216 std::vector<Image<float> > itsRecentFoeMaps;
00217 int itsCurrentFoeMapIndex;
00218
00219
00220 Point2D<int> itsFoe;
00221
00222
00223
00224 uint itsCurrentRotMotionDir;
00225 float itsCurrentRotMotionSpeed;
00226 float itsCurrentRotMotionDi;
00227 float itsCurrentRotMotionDj;
00228
00229
00230 rutz::shared_ptr<XWinManaged> itsWin;
00231 };
00232 #endif
00233
00234
00235
00236
00237
00238