1 /*******************************************************************************
2 *   Copyright 2013-2014 EPFL                                                   *
3 *   Copyright 2013-2014 Quentin Bonnard                                        *
4 *                                                                              *
5 *   This file is part of chilitags.                                            *
6 *                                                                              *
7 *   Chilitags is free software: you can redistribute it and/or modify          *
8 *   it under the terms of the Lesser GNU General Public License as             *
9 *   published by the Free Software Foundation, either version 3 of the         *
10 *   License, or (at your option) any later version.                            *
11 *                                                                              *
12 *   Chilitags is distributed in the hope that it will be useful,               *
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of             *
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
15 *   GNU Lesser General Public License for more details.                        *
16 *                                                                              *
17 *   You should have received a copy of the GNU Lesser General Public License   *
18 *   along with Chilitags.  If not, see <http://www.gnu.org/licenses/>.         *
19 *******************************************************************************/
20 
21 /** This header contains various utilities to paliate with imperfect detection.
22  */
23 
24 #ifndef Filter_HPP
25 #define Filter_HPP
26 
27 #include <map>
28 #include <vector>
29 
30 #include <chilitags.hpp>
31 
32 namespace chilitags {
33 
34 class FindOutdated {
35 
36 public:
37 
38 FindOutdated(int persistence);
39 
setPersistence(int persistence)40 void setPersistence(int persistence) {
41     mPersistence = persistence;
42 }
43 
44 std::vector<int> operator()(const std::map<int, Quad> &tags);
45 
46 protected:
47 
48 int mPersistence;
49 std::map<int, int> mDisappearanceTime;
50 
51 };
52 
53 
54 
55 class Filter {
56 public:
57 Filter(int persistence, float gain);
58 
setPersistence(int persistence)59 void setPersistence(int persistence) {
60     mFindOutdated.setPersistence(persistence);
61 }
62 
setGain(float gain)63 void setGain(float gain) {
64     mGain = gain;
65 }
66 
67 const std::map<int, Quad> & operator()(
68     const std::map<int, Quad > &tags);
69 
70 protected:
71 FindOutdated mFindOutdated;
72 float mGain;
73 std::map<int, Quad> mFilteredCoordinates;
74 };
75 
76 
77 }
78 
79 #endif
80