FeatureCalculator.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package
19  * @author
20  * @date
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 #pragma once
25 
26 #include <map>
27 #include <string>
28 #include <vector>
29 #include <functional>
30 #include <memory>
31 #include <utility>
32 
33 #include "Feature.hpp"
34 
36 {
37 public:
38  using Points = std::vector<Eigen::Vector3f>;
39  template<class F>
40  void addFeature()
41  {
42  features.push_back(FeaturePtr(new F()));
43  }
44 
45  // Due to bug in GCC, this won't work in GCC versions smaller than 4.9. See GCC bug 41933
46 
47  // template<class F, class... Args>
48  // void addFeature(Args... args) {
49  // featureCtors.push_back([&](std::vector<Eigen::Vector3f> &points) {
50  // return F(points, args...);
51  // });
52  // }
53 
54  std::map<std::string, FeaturePtr> getFeatures(const Points& points)
55  {
56  std::map<std::string, FeaturePtr> fs;
57 
58  for (auto& f : features)
59  {
60  FeaturePtr feature = f->calculate(points);
61  fs[feature->name()] = feature;
62  }
63 
64  return fs;
65  }
66 
67  std::map<std::string, FeaturePtr> getFeatures(const std::pair<std::string, Points>& points)
68  {
69  std::map<std::string, FeaturePtr> fs;
70 
71  for (auto& f : features)
72  {
73  FeaturePtr feature = f->calculate(points);
74  fs[feature->name()] = feature;
75  }
76 
77  return fs;
78  }
79 
80 private:
81  std::vector<FeaturePtr> features;
82 };
83 
FeatureCalculator::getFeatures
std::map< std::string, FeaturePtr > getFeatures(const Points &points)
Definition: FeatureCalculator.hpp:54
Feature.hpp
FeatureCalculator::Points
std::vector< Eigen::Vector3f > Points
Definition: FeatureCalculator.hpp:38
FeatureCalculator::getFeatures
std::map< std::string, FeaturePtr > getFeatures(const std::pair< std::string, Points > &points)
Definition: FeatureCalculator.hpp:67
F
Definition: ExportDialogControllerTest.cpp:16
FeatureCalculator::addFeature
void addFeature()
Definition: FeatureCalculator.hpp:40
FeaturePtr
std::shared_ptr< Feature > FeaturePtr
Definition: Feature.hpp:90
FeatureCalculator
Definition: FeatureCalculator.hpp:35