HumanPoseBody25.cpp
Go to the documentation of this file.
1 #include "HumanPoseBody25.h"
2 
6 
7 
8 namespace armarx::viz
9 {
10 
12 
13  void
15  HumanPoseLayers &layers,
16  const std::string& prefix)
17  {
19  static const int segmentThickness = 20;
20  static const int jointThickness = 30;
21 
22  // Segments.
23  for (const auto& [index1, index2] : Segments)
24  {
25  const std::string& name1 = JointNames.map().left.at(index1);
26  const std::string& name2 = JointNames.map().left.at(index2);
27 
28  // Only draw segment if start end end are in keypoint map.
29  if (pose.keypoints.find(name1) == pose.keypoints.end() or
30  pose.keypoints.find(name2) == pose.keypoints.end())
31  {
32  continue;
33  }
34 
35  const armarx::armem::human::PoseKeypoint p1 = pose.keypoints.at(name1);
36  const armarx::armem::human::PoseKeypoint p2 = pose.keypoints.at(name2);
37 
38  const Eigen::Vector3f pos1 = p1.positionGlobal->toEigen();
39  const Eigen::Vector3f pos2 = p2.positionGlobal->toEigen();
40 
41  if (pos1.allFinite() and pos2.allFinite())
42  {
43  if (pos1 == Eigen::Vector3f(0, 0, 0) or pos2 == Eigen::Vector3f(0, 0, 0))
44  {
45  continue;
46  }
47 
48  const armarx::viz::Color color = Colors.at(index2);
49 
51  armarx::viz::Cylinder(prefix + "::" + p1.label + "_" + p2.label)
52  .fromTo(pos1, pos2)
53  .radius(segmentThickness)
54  .color(color);
55  layers.skeleton.add(line);
56  }
57  }
58 
59  // Keypoints.
60  for (auto const& [id, name] : JointNames.map())
61  {
62  if (pose.keypoints.find(name) != pose.keypoints.end() and
63  name != JointNames.map().left.at(Joints::Background))
64  {
66 
67  const armarx::viz::Color color= Colors.at(id);
68  armarx::viz::Sphere sphere = armarx::viz::Sphere(prefix + "::" + name)
69  .position(kp.positionGlobal->toEigen())
70  .radius(jointThickness)
71  .color(color);
72  layers.skeleton.add(sphere);
73  }
74  }
75  }
76 
77 } // namespace armarx::viz
armarx::viz::Cylinder::radius
Cylinder & radius(float r)
Definition: Elements.h:78
armarx::viz::Cylinder::fromTo
Cylinder & fromTo(Eigen::Vector3f from, Eigen::Vector3f to)
Definition: Elements.cpp:82
armarx::armem::human::PoseKeypoint::label
std::string label
Definition: types.h:19
armarx::viz::Layer::add
void add(ElementT const &element)
Definition: Layer.h:29
armarx::viz::Sphere
Definition: Elements.h:134
Elements.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_TRACE
#define ARMARX_TRACE
Definition: trace.h:69
armarx::armem::human::PoseKeypoint
Definition: types.h:17
armarx::human::pose::model::k4a_bt_body_32::JointNames
const simox::meta::EnumNames< Joints > JointNames
Names of the joints as defined in the body model.
Definition: k4a_bt_body_32.h:78
HumanPoseBody25.h
armarx::viz::Cylinder
Definition: Elements.h:74
armarx::viz::Sphere::radius
Sphere & radius(float r)
Definition: Elements.h:138
armarx::human::pose::model::k4a_bt_body_32::Segments
const std::vector< std::pair< Joints, Joints > > Segments
Segments (defined by pairs of joints) as defined in the body model.
Definition: k4a_bt_body_32.h:114
armarx::viz::Color
Definition: Color.h:13
armarx::armem::human::HumanPose
Definition: types.h:30
openpose_body_25.h
armarx::viz::body_25::addPoseToLayer
void addPoseToLayer(const armarx::armem::human::HumanPose &pose, HumanPoseLayers &layer, const std::string &prefix)
Definition: HumanPoseBody25.cpp:14
armarx::viz::ElementOps::color
DerivedT & color(Color color)
Definition: ElementOps.h:195
armarx::armem::human::PoseKeypoint::positionGlobal
std::optional< armarx::FramedPosition > positionGlobal
Definition: types.h:26
armarx::viz::HumanPoseLayers
Definition: HumanPose.h:15
armarx::human::pose::model::openpose_body_25
This file is part of ArmarX.
Definition: openpose_body_25.h:28
armarx::armem::human::HumanPose::keypoints
KeyPointMap keypoints
Definition: types.h:35
Logging.h
armarx::viz
This file is part of ArmarX.
Definition: ArVizStorage.cpp:416
armarx::human::pose::model::k4a_bt_body_32::Colors
const std::map< Joints, simox::Color > Colors
Definition: k4a_bt_body_32.h:148