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