DeepFaceRecognition.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package VisionX::ArmarXObjects::DeepFaceRecognition
17  * @author Mirko Waechter (waechter at kit dot edu)
18  * @date 2017
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 #include <RobotAPI/interface/speech/SpeechInterface.h>
26 
28 #include <VisionX/interface/components/FaceRecognitionInterface.h>
29 #include <VisionX/interface/components/PointCloudAndImageAndCalibrationProviderInterface.h>
31 
32 #include <MemoryX/interface/components/LongtermMemoryInterface.h>
33 
34 //#include <Python.h>
35 
36 
37 namespace visionx
38 {
39  /**
40  * @class DeepFaceRecognitionPropertyDefinitions
41  * @brief
42  */
44  {
45  public:
48  {
49  defineOptionalProperty<std::string>(
50  "AgentName", "Armar3", "Name of the robot that does the localization");
51  defineOptionalProperty<std::string>(
52  "CameraFrameName",
53  "EyeLeftCamera",
54  "Name of the camera frame of the robot that does the localization");
55  defineOptionalProperty<float>(
56  "GreetAgainDelay",
57  60 * 60 * 12,
58  "Time in seconds between that a person is not greeted again");
59  // defineOptionalProperty<int>("FaceMatchCounter", 3, "How many times a face must be seen until a greeting is send to the TTS");
60  defineOptionalProperty<float>(
61  "GreetThreshold",
62  3.0,
63  "The sum of all gaussians of the recognized faces over time.",
65  defineOptionalProperty<std::string>("ImageProviderName",
66  "OpenNIPointCloudProvider",
67  "Name of the Imageprovider to be used");
68  }
69  };
70 
71  /**
72  * @defgroup Component-DeepFaceRecognition DeepFaceRecognition
73  * @ingroup VisionX-Components
74  * A description of the component DeepFaceRecognition.
75  *
76  * @class DeepFaceRecognition
77  * @ingroup Component-DeepFaceRecognition
78  * @brief Brief description of class DeepFaceRecognition.
79  *
80  * Detailed description of class DeepFaceRecognition.
81  */
83  public armarx::Component,
84  virtual public memoryx::ObjectLocalizerInterface
85  {
86  public:
87  /**
88  * @see armarx::ManagedIceObject::getDefaultName()
89  */
90  std::string
91  getDefaultName() const override
92  {
93  return "DeepFaceRecognition";
94  }
95 
96  protected:
97  memoryx::ObjectLocalizationResultList
98  localizeAndIdentifyFaces(CByteImage** cameraImages,
99  armarx::MetaInfoSizeBasePtr imageMetaInfo,
100  CByteImage** resultImages);
101  // /**
102  // * @see ObjectLocalizerProcessor::onInitObjectLocalizerProcessor()
103  // */
104  // void onInitObjectLocalizerProcessor();
105 
106  // /**
107  // * @see ObjectLocalizerProcessor::onConnectObjectLocalizerProcessor()
108  // */
109  // void onConnectObjectLocalizerProcessor();
110 
111  // /**
112  // * @see ObjectLocalizerProcessor::onExitObjectLocalizerProcessor()
113  // */
114  // void onExitObjectLocalizerProcessor();
115 
116  // /**
117  // * Add a memory entity representing the hand marker in order to set its properties
118  // *
119  // * @param objectClassEntity entity containing all information available for the object class
120  // * @param fileManager GridFileManager required to read files associated to prior knowledge from the database.
121  // *
122  // * @return success of adding this entity
123  // */
124  // memoryx::ObjectLocalizationResultList localizeObjectClasses(const std::vector<std::string>& objectClassNames, CByteImage** cameraImages, armarx::MetaInfoSizeBasePtr imageMetaInfo, CByteImage** resultImages) override;
125 
126  // /**
127  // * Initializes segmentable recognition
128  // *
129  // * @return success
130  // */
131  // bool initRecognizer();
132 
133  // /**
134  // * Add a memory entity representing the hand marker in order to set its properties
135  // *
136  // * @param objectClassEntity entity containing all information available for the object class
137  // * @param fileManager GridFileManager required to read files associated to prior knowledge from the database.
138  // *
139  // * @return success of adding this entity
140  // */
141  // bool addObjectClass(const memoryx::EntityPtr& objectClassEntity, const memoryx::GridFileManagerPtr& fileManager);
142 
143  /**
144  * @see PropertyUser::createPropertyDefinitions()
145  */
147  using FaceConfidenceHistory =
148  std::map<std::string, std::list<std::pair<IceUtil::Time, double>>>;
149 
150  private:
151  visionx::FaceRecognitionInterfacePrx faceReg;
152  memoryx::LongtermMemoryInterfacePrx ltm;
153  ::memoryx::EntityMemorySegmentInterfacePrx faceSegmentPrx;
154  armarx::TextListenerInterfacePrx tts;
155  visionx::CapturingPointCloudAndImageAndCalibrationProviderInterfacePrx imageProvider;
156  const std::string faceSegmentName = "faceMemory";
157  std::shared_ptr<CCalibration> calibration;
158  FaceConfidenceHistory faceConfidenceHistory;
159  // PyObject* pModule, *py_main;
160 
161  float updateAndCheckFaceExistenceProbability(const visionx::FaceLocation& faceLocation);
162  // ObjectLocalizerInterface interface
163  public:
164  memoryx::ObjectLocalizationResultList
165  localizeObjectClasses(const memoryx::ObjectClassNameList& classes,
166  const Ice::Current&) override;
167 
168  // ManagedIceObject interface
169  protected:
170  void onInitComponent() override;
171  void onConnectComponent() override;
172  };
173 } // namespace visionx
visionx::DeepFaceRecognition::localizeObjectClasses
memoryx::ObjectLocalizationResultList localizeObjectClasses(const memoryx::ObjectClassNameList &classes, const Ice::Current &) override
Definition: DeepFaceRecognition.cpp:96
visionx::DeepFaceRecognitionPropertyDefinitions::DeepFaceRecognitionPropertyDefinitions
DeepFaceRecognitionPropertyDefinitions(std::string prefix)
Definition: DeepFaceRecognition.h:46
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::DeepFaceRecognition::localizeAndIdentifyFaces
memoryx::ObjectLocalizationResultList localizeAndIdentifyFaces(CByteImage **cameraImages, armarx::MetaInfoSizeBasePtr imageMetaInfo, CByteImage **resultImages)
visionx::DeepFaceRecognition::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: DeepFaceRecognition.cpp:63
visionx::DeepFaceRecognition::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: DeepFaceRecognition.cpp:51
visionx::DeepFaceRecognitionPropertyDefinitions
Definition: DeepFaceRecognition.h:43
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
ObjectLocalizerProcessor.h
visionx::DeepFaceRecognition
Brief description of class DeepFaceRecognition.
Definition: DeepFaceRecognition.h:82
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:91
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:69
IceUtil::Handle< class PropertyDefinitionContainer >
visionx::DeepFaceRecognition::FaceConfidenceHistory
std::map< std::string, std::list< std::pair< IceUtil::Time, double > >> FaceConfidenceHistory
Definition: DeepFaceRecognition.h:148
armarx::ComponentPropertyDefinitions::ComponentPropertyDefinitions
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition: Component.cpp:35
visionx::DeepFaceRecognition::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: DeepFaceRecognition.cpp:89
TypeMapping.h
visionx::DeepFaceRecognition::getDefaultName
std::string getDefaultName() const override
Definition: DeepFaceRecognition.h:91
armarx::PropertyDefinitionBase::eModifiable
@ eModifiable
Definition: PropertyDefinitionInterface.h:57
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27