OpenPoseEstimationComponent.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package VisionX::ArmarXObjects::OpenPoseEstimation
17 * @author Stefan Reither ( stef dot reither at web dot de )
18 * @date 2018
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22#pragma once
23
24// STD/STL
25#include <mutex>
26
27// IVT
28#include <Image/ByteImage.h>
29#include <Image/ImageProcessor.h>
30#include <Math/Math2d.h>
31#include <Math/Math3d.h>
32
33// Simox
34#include <VirtualRobot/Robot.h>
35
36// ArmarX
39
41#include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
43
45
46// OpenPose stuff
47#include <VisionX/interface/components/OpenPoseEstimationInterface.h>
49
51
52namespace armarx
53{
55 public OpenPoseEstimationInterface,
57 {
58 public:
60
61 // Helper functions
62 virtual void preOnInitImageProcessor();
63 virtual void preOnConnectImageProcessor();
64 virtual void postOnConnectImageProcessor();
65 virtual void preOnDisconnectImageProcessor();
66 virtual void postOnDisconnectImageProcessor();
67
69
70 // HumanPoseEstimation Interface
71 void enableHumanPoseEstimation(const EnableHumanPoseEstimationInput& input,
72 const Ice::Current& = Ice::emptyCurrent) override;
73
74 // OpenPoseEstimation Interface
75 void start(const Ice::Current& = Ice::emptyCurrent) override;
76 void stop(const Ice::Current& = Ice::emptyCurrent) override;
77 void start3DPoseEstimation(const Ice::Current& = Ice::emptyCurrent) override;
78 void stop3DPoseEstimation(const Ice::Current& = Ice::emptyCurrent) override;
79
80 virtual void renderOutputImage(const op::Array<float>&);
81 virtual void reportEntities();
82 virtual void visualize();
83
84 protected:
85 // main loop
86 void loop();
87
88 public:
89 bool active_upon_startup = false;
90
91 // ImageBuffer und ImageInformations
92 CByteImage** imageBuffer;
93 unsigned int numImages;
95 armarx::MetaInfoSizeBasePtr imageMetaInfo;
96 std::mutex imageBufferMutex;
97
98 visionx::ImageFormatInfo rgbImageFormat;
99 CByteImage* rgbImageBuffer;
101
102 // ErrorCounters
103 std::uint64_t timeoutCounter2d{0};
104 std::uint64_t readErrorCounter2d{0};
105 std::uint64_t sucessCounter2d{0};
106
107 // Topics
108 OpenPose2DListenerPrx listener2DPrx;
109
110 // OpenPose Buffers
111 HumanPose2DMap openposeResult;
112
113 // ImageBuffer und ImageInformations
116 std::atomic_bool result_image_ready = false;
117
118 // OpenPose renderer
120 float op_render_threshold = 0.05f;
122
125
126 // Visualization
127 std::string layerName = "OpenPoseEstimation";
128
129 // Threads and program flow information
131 std::atomic_bool running2D = false;
132 std::atomic_bool update_ready; // Is true, if new updates are available
133 std::atomic_long
134 timestamp_of_update; // Contains the timestamp of the currently available update
135 };
136} // namespace armarx
void start3DPoseEstimation(const Ice::Current &=Ice::emptyCurrent) override
armarx::RunningTask< OpenPoseEstimationComponentPluginUser >::pointer_type openposeTask
void stop(const Ice::Current &=Ice::emptyCurrent) override
void start(const Ice::Current &=Ice::emptyCurrent) override
void stop3DPoseEstimation(const Ice::Current &=Ice::emptyCurrent) override
virtual void postCreatePropertyDefinitions(PropertyDefinitionsPtr &properties)
void enableHumanPoseEstimation(const EnableHumanPoseEstimationInput &input, const Ice::Current &=Ice::emptyCurrent) override
virtual void renderOutputImage(const op::Array< float > &)
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< OpenPoseAdapter > MonocularOpenPoseEstimationPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.