Feature.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 <iostream>
27 #include <limits>
28 #include <memory>
29 #include <string>
30 #include <utility>
31 
32 #include <Eigen/Core>
33 
34 #include <ArmarXCore/interface/observers/Serialization.h>
37 
38 #include <VisionX/interface/components/ObjectShapeClassification.h>
39 
40 using namespace visionx;
41 using namespace armarx;
42 
43 const std::string FEATURE_FIELD_NAME = "features";
44 
45 class Feature : public FeatureBase
46 {
47 public:
48  using Points = std::vector<Eigen::Vector3f>;
49  using TaggedPoints = std::pair<std::string, Points>;
50  using FeaturePtr = std::shared_ptr<Feature>;
51 
52  virtual std::string
53  name()
54  {
55  return m_name;
56  }
57 
58  virtual FeaturePtr calculate(const Points& points) = 0;
59 
60  virtual FeaturePtr
61  calculate(const TaggedPoints& points)
62  {
63  return calculate(points.second);
64  }
65 
66  virtual double compare(const Feature&) const = 0;
67 
68  virtual void serialize(const ObjectSerializerBasePtr& serializer,
69  const Ice::Current&) const = 0;
70  virtual void deserialize(const ObjectSerializerBasePtr& serializer, const Ice::Current&) = 0;
71 
72  //TODO: properly implement this functions
73  virtual VariantDataClassPtr
74  clone(const Ice::Current&) const
75  {
76  return VariantDataClassPtr();
77  }
78 
79  virtual std::string
80  output(const Ice::Current&) const
81  {
82  return "Feature";
83  }
84 
85  virtual VariantTypeId
86  getType(const Ice::Current&) const
87  {
88  return 0;
89  }
90 
91  virtual bool
92  validate(const Ice::Current&)
93  {
94  return true;
95  }
96 
97  virtual std::ostream& output(std::ostream& out) const = 0;
98  friend std::ostream& operator<<(std::ostream& os, const Feature& f);
99 
100 protected:
101  std::string m_name;
102 };
103 
104 using FeaturePtr = std::shared_ptr<Feature>;
105 
106 std::ostream&
107 operator<<(std::ostream& os, const Feature& f)
108 {
109  return f.output(os);
110 }
Feature::calculate
virtual FeaturePtr calculate(const TaggedPoints &points)
Definition: Feature.hpp:61
Feature
Definition: Feature.hpp:45
Feature::name
virtual std::string name()
Definition: Feature.hpp:53
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
Feature::getType
virtual VariantTypeId getType(const Ice::Current &) const
Definition: Feature.hpp:86
Feature::m_name
std::string m_name
Definition: Feature.hpp:101
visionx::Points
std::vector< Point > Points
Definition: ObjectShapeClassification.h:71
AbstractObjectSerializer.h
Feature::TaggedPoints
std::pair< std::string, Points > TaggedPoints
Definition: Feature.hpp:49
Feature::clone
virtual VariantDataClassPtr clone(const Ice::Current &) const
Definition: Feature.hpp:74
visionx::operator<<
std::ostream & operator<<(std::ostream &os, const Point3D &rhs)
Definition: ice_point_operators.cpp:19
FEATURE_FIELD_NAME
const std::string FEATURE_FIELD_NAME
Definition: Feature.hpp:43
Feature::Points
std::vector< Eigen::Vector3f > Points
Definition: Feature.hpp:48
armarx::VariantTypeId
Ice::Int VariantTypeId
Definition: Variant.h:43
armarx::detail::compare
int compare(const T &lhs, const T &rhs)
Definition: TreeWidgetBuilder.h:321
Feature::output
virtual std::string output(const Ice::Current &) const
Definition: Feature.hpp:80
Feature::FeaturePtr
std::shared_ptr< Feature > FeaturePtr
Definition: Feature.hpp:50
Feature::validate
virtual bool validate(const Ice::Current &)
Definition: Feature.hpp:92
Variant.h
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
FeaturePtr
std::shared_ptr< Feature > FeaturePtr
Definition: Feature.hpp:104