PersonInstance.cpp
Go to the documentation of this file.
1#include "PersonInstance.h"
2
3#include <string>
4
7
11
13
14namespace armarx::viz
15{
16 void
18 const std::string& name,
19 armarx::viz::Layer& personInstanceLayer,
20 const std::string& prefix)
21 {
23 static const int radius = 100;
24 armarx::viz::Color color = armarx::viz::Color::fromRGBA(255, 255, 0, 255);
25 Eigen::Matrix pos3D = faceReco.position3DGlobal;
26 armarx::viz::Sphere facePos = armarx::viz::Sphere("Person instance of " + name)
27 .position(pos3D.x(), pos3D.y(), pos3D.z())
28 .radius(radius)
29 .color(color);
30 Eigen::Matrix4f nameTagRotation;
31 nameTagRotation << -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1;
32 armarx::viz::Text nameTag =
33 armarx::viz::Text("Name of" + name)
34 .text(name)
35 .scale(15)
36 .pose(nameTagRotation)
37 .position(pos3D.x(), pos3D.y() + (int)(radius / 2) + 10, pos3D.z());
38 personInstanceLayer.add(facePos);
39 personInstanceLayer.add(nameTag);
40 }
41
42 void
44 const std::string& name,
45 armarx::viz::Layer& personInstanceLayer,
46 const std::string& prefix)
47 {
49
50 if (personInstance.globalPose.matrix().isIdentity())
51 {
52 ARMARX_VERBOSE << "Global pose is identity -> not set. Won't visualize pose.";
53 return;
54 }
55
56 static const int radius = 100;
57
58 // Face: position
59 {
60 armarx::viz::Color color = armarx::viz::Color::fromRGBA(255, 255, 0, 255);
61 armarx::viz::Sphere facePos = armarx::viz::Sphere("Position:" + name)
62 .position(personInstance.globalPose.translation())
63 .radius(radius)
64 .color(color);
65 personInstanceLayer.add(facePos);
66 }
67
68 // Face: orientation
69 // if (not personInstance.globalPose.linear().isIdentity())
70 // {
71 // armarx::viz::Pose facePose = armarx::viz::Pose("Pose:" + name)
72 // .position(personInstance.globalPose.translation())
73 // .scale(radius / 10);
74 // personInstanceLayer.add(facePose);
75 // }
76
77 // Name tag
78 {
79 Eigen::Matrix4f nameTagRotation;
80 nameTagRotation << -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1;
81 armarx::viz::Text nameTag =
82 armarx::viz::Text("Name:" + name)
83 .text(name)
84 .scale(15)
85 .pose(nameTagRotation)
86 .position(personInstance.globalPose.translation() +
87 Eigen::Vector3f::UnitY() * ((radius / 2) + 10));
88 personInstanceLayer.add(nameTag);
89 }
90 }
91
92} // namespace armarx::viz
DerivedT & pose(Eigen::Matrix4f const &pose)
Definition ElementOps.h:176
DerivedT & color(Color color)
Definition ElementOps.h:218
DerivedT & position(float x, float y, float z)
Definition ElementOps.h:136
DerivedT & scale(Eigen::Vector3f scale)
Definition ElementOps.h:254
#define ARMARX_VERBOSE
The logging level for verbose information.
Definition Logging.h:187
This file is part of ArmarX.
void addPersonInstanceToLayer(const armarx::armem::human::FaceRecognition &faceReco, const std::string &name, armarx::viz::Layer &personInstanceLayer, const std::string &prefix)
Eigen::Isometry3f globalPose
Definition types.h:90
void add(ElementT const &element)
Definition Layer.h:31
Sphere & radius(float r)
Definition Elements.h:138
Text & text(std::string const &t)
Definition Elements.h:188
#define ARMARX_TRACE
Definition trace.h:77