HumanPose.cpp
Go to the documentation of this file.
1#include "HumanPose.h"
2
4
11
12namespace armarx
13{
14
15 void
17 HumanPoseLayers& layers,
18 const std::string& prefix,
19 const DrawingStyle& drawingStyle)
20 {
21 namespace mmm_model_body_68 = human::pose::model::mmm_body_68;
22 namespace k4a_bt_body_32 = human::pose::model::k4a_bt_body_32;
23 namespace openpose_body_25 = human::pose::model::openpose_body_25;
24
25 if (pose.poseModelId == openpose_body_25::ModelId)
26 {
27 body_25::addPoseToLayer(pose, layers, prefix, drawingStyle);
28 }
29 else if (pose.poseModelId == k4a_bt_body_32::ModelId)
30 {
31 k4abt_body_32::addPoseToLayer(pose, layers, prefix, drawingStyle);
32 }
33 else if (pose.poseModelId == mmm_model_body_68::ModelId)
34 {
35 mmm_body_68::addPoseToLayer(pose, layers, prefix, drawingStyle);
36 }
37 else
38 {
39 ARMARX_WARNING << "Unknown pose model ID '" << pose.poseModelId << "'. No generic "
40 << "visualization is available at this point.";
41
42 generic::addPoseToLayer(pose, layers, prefix, drawingStyle);
43 }
44 }
45
46 void
47 viz::addPosesToLayer(const std::map<std::string, armarx::armem::human::HumanPose>& poses,
48 HumanPoseLayers& layers,
49 const std::string& prefix,
50 const DrawingStyle& drawingStyle)
51 {
52 for (const auto& [name, pose] : poses)
53 {
54 addPoseToLayer(pose, layers, prefix + name, drawingStyle);
55 }
56 }
57
58 void
60 HumanPoseLayers& layers,
61 const std::string& prefix,
62 const DrawingStyle& drawingStyle)
63 {
64 static const int jointThickness = 30;
65 armarx::viz::Color color =
66 armarx::viz::Color::fromRGBA(1, 1, 1, 1); // TODO: Random, seed with person ID.
67
68 // Cannot visualize segments without pose model information.
69
70 // Keypoints.
71 for (auto const& [name, kp] : pose.keypoints)
72 {
73 armarx::viz::Sphere sphere = armarx::viz::Sphere(prefix + "::" + name)
74 .position(kp.positionGlobal->toEigen())
75 .radius(jointThickness)
76 .color(color);
77 layers.skeleton.add(sphere);
78 }
79 }
80
81
82} // namespace armarx
DerivedT & color(Color color)
Definition ElementOps.h:218
DerivedT & position(float x, float y, float z)
Definition ElementOps.h:136
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193
This file is part of ArmarX.
Definition mmm_body_68.h:28
void addPoseToLayer(const armarx::armem::human::HumanPose &pose, HumanPoseLayers &layer, const std::string &prefix, const DrawingStyle &drawingStyle=DrawingStyle())
void addPoseToLayer(const armarx::armem::human::HumanPose &pose, HumanPoseLayers &layers, const std::string &prefix, const DrawingStyle &drawingStyle=DrawingStyle())
Definition HumanPose.cpp:59
void addPoseToLayer(const armarx::armem::human::HumanPose &pose, const HumanPoseLayers &layers, const std::string &prefix, const DrawingStyle &drawingStyle=DrawingStyle())
void addPoseToLayer(const armarx::armem::human::HumanPose &pose, HumanPoseLayers &layers, const std::string &prefix, const DrawingStyle &drawingStyle=DrawingStyle())
void addPosesToLayer(const std::map< std::string, armarx::armem::human::HumanPose > &poses, HumanPoseLayers &layers, const std::string &prefix, const DrawingStyle &drawingStyle=DrawingStyle())
Definition HumanPose.cpp:47
void addPoseToLayer(const armarx::armem::human::HumanPose &pose, HumanPoseLayers &layers, const std::string &prefix, const DrawingStyle &drawingStyle=DrawingStyle())
Definition HumanPose.cpp:16
This file offers overloads of toIce() and fromIce() functions for STL container types.
void add(ElementT const &element)
Definition Layer.h:31
Sphere & radius(float r)
Definition Elements.h:138