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 <MemoryX/interface/components/LongtermMemoryInterface.h>
26 #include <RobotAPI/interface/speech/SpeechInterface.h>
28 #include <VisionX/interface/components/FaceRecognitionInterface.h>
29 #include <VisionX/interface/components/PointCloudAndImageAndCalibrationProviderInterface.h>
31 
32 //#include <Python.h>
33 
34 
35 namespace visionx
36 {
37  /**
38  * @class DeepFaceRecognitionPropertyDefinitions
39  * @brief
40  */
43  {
44  public:
47  {
48  defineOptionalProperty<std::string>("AgentName", "Armar3", "Name of the robot that does the localization");
49  defineOptionalProperty<std::string>("CameraFrameName", "EyeLeftCamera", "Name of the camera frame of the robot that does the localization");
50  defineOptionalProperty<float>("GreetAgainDelay", 60 * 60 * 12, "Time in seconds between that a person is not greeted again");
51  // defineOptionalProperty<int>("FaceMatchCounter", 3, "How many times a face must be seen until a greeting is send to the TTS");
52  defineOptionalProperty<float>("GreetThreshold", 3.0, "The sum of all gaussians of the recognized faces over time.", armarx::PropertyDefinitionBase::eModifiable);
53  defineOptionalProperty<std::string>("ImageProviderName", "OpenNIPointCloudProvider", "Name of the Imageprovider to be used");
54 
55  }
56  };
57 
58  /**
59  * @defgroup Component-DeepFaceRecognition DeepFaceRecognition
60  * @ingroup VisionX-Components
61  * A description of the component DeepFaceRecognition.
62  *
63  * @class DeepFaceRecognition
64  * @ingroup Component-DeepFaceRecognition
65  * @brief Brief description of class DeepFaceRecognition.
66  *
67  * Detailed description of class DeepFaceRecognition.
68  */
70  public armarx::Component,
71  virtual public memoryx::ObjectLocalizerInterface
72  {
73  public:
74  /**
75  * @see armarx::ManagedIceObject::getDefaultName()
76  */
77  std::string getDefaultName() const override
78  {
79  return "DeepFaceRecognition";
80  }
81 
82  protected:
83  memoryx::ObjectLocalizationResultList localizeAndIdentifyFaces(CByteImage** cameraImages, armarx::MetaInfoSizeBasePtr imageMetaInfo, CByteImage** resultImages);
84  // /**
85  // * @see ObjectLocalizerProcessor::onInitObjectLocalizerProcessor()
86  // */
87  // void onInitObjectLocalizerProcessor();
88 
89  // /**
90  // * @see ObjectLocalizerProcessor::onConnectObjectLocalizerProcessor()
91  // */
92  // void onConnectObjectLocalizerProcessor();
93 
94  // /**
95  // * @see ObjectLocalizerProcessor::onExitObjectLocalizerProcessor()
96  // */
97  // void onExitObjectLocalizerProcessor();
98 
99  // /**
100  // * Add a memory entity representing the hand marker in order to set its properties
101  // *
102  // * @param objectClassEntity entity containing all information available for the object class
103  // * @param fileManager GridFileManager required to read files associated to prior knowledge from the database.
104  // *
105  // * @return success of adding this entity
106  // */
107  // memoryx::ObjectLocalizationResultList localizeObjectClasses(const std::vector<std::string>& objectClassNames, CByteImage** cameraImages, armarx::MetaInfoSizeBasePtr imageMetaInfo, CByteImage** resultImages) override;
108 
109  // /**
110  // * Initializes segmentable recognition
111  // *
112  // * @return success
113  // */
114  // bool initRecognizer();
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  // bool addObjectClass(const memoryx::EntityPtr& objectClassEntity, const memoryx::GridFileManagerPtr& fileManager);
125 
126  /**
127  * @see PropertyUser::createPropertyDefinitions()
128  */
130  using FaceConfidenceHistory = std::map<std::string, std::list<std::pair<IceUtil::Time, double> > >;
131  private:
132  visionx::FaceRecognitionInterfacePrx faceReg;
133  memoryx::LongtermMemoryInterfacePrx ltm;
134  ::memoryx::EntityMemorySegmentInterfacePrx faceSegmentPrx;
135  armarx::TextListenerInterfacePrx tts;
136  visionx::CapturingPointCloudAndImageAndCalibrationProviderInterfacePrx imageProvider;
137  const std::string faceSegmentName = "faceMemory";
138  std::shared_ptr<CCalibration> calibration;
139  FaceConfidenceHistory faceConfidenceHistory;
140  // PyObject* pModule, *py_main;
141 
142  float updateAndCheckFaceExistenceProbability(const visionx::FaceLocation& faceLocation);
143  // ObjectLocalizerInterface interface
144  public:
145  memoryx::ObjectLocalizationResultList localizeObjectClasses(const memoryx::ObjectClassNameList& classes, const Ice::Current&) override;
146 
147  // ManagedIceObject interface
148  protected:
149  void onInitComponent() override;
150  void onConnectComponent() override;
151 
152  };
153 }
154 
visionx::DeepFaceRecognition::localizeObjectClasses
memoryx::ObjectLocalizationResultList localizeObjectClasses(const memoryx::ObjectClassNameList &classes, const Ice::Current &) override
Definition: DeepFaceRecognition.cpp:97
visionx::DeepFaceRecognitionPropertyDefinitions::DeepFaceRecognitionPropertyDefinitions
DeepFaceRecognitionPropertyDefinitions(std::string prefix)
Definition: DeepFaceRecognition.h:45
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:61
visionx::DeepFaceRecognition::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: DeepFaceRecognition.cpp:50
visionx::DeepFaceRecognitionPropertyDefinitions
Definition: DeepFaceRecognition.h:41
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
visionx::DeepFaceRecognition::FaceConfidenceHistory
std::map< std::string, std::list< std::pair< IceUtil::Time, double > > > FaceConfidenceHistory
Definition: DeepFaceRecognition.h:130
ObjectLocalizerProcessor.h
visionx::DeepFaceRecognition
Brief description of class DeepFaceRecognition.
Definition: DeepFaceRecognition.h:69
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::ComponentPropertyDefinitions::ComponentPropertyDefinitions
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition: Component.cpp:37
visionx::DeepFaceRecognition::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: DeepFaceRecognition.cpp:89
TypeMapping.h
visionx::DeepFaceRecognition::getDefaultName
std::string getDefaultName() const override
Definition: DeepFaceRecognition.h:77
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:28