10 #include <VisionX/libraries/armem_human/aron/FaceRecognition.aron.generated.h>
11 #include <VisionX/libraries/armem_human/aron/HumanPose.aron.generated.h>
12 #include <VisionX/libraries/armem_human/aron/PersonInstance.aron.generated.h>
13 #include <VisionX/libraries/armem_human/aron/Profile.aron.generated.h>
31 maxFaceHeadDistance(maxFaceHeadDistance)
51 if (faceRecognition.
profileID.has_value())
53 profileID = faceRecognition.
profileID.value();
58 " does not provide valid profileID, finding matching "
59 "personInstance is not possible.";
66 bool foundMatchingEntity =
false;
68 [&profileID, &personInstanceWriter, &faceRecognitionID, &foundMatchingEntity](
71 armarx::human::arondto::PersonInstance personInstance =
72 instance.
dataAs<armarx::human::arondto::PersonInstance>();
73 if (profileID.
entityName == personInstance.profileID.entityName)
76 toAron(personInstance.faceRecognitionID, faceRecognitionID);
80 update.instancesData = {personInstance.toAron()};
82 ARMARX_INFO <<
"Updated face recognition on personInstance " +
85 foundMatchingEntity =
true;
89 if (foundMatchingEntity)
95 armarx::human::arondto::PersonInstance personInstance;
96 toAron(personInstance.faceRecognitionID, faceRecognitionID);
97 toAron(personInstance.profileID, profileID);
98 std::optional<armarx::armem::MemoryID> closestPoseID =
100 if (closestPoseID.has_value())
102 toAron(personInstance.poseID, closestPoseID.value());
109 update.instancesData = {personInstance.toAron()};
111 ARMARX_INFO <<
"Created new personInstance for face recognition " +
130 bool poseKnown =
false;
134 armarx::human::arondto::PersonInstance personInstance =
135 instance.
dataAs<armarx::human::arondto::PersonInstance>();
137 fromAron(personInstance.poseID, currentPoseID);
138 poseKnown = poseKnown or (currentPoseID == poseID);
146 std::optional<armarx::FramedPosition> headPos = getHeadPos(humanPose);
147 if (headPos.has_value())
149 std::optional<armarx::armem::MemoryID> faceRecognitionID =
150 getClosestFaceID(headPos.value(), mns);
151 if (faceRecognitionID.has_value())
153 armarx::human::arondto::PersonInstance personInstance;
154 toAron(personInstance.faceRecognitionID, faceRecognitionID.value());
157 toAron(personInstance.poseID, poseID);
164 update.instancesData = {personInstance.toAron()};
166 ARMARX_INFO <<
"Created new personInstance for human pose " +
181 std::optional<armarx::armem::MemoryID>
190 float closestDistance = maxFaceHeadDistance;
195 [&facePos, &closestPoseID, &closestDistance](
198 armarx::human::arondto::HumanPose dto =
199 instance.
dataAs<armarx::human::arondto::HumanPose>();
202 std::optional<armarx::FramedPosition> headPos_opt = getHeadPos(pose);
203 if (headPos_opt.has_value())
206 float distance = getDistance(facePos, headPos);
209 closestPoseID = instance.
id();
215 return closestPoseID;
218 std::optional<armarx::armem::MemoryID>
228 float closestDistance = maxFaceHeadDistance;
233 [&headPos, &closestFaceID, &closestDistance](
236 armarx::human::arondto::FaceRecognition dto =
237 instance.
dataAs<armarx::human::arondto::FaceRecognition>();
241 float distance = getDistance(faceRecognition.position3DGlobal, headPos);
244 closestFaceID = instance.
id();
249 return closestFaceID;
252 std::optional<armarx::FramedPosition>
255 std::optional<armarx::FramedPosition> headPos;
280 return sqrt(facePos.x() * headPos.x + facePos.y() * headPos.y + facePos.z() * headPos.z);