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