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
00032 #ifndef _MHT_DECLARATION_H_
00033 #define _MHT_DECLARATION_H_
00034
00035 #include <algorithm>
00036 #include <vector>
00037 #include <string>
00038 #include <iostream>
00039 #include <fstream>
00040
00041 #include <assert.h>
00042
00043 #include <mtt/hypothesisTree.h>
00044
00045 #include <mtt/k_best.h>
00046
00047 #include <boost/shared_ptr.hpp>
00048 #include <boost/math/special_functions/fpclassify.hpp>
00049
00050 #include <colormap/colormap.h>
00051 #include <boost/thread.hpp>
00052
00053 #include <mtt/metrics.h>
00054
00055 using namespace std;
00056
00065 MatrixXd ellipseParametric(Matrix2d& cov,Vector2d& mu,double MahThreshold);
00066
00067 extern string fileName;
00068
00069 template<class T>
00070 bool removeLocal(vector<T>& v, T i)
00071 {
00072 typename vector<T>::iterator it;
00073
00074 it=find(v.begin(),v.end(),i);
00075
00076 if(it==v.end())
00077 return false;
00078
00079 v.erase(it);
00080 return true;
00081 }
00082
00089 class Color: public std_msgs::ColorRGBA
00090 {
00091 public:
00092
00098 Color(std_msgs::ColorRGBA c);
00099
00107 Color& changeColorBrightness(double correctionFactor);
00108
00114 string str();
00115
00119 ostream& operator<<(ostream&);
00120 };
00121
00122 ostream& operator<<(ostream& o,vector<vector<int> >& measurements_assignemnt);
00123
00147 class Mht
00148 {
00149 public:
00150
00152 vector<ClusterPtr> _clusters;
00153 string _aux1;
00154
00158 Mht(void);
00159
00163 ~Mht(void);
00164
00166 double getMaxGating(void);
00167
00171 void clearTargetAssociations(void);
00172
00173 void simplifySingleTargetClusters(vector<MeasurementPtr>& global_measurements);
00174
00175 void solveCluster(ClusterPtr cluster);
00176
00203 void iterate(vector<MeasurementPtr>& measurements);
00204
00205 hypothesisTreePtr getHypothesisTree(void);
00206
00207 vector<TargetPtr> getTargets(void);
00208
00209 void clear(void);
00210
00211 string getReportName(string extra);
00212
00213 void solveClusterMultiTread(ClusterPtr cluster);
00214
00215 void solveHypothesis(HypothesisPtr parent_hypothesis,vector<MeasurementPtr>& measurements, vector<HypothesisPtr>& list_of_hypotheses);
00216
00218 int _k;
00220 int _j;
00221
00222 private:
00223
00225 hypothesisTreePtr _hypothesisTree;
00226
00228 HypothesisTree::leaf_iterator _hleaf;
00230 HypothesisTree::iterator _iterator;
00231
00233 vector<TargetPtr> _current_targets;
00234
00236 long iteration;
00238 double _max_gating;
00240 int _miss_association_threshold;
00242 double _minimum_representativity;
00243
00245 uint _history_size;
00247 bool _remove_unused;
00249 bool _parent_tagging;
00251 bool _use_minimum_representativity;
00253 bool _remove_empty_clusters;
00255 bool _clean_old_modifying_tree;
00257 long _cluster_id;
00259 void recursiveHypothesisRemove(HypothesisTree::iterator it);
00261 void removeIrrelevant(void);
00263 void removeTheDead(void);
00264
00270 vector<ClusterPtr>::iterator completeRemoveCluster(long id);
00271
00275 vector<ClusterPtr>::iterator completeRemoveCluster(vector<ClusterPtr>::iterator it_cluster);
00276
00277 MeasurementPtr findMeasurement(vector<MeasurementPtr>& measurements, long id);
00278
00287 void switchColor(HypothesisPtr hypothesis);
00288
00301 vector<HypothesisPtr> findHypotheses(int cl,int it_past = 1);
00302
00303 ClusterPtr findCluster(vector<ClusterPtr>& clusters, int id);
00304
00305 void createClusters(void);
00306
00310 void clusterAssignemnt(vector<MeasurementPtr>& measurements);
00311
00315 void cleanClusters(void);
00316
00317 void removeEmptyClusters(void);
00318
00319 bool consistencyCheck(void);
00320
00321 void breakClusters(vector<MeasurementPtr>& measurements);
00322
00323 HypothesisTree::iterator insertForcedParent(long cluster);
00324
00325 vector<TargetPtr> createCopy(vector<TargetPtr>& original);
00326
00332 void clusterMerger(vector<MeasurementPtr>& measurements);
00333
00334 TargetPtr associate(TargetPtr& target,MeasurementPtr& measurement);
00335
00336 bool normalize(vector<HypothesisPtr>& hypotheses,uint j=10e3);
00337
00338 void getProbability(HypothesisPtr hypothesis);
00339
00340 double getProbability(uint n_det, uint n_occ, uint n_del, uint n_new, uint n_fal, double prod, double previous);
00341
00342 HypothesisPtr getHypothesisPtr(long id,ClusterPtr& cluster);
00343
00344 void updateTargetList(void);
00345
00346 void checkCurrentTargets(vector<MeasurementPtr>& measurements);
00347 };
00348
00349 #endif