HumanPoseK4ABTBody32.cpp
Go to the documentation of this file.
1 #include "HumanPoseK4ABTBody32.h"
2 
3 #include <SimoxUtility/color/GlasbeyLUT.h>
4 
6 
7 namespace armarx::viz
8 {
9 
11 
12  void
14  const HumanPoseLayers& layers,
15  const std::string& prefix)
16  {
17  static const int segmentThickness = 20;
18  static const int jointThickness = 30;
19 
20  //const armarx::viz::Color colorCylinder =
21  // armarx::viz::Color::fromRGBA(1, 1, 1, 1); // TODO: Random, seed with person ID.
22 
23  // Segments.
24  for (const auto& [index1, index2] : Segments)
25  {
26  const std::string& name1 = JointNames.map().left.at(index1);
27  const std::string& name2 = JointNames.map().left.at(index2);
28 
29  // Only draw segment if start end end are in keypoint map.
30  if (pose.keypoints.find(name1) == pose.keypoints.end() or
31  pose.keypoints.find(name2) == pose.keypoints.end())
32  {
33  continue;
34  }
35 
36  const armarx::armem::human::PoseKeypoint p1 = pose.keypoints.at(name1);
37  const armarx::armem::human::PoseKeypoint p2 = pose.keypoints.at(name2);
38 
39  const Eigen::Vector3f pos1 = p1.positionGlobal->toEigen();
40  const Eigen::Vector3f pos2 = p2.positionGlobal->toEigen();
41 
42  if (pos1.allFinite() and pos2.allFinite())
43  {
44  if (pos1 == Eigen::Vector3f(0, 0, 0) or pos2 == Eigen::Vector3f(0, 0, 0))
45  {
46  continue;
47  }
48 
49  armarx::viz::Color color = Colors.at(JointNames.from_name(p2.label));
50 
52  armarx::viz::Cylinder(prefix + "::" + p1.label + "_" + p2.label)
53  .fromTo(pos1, pos2)
54  .radius(segmentThickness)
55  .color(color);
56  layers.skeleton.add(line);
57  }
58  }
59 
60  // Keypoints.
61  for (auto const& [id, name] : JointNames.map())
62  {
63  const auto it = pose.keypoints.find(name);
64  if (it != pose.keypoints.end())
65  {
67  armarx::viz::Color color = Colors.at(JointNames.from_name(kp.label));
68 
69  armarx::viz::Sphere sphere = armarx::viz::Sphere(prefix + "::" + name)
70  .position(kp.positionGlobal->toEigen())
71  .radius(jointThickness)
72  .color(color);
73 
74  if (kp.orientationGlobal.has_value())
75  {
76  armarx::viz::Pose pose = armarx::viz::Pose(prefix + "::" + name + "_pose")
77  .pose(kp.positionGlobal.value().toEigen(),
78  kp.orientationGlobal.value().toEigen());
79  layers.frames.add(pose);
80  }
81 
82  layers.skeleton.add(sphere);
83  }
84  }
85  }
86 
87 
88 } // namespace armarx::viz
armarx::viz::Cylinder::radius
Cylinder & radius(float r)
Definition: Elements.h:78
armarx::navigation::core::Pose
Eigen::Isometry3f Pose
Definition: basic_types.h:31
armarx::viz::Cylinder::fromTo
Cylinder & fromTo(Eigen::Vector3f from, Eigen::Vector3f to)
Definition: Elements.cpp:82
armarx::human::pose::model::k4a_bt_body_32
This file is part of ArmarX.
Definition: k4a_bt_body_32.h:32
armarx::armem::human::PoseKeypoint::orientationGlobal
std::optional< armarx::FramedOrientation > orientationGlobal
Definition: types.h:27
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
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::viz::k4abt_body_32::addPoseToLayer
void addPoseToLayer(const armarx::armem::human::HumanPose &pose, const HumanPoseLayers &layers, const std::string &prefix)
Definition: HumanPoseK4ABTBody32.cpp:13
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
armarx::viz::Cylinder
Definition: Elements.h:74
armarx::viz::Sphere::radius
Sphere & radius(float r)
Definition: Elements.h:138
armarx::viz::HumanPoseLayers::frames
viz::Layer & frames
Definition: HumanPose.h:18
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::viz::Pose
Definition: Elements.h:179
armarx::armem::human::HumanPose
Definition: types.h:30
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
HumanPoseK4ABTBody32.h
armarx::viz::HumanPoseLayers
Definition: HumanPose.h:15
armarx::armem::human::HumanPose::keypoints
KeyPointMap keypoints
Definition: types.h:35
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