mht_declaration.h
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
32 #ifndef _MHT_DECLARATION_H_
33 #define _MHT_DECLARATION_H_
34 
35 #include <algorithm>
36 #include <vector>
37 #include <string>
38 #include <iostream>
39 #include <fstream>
40 
41 #include <assert.h>
42 
43 #include <mtt/hypothesisTree.h>
44 
45 #include <mtt/k_best.h>
46 
47 #include <boost/shared_ptr.hpp>
48 #include <boost/math/special_functions/fpclassify.hpp>
49 
50 #include <colormap/colormap.h>
51 #include <boost/thread.hpp>
52 
53 #include <mtt/metrics.h>
54 
55 using namespace std;
56 
65 MatrixXd ellipseParametric(Matrix2d& cov,Vector2d& mu,double MahThreshold);
66 
67 extern string fileName;
68 
69 template<class T>
70 bool removeLocal(vector<T>& v, T i)
71 {
72  typename vector<T>::iterator it;
73 
74  it=find(v.begin(),v.end(),i);
75 
76  if(it==v.end())
77  return false;
78 
79  v.erase(it);
80  return true;
81 }
82 
89 class Color: public std_msgs::ColorRGBA
90 {
91  public:
92 
98  Color(std_msgs::ColorRGBA c);
99 
107  Color& changeColorBrightness(double correctionFactor);
108 
114  string str();
115 
119  ostream& operator<<(ostream&);
120 };
121 
122 ostream& operator<<(ostream& o,vector<vector<int> >& measurements_assignemnt);
123 
147 class Mht
148 {
149  public:
150 
152  vector<ClusterPtr> _clusters;
153  string _aux1;
154 
158  Mht(void);
159 
163  ~Mht(void);
164 
166  double getMaxGating(void);
167 
171  void clearTargetAssociations(void);
172 
173  void simplifySingleTargetClusters(vector<MeasurementPtr>& global_measurements);
174 
175  void solveCluster(ClusterPtr cluster);
176 
203  void iterate(vector<MeasurementPtr>& measurements);
204 
205  hypothesisTreePtr getHypothesisTree(void);
206 
207  vector<TargetPtr> getTargets(void);
208 
209  void clear(void);
210 
211  string getReportName(string extra);
212 
213  void solveClusterMultiTread(ClusterPtr cluster);
214 
215  void solveHypothesis(HypothesisPtr parent_hypothesis,vector<MeasurementPtr>& measurements, vector<HypothesisPtr>& list_of_hypotheses);
216 
218  int _k;
220  int _j;
221 
222  private:
223 
226 
228  HypothesisTree::leaf_iterator _hleaf;
231 
233  vector<TargetPtr> _current_targets;
234 
236  long iteration;
238  double _max_gating;
243 
259  void recursiveHypothesisRemove(HypothesisTree::iterator it);
261  void removeIrrelevant(void);
263  void removeTheDead(void);
264 
270  vector<ClusterPtr>::iterator completeRemoveCluster(long id);
271 
275  vector<ClusterPtr>::iterator completeRemoveCluster(vector<ClusterPtr>::iterator it_cluster);
276 
277  MeasurementPtr findMeasurement(vector<MeasurementPtr>& measurements, long id);
278 
287  void switchColor(HypothesisPtr hypothesis);
288 
301  vector<HypothesisPtr> findHypotheses(int cl,int it_past = 1);
302 
303  ClusterPtr findCluster(vector<ClusterPtr>& clusters, int id);
304 
305  void createClusters(void);
306 
310  void clusterAssignemnt(vector<MeasurementPtr>& measurements);
311 
315  void cleanClusters(void);
316 
317  void removeEmptyClusters(void);
318 
319  bool consistencyCheck(void);
320 
321  void breakClusters(vector<MeasurementPtr>& measurements);
322 
323  HypothesisTree::iterator insertForcedParent(long cluster);
324 
325  vector<TargetPtr> createCopy(vector<TargetPtr>& original);
326 
332  void clusterMerger(vector<MeasurementPtr>& measurements);
333 
334  TargetPtr associate(TargetPtr& target,MeasurementPtr& measurement);
335 
336  bool normalize(vector<HypothesisPtr>& hypotheses,uint j=10e3);
337 
338  void getProbability(HypothesisPtr hypothesis);
339 
340  double getProbability(uint n_det, uint n_occ, uint n_del, uint n_new, uint n_fal, double prod, double previous);
341 
342  HypothesisPtr getHypothesisPtr(long id,ClusterPtr& cluster);
343 
344  void updateTargetList(void);
345 
346  void checkCurrentTargets(vector<MeasurementPtr>& measurements);
347 };
348 
349 #endif
boost::shared_ptr< Measurement > MeasurementPtr
Definition: cluster.h:47
double _max_gating
Maximum gating threshold.
HypothesisTree::leaf_iterator _hleaf
Leaf auxiliary iterator.
HypothesisTree::iterator _iterator
Simple iterator.
string _aux1
vector< ClusterPtr > _clusters
Vector of current existing hypotheses clusters.
ostream & operator<<(ostream &o, vector< vector< int > > &measurements_assignemnt)
boost::shared_ptr< Cluster > ClusterPtr
Shared pointer to the Cluster class.
Definition: cluster.h:85
int _j
J parameter used in the propagation of hypotheses, must be configured form outside class...
vector< TargetPtr > _current_targets
Vector to store outgoing targets.
double _minimum_representativity
Minimum representativity value in propagating hypotheses.
bool _use_minimum_representativity
Flag that controls the use of the minimum representativity rule.
Big and complicated class that implements the MHT (Multiple Hypotheses Tracking) algorithm.
boost::shared_ptr< HypothesisTree > hypothesisTreePtr
Shared pointer to the HypothesisTree class.
boost::shared_ptr< Hypothesis > HypothesisPtr
Definition: cluster.h:44
bool _remove_empty_clusters
Flag that controls the removal of empty clusters.
int _miss_association_threshold
Maximum number of miss associations.
bool removeLocal(vector< T > &v, T i)
long iteration
Current iteration.
K-best Murtys' algorithm header and auxiliary classes declaration.
long _cluster_id
Cluster id seed.
MatrixXd ellipseParametric(Matrix2d &cov, Vector2d &mu, double MahThreshold)
Create a ellipse using parameters.
bool _remove_unused
Flag that determines if dead hypotheses are to be deleted, used in graphviz.
boost::shared_ptr< Target > TargetPtr
Shared pointer to the Target class.
Definition: hypothesis.h:37
Color class, extension to std_msgs::ColorRGBA.
bool _clean_old_modifying_tree
Flag that controls the removal of old hypotheses, with changes to the tree structure.
int _k
K parameter used in the Murty's algorithm, must be configured form outside class. ...
string fileName
Definition: mht.cpp:54
uint _history_size
Number of previous state positions to store.
hypothesisTreePtr _hypothesisTree
Main tree holding variable.
pre_order_iterator iterator
The default iterator types throughout the tree class.
Definition: tree.h:184
Distance metrics declaration.
bool _parent_tagging
Flag that determines if the main parents are to be tagged, used in graphviz.
Hypotheses tree class declaration.


mtt
Author(s): Jorge Almeida
autogenerated on Mon Mar 2 2015 01:32:18