Image Component Library (ICL)
|
00001 /******************************************************************** 00002 ** Image Component Library (ICL) ** 00003 ** ** 00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** 00005 ** Neuroinformatics Group ** 00006 ** Website: www.iclcv.org and ** 00007 ** http://opensource.cit-ec.de/projects/icl ** 00008 ** ** 00009 ** File : ICLCV/src/ICLCV/PositionTracker.h ** 00010 ** Module : ICLCV ** 00011 ** Authors: Christof Elbrechter ** 00012 ** ** 00013 ** ** 00014 ** GNU LESSER GENERAL PUBLIC LICENSE ** 00015 ** This file may be used under the terms of the GNU Lesser General ** 00016 ** Public License version 3.0 as published by the ** 00017 ** ** 00018 ** Free Software Foundation and appearing in the file LICENSE.LGPL ** 00019 ** included in the packaging of this file. Please review the ** 00020 ** following information to ensure the license requirements will ** 00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** 00022 ** ** 00023 ** The development of this software was supported by the ** 00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** 00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** 00026 ** Forschungsgemeinschaft (DFG) in the context of the German ** 00027 ** Excellence Initiative. ** 00028 ** ** 00029 ********************************************************************/ 00030 00031 #pragma once 00032 #include <vector> 00033 #include <deque> 00034 #include <ICLUtils/Point32f.h> 00035 00036 namespace icl{ 00037 namespace cv{ 00038 00040 enum IDAllocationMode{ 00041 allocateFirstFreeIDs, // re-using old ID's 00042 allocateBrandNewIDs // using next brand-new ID 00043 }; 00044 00045 00047 00242 template<class valueType> 00243 class ICLCV_API PositionTracker{ 00244 public: 00245 00246 00247 00248 00250 PositionTracker():m_bTryOptimize(false),m_currentID(0),m_IDAllocationMode(allocateFirstFreeIDs),m_tThreshold(0){} 00251 00253 00254 PositionTracker(valueType threshold): 00255 m_bTryOptimize(true),m_currentID(0), 00256 m_IDAllocationMode(allocateFirstFreeIDs),m_tThreshold(threshold){} 00257 00259 00261 void pushData(valueType *xys, int n); 00262 00264 void pushData(const std::vector<valueType> &xs, const std::vector<valueType> &ys); 00265 00267 void pushData(const std::vector<utils::Point32f> points); 00268 00273 void setIDAllocationMode(IDAllocationMode mode){ 00274 m_IDAllocationMode = mode; 00275 } 00276 00278 00283 int getID(valueType x, valueType y); 00284 00286 int getID(int index); 00287 00288 private: 00289 00291 typedef std::vector<valueType> Vec; 00292 00294 typedef std::vector<Vec> Mat; 00295 00297 typedef std::deque<Vec> QMat; 00298 00300 QMat m_matData[2]; 00301 00303 std::vector<int> m_vecCurrentAssignment; 00304 00306 std::vector<int> m_vecIDs; 00307 00309 std::vector<int> m_vecGoodDataCount; 00310 00312 bool m_bTryOptimize; 00313 00315 int m_currentID; 00316 00318 IDAllocationMode m_IDAllocationMode; 00319 00321 valueType m_tThreshold; 00322 }; 00323 00324 00325 } // namespace cv 00326 }