Image Component Library (ICL)
PositionTracker.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLCV/src/ICLCV/PositionTracker.h **
10 ** Module : ICLCV **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 #include <vector>
33 #include <deque>
34 #include <ICLUtils/Point32f.h>
35 
36 namespace icl{
37  namespace cv{
38 
41  allocateFirstFreeIDs, // re-using old ID's
42  allocateBrandNewIDs // using next brand-new ID
43  };
44 
45 
47 
242  template<class valueType>
244  public:
245 
246 
247 
248 
250  PositionTracker():m_bTryOptimize(false),m_currentID(0),m_IDAllocationMode(allocateFirstFreeIDs),m_tThreshold(0){}
251 
253 
254  PositionTracker(valueType threshold):
255  m_bTryOptimize(true),m_currentID(0),
256  m_IDAllocationMode(allocateFirstFreeIDs),m_tThreshold(threshold){}
257 
259 
261  void pushData(valueType *xys, int n);
262 
264  void pushData(const std::vector<valueType> &xs, const std::vector<valueType> &ys);
265 
267  void pushData(const std::vector<utils::Point32f> points);
268 
274  m_IDAllocationMode = mode;
275  }
276 
278 
283  int getID(valueType x, valueType y);
284 
286  int getID(int index);
287 
288  private:
289 
291  typedef std::vector<valueType> Vec;
292 
294  typedef std::vector<Vec> Mat;
295 
297  typedef std::deque<Vec> QMat;
298 
300  QMat m_matData[2];
301 
303  std::vector<int> m_vecCurrentAssignment;
304 
306  std::vector<int> m_vecIDs;
307 
309  std::vector<int> m_vecGoodDataCount;
310 
313 
316 
319 
321  valueType m_tThreshold;
322  };
323 
324 
325  } // namespace cv
326 }
Class for tracking 2D positions.
Definition: PositionTracker.h:243
PositionTracker()
Empty default constructor without any optimization.
Definition: PositionTracker.h:250
undocument this line if you encounter any issues!
Definition: Any.h:37
std::vector< int > m_vecIDs
internal storage of the unique ids I
Definition: PositionTracker.h:306
IDAllocationMode m_IDAllocationMode
flag to indicate which type of ID allocation should be used
Definition: PositionTracker.h:318
std::deque< Vec > QMat
internally used queue-matrix (columns can be pushed and pop'ed in constant time
Definition: PositionTracker.h:297
std::vector< int > m_vecCurrentAssignment
internal storage of the last calculated assignment
Definition: PositionTracker.h:303
#define ICLCV_API
Definition: CompatMacros.h:177
Definition: PositionTracker.h:42
PositionTracker(valueType threshold)
NEW constructor with optimization enabled and given theshold
Definition: PositionTracker.h:254
Definition: PositionTracker.h:41
valueType m_tThreshold
threshold distance
Definition: PositionTracker.h:321
std::vector< int > m_vecGoodDataCount
internal storage for the good data count G
Definition: PositionTracker.h:309
bool m_bTryOptimize
flag to indicate whether to try optimization (trivial assignment)
Definition: PositionTracker.h:312
IDAllocationMode
How should new ID's be allocated.
Definition: PositionTracker.h:40
int m_currentID
first unused ID
Definition: PositionTracker.h:315
void setIDAllocationMode(IDAllocationMode mode)
Definition: PositionTracker.h:273
std::vector< Vec > Mat
internally used matrix type
Definition: PositionTracker.h:294
std::vector< valueType > Vec
internally used vector type
Definition: PositionTracker.h:291