aron_conversions.cpp
Go to the documentation of this file.
1 #include "aron_conversions.h"
2 
4 
8 
10 
12 {
13 
14 }
15 
17 {
18 
19  void
20  fromAron(const armarx::human::arondto::HumanPose& dto, HumanPose& bo)
21  {
23 
24  fromAron(dto.poseModelId, bo.poseModelId);
25  bo.humanTrackingId = dto.humanTrackingId;
26  bo.cameraFrameName = dto.cameraFrameName;
27  fromAron(dto.keypoints, bo.keypoints);
28  }
29 
30  void
31  toAron(armarx::human::arondto::HumanPose& dto, const HumanPose& bo)
32  {
34 
35  toAron(dto.poseModelId, bo.poseModelId);
36  dto.humanTrackingId = bo.humanTrackingId;
37  dto.cameraFrameName = bo.cameraFrameName;
38  toAron(dto.keypoints, bo.keypoints);
39  }
40 
41  void
42  fromAron(const std::map<std::string, armarx::human::arondto::PoseKeypoint>& dto,
43  std::map<std::string, armarx::armem::human::PoseKeypoint>& bo)
44  {
45  bo.clear();
46  for (const auto& [keypoint_name, keypoint] : dto)
47  {
49  keypoint_bo.label = keypoint_name;
50  fromAron(keypoint, keypoint_bo);
51  bo[keypoint_name] = keypoint_bo;
52  }
53  }
54 
55  void
56  toAron(std::map<std::string, armarx::human::arondto::PoseKeypoint>& dto,
57  const std::map<std::string, armarx::armem::human::PoseKeypoint>& bo)
58  {
59  dto.clear();
60  for (const auto& [keypoint_name, keypoint] : bo)
61  {
62  armarx::human::arondto::PoseKeypoint keypoint_dto;
63  toAron(keypoint_dto, keypoint);
64  dto[keypoint_name] = keypoint_dto;
65  }
66  }
67 
68  void
69  fromAron(const armarx::human::arondto::PoseKeypoint& dto, PoseKeypoint& bo)
70  {
71  armarx::fromAron(dto.positionCamera, bo.positionCamera);
72  armarx::fromAron(dto.orientationCamera, bo.orientationCamera);
73  armarx::fromAron(dto.positionRobot, bo.positionRobot);
74  armarx::fromAron(dto.orientationRobot, bo.orientationRobot);
75  armarx::fromAron(dto.positionGlobal, bo.positionGlobal);
76  armarx::fromAron(dto.orientationGlobal, bo.orientationGlobal);
77  bo.confidence = dto.confidence;
78  }
79 
80  void
81  toAron(armarx::human::arondto::PoseKeypoint& dto, const PoseKeypoint& bo)
82  {
83  armarx::toAron(dto.positionCamera, bo.positionCamera);
84  armarx::toAron(dto.orientationCamera, bo.orientationCamera);
85  armarx::toAron(dto.positionRobot, bo.positionRobot);
86  armarx::toAron(dto.orientationRobot, bo.orientationRobot);
87  armarx::toAron(dto.positionGlobal, bo.positionGlobal);
88  armarx::toAron(dto.orientationGlobal, bo.orientationGlobal);
89  dto.confidence = bo.confidence;
90  }
91 
92  void
93  fromAron(const armarx::human::arondto::HumanPose2D& dto, HumanPose2D& bo)
94  {
96 
98 
99  fromAron(dto.poseModelId, bo.poseModelId);
100  bo.humanTrackingId = dto.humanTrackingId;
101  bo.cameraFrameName = dto.cameraFrameName;
102  fromAron(dto.keypoints, bo.keypoints);
103  }
104 
105  void
106  toAron(armarx::human::arondto::HumanPose2D& dto, const HumanPose2D& bo)
107  {
108  using armarx::aron::toAron;
109 
110  toAron(dto.poseModelId, bo.poseModelId);
111  dto.humanTrackingId = bo.humanTrackingId;
112  dto.cameraFrameName = bo.cameraFrameName;
113  toAron(dto.keypoints, bo.keypoints);
114  }
115 
116  void
117  fromAron(const std::map<std::string, armarx::human::arondto::PoseKeypoint2D>& dto,
118  std::map<std::string, armarx::armem::human::PoseKeypoint2D>& bo)
119  {
120  bo.clear();
121  for (const auto& [keypoint_name, keypoint] : dto)
122  {
124  keypoint_bo.label = keypoint_name;
125  fromAron(keypoint, keypoint_bo);
126  bo[keypoint_name] = keypoint_bo;
127  }
128  }
129 
130  void
131  toAron(std::map<std::string, armarx::human::arondto::PoseKeypoint2D>& dto,
132  const std::map<std::string, armarx::armem::human::PoseKeypoint2D>& bo)
133  {
134  dto.clear();
135  for (const auto& [keypoint_name, keypoint] : bo)
136  {
137  armarx::human::arondto::PoseKeypoint2D keypoint_dto;
138  toAron(keypoint_dto, keypoint);
139  dto[keypoint_name] = keypoint_dto;
140  }
141  }
142 
143  void
144  fromAron(const armarx::human::arondto::PoseKeypoint2D& dto, PoseKeypoint2D& bo)
145  {
146  bo.position = Eigen::Vector2f(dto.x, dto.y);
147  bo.confidence = dto.confidence;
148  }
149 
150  void
151  toAron(armarx::human::arondto::PoseKeypoint2D& dto, const PoseKeypoint2D& bo)
152  {
153  dto.x = bo.position.x();
154  dto.y = bo.position.y();
155  dto.confidence = bo.confidence;
156  }
157 
158  void
159  fromAron(const armarx::human::arondto::FaceRecognition& dto, FaceRecognition& bo)
160  {
161  bo.position3DGlobal = Eigen::Matrix(dto.position3DGlobal);
162  bo.extents2D = Eigen::Matrix(dto.extents2D);
163  bo.position2D = Eigen::Matrix(dto.position2D);
164  FramedPosition dtoFramedPosition;
165  armarx::aron::framed::fromAron(dto.framedPosition3D, dtoFramedPosition);
166  bo.framedPosition3D = FramedPosition(dtoFramedPosition);
167  if (dto.profileID.has_value())
168  {
169  armarx::armem::arondto::MemoryID dtoID = dto.profileID.value();
171  armarx::armem::fromAron(dtoID, boID);
172  bo.profileID = boID;
173  }
174  }
175 
176  void
177  toAron(armarx::human::arondto::FaceRecognition& dto, const FaceRecognition& bo)
178  {
179  dto.position3DGlobal = Eigen::Matrix(bo.position3DGlobal);
180  dto.extents2D = Eigen::Matrix(bo.extents2D);
181  dto.position2D = Eigen::Matrix(bo.position2D);
182  armarx::aron::framed::toAron(dto.framedPosition3D, bo.framedPosition3D);
183  if (bo.profileID.has_value())
184  {
185  armarx::armem::MemoryID boID = bo.profileID.value();
187  armarx::armem::toAron(dtoID, boID);
188  dto.profileID = dtoID;
189  }
190  // dto.profileID = armarx::aron::toAron<armarx::armem::arondto::MemoryID>(bo.profileID);
191  }
192 
193  void
194  fromAron(const armarx::human::arondto::PersonInstance& dto, PersonInstance& bo)
195  {
196  armarx::armem::fromAron(dto.profileID, bo.profileID);
197  armarx::armem::fromAron(dto.faceRecognitionID, bo.faceRecognitionID);
198  armarx::armem::fromAron(dto.poseID, bo.poseID);
199  bo.pose = Pose(dto.pose);
200  }
201 
202  void
203  toAron(armarx::human::arondto::PersonInstance& dto, const PersonInstance& bo)
204  {
205  armarx::armem::toAron(dto.profileID, bo.profileID);
206  armarx::armem::toAron(dto.faceRecognitionID, bo.faceRecognitionID);
207  armarx::armem::toAron(dto.poseID, bo.poseID);
208  dto.pose = Eigen::Matrix4f(bo.pose.toEigen());
209  }
210 
211 } // namespace armarx::armem::human
armarx::armem::human::PoseKeypoint2D::label
std::string label
Definition: types.h:43
Matrix
Eigen::Matrix< T, 3, 3 > Matrix
Definition: UnscentedKalmanFilterTest.cpp:37
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
framed.h
armarx::aron::framed::toAron
void toAron(arondto::FramedPosition &dto, const armarx::FramedPosition &bo)
Definition: framed.cpp:18
armarx::armem::human::toAron
void toAron(armarx::human::arondto::HumanPose &dto, const HumanPose &bo)
Definition: aron_conversions.cpp:31
armarx::armem::human::FaceRecognition
Definition: types.h:59
armarx::armem::toAron
void toAron(arondto::MemoryID &dto, const MemoryID &bo)
Definition: aron_conversions.cpp:19
trace.h
armarx::armem::human::HumanPose2D
Definition: types.h:50
armarx::aron::framed::fromAron
void fromAron(const arondto::FramedPosition &dto, armarx::FramedPosition &bo)
Definition: framed.cpp:8
armarx::armem::human::PoseKeypoint::label
std::string label
Definition: types.h:19
aron_conversions.h
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:69
armarx::armem::human::PoseKeypoint
Definition: types.h:17
types.h
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
armarx::FramedPosition
The FramedPosition class.
Definition: FramedPose.h:142
armarx::armem::human::PersonInstance
Definition: types.h:73
armarx::armem::human::PoseKeypoint2D
Definition: types.h:41
armarx::armem::human::HumanPose
Definition: types.h:30
aron_conversions.h
armarx::armem::fromAron
void fromAron(const arondto::MemoryID &dto, MemoryID &bo)
Definition: aron_conversions.cpp:8
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::armem::server::human
Definition: aron_conversions.cpp:11
armarx::aron::toAron
void toAron(T &dto, const T &bo)
Framework for converting ARON DTOs (Data Transfer Objects) to C++ BOs (Business Objects) and back.
Definition: aron_conversions.h:74
armarx::fromAron
void fromAron(const arondto::PackagePath &dto, PackageFileLocation &bo)
armarx::armem::human
Definition: aron_conversions.cpp:16
armarx::toAron
void toAron(arondto::PackagePath &dto, const PackageFileLocation &bo)
armarx::VariantType::FramedPosition
const VariantTypeId FramedPosition
Definition: FramedPose.h:39
armarx::aron::fromAron
void fromAron(const T &dto, T &bo)
Definition: aron_conversions.h:79
armarx::aron::bo
const std::optional< BoT > & bo
Definition: aron_conversions.h:168
armarx::armem::human::fromAron
void fromAron(const armarx::human::arondto::HumanPose &dto, HumanPose &bo)
Definition: aron_conversions.cpp:20
armarx::human::MemoryID
const armem::MemoryID MemoryID
Definition: memory_ids.cpp:29