MaskFilterPointCloudProcessor.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::MaskFilterPointCloudProcessor
17  * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
18  * @date 2018
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 #include <atomic>
26 
27 #include <VirtualRobot/Robot.h>
28 
31 
32 #include <RobotAPI/interface/core/RobotState.h>
33 
34 #include <ArmarXGui/interface/RemoteGuiInterface.h>
36 
38 
39 namespace armarx
40 {
41  /**
42  * @class MaskFilterPointCloudProcessorPropertyDefinitions
43  * @brief
44  */
47  {
48  public:
51  {
52  defineOptionalProperty<std::string>("DebugDrawerTopicName", "DebugDrawerUpdates", "Name of the debug drawer topic that should be used");
53 
54  defineOptionalProperty<std::string>("RobotStateComponentName", "RobotStateComponent", "Name of the robot state component that should be used");
55  defineOptionalProperty<std::string>("RemoteGuiName", "RemoteGuiProvider", "Name of the remote gui");
56 
57  defineRequiredProperty<std::string>("MaskImageProvider", "The Image Provider used to get a mask");
58 
59  defineOptionalProperty<std::string>("PointCloudProviderReferenceFrameOverride", "", "If set, the component will assume incoming point clouds to be in this frame");
60  defineOptionalProperty<std::string>("MaskImageProviderReferenceFrameOverride", "", "If set, the component will assume incoming mask images to be in this frame");
61 
62  defineOptionalProperty<std::string>("CalibrationProviderName", "", "An alternative component to receive calibration data from (mono or stereo)");
63 
64  defineOptionalProperty<std::string>("PointCloudReportFrame", "root", "The frame used to report the point clouds");
65 
66  defineOptionalProperty<int>("MaskRedHi", 255, "Higher bound for the mask color's red channel");
67  defineOptionalProperty<int>("MaskGreenHi", 255, "Higher bound for the mask color's green channel");
68  defineOptionalProperty<int>("MaskBlueHi", 255, "Higher bound for the mask color's blue channel");
69  defineOptionalProperty<int>("MaskRedLo", 0, "Lower bound for the mask color's red channel");
70  defineOptionalProperty<int>("MaskGreenLo", 0, "Lower bound for the mask color's green channel");
71  defineOptionalProperty<int>("MaskBlueLo", 128, "Lower bound for the mask color's blue channel");
72  }
73  };
74 
75  /**
76  * @defgroup Component-MaskFilterPointCloudProcessor MaskFilterPointCloudProcessor
77  * @ingroup VisionX-Components
78  * A description of the component MaskFilterPointCloudProcessor.
79  *
80  * @class MaskFilterPointCloudProcessor
81  * @ingroup Component-MaskFilterPointCloudProcessor
82  * @brief Brief description of class MaskFilterPointCloudProcessor.
83  *
84  * Detailed description of class MaskFilterPointCloudProcessor.
85  */
88  {
89  public:
90  /**
91  * @see armarx::ManagedIceObject::getDefaultName()
92  */
93  std::string getDefaultName() const override
94  {
95  return "MaskFilterPointCloudProcessor";
96  }
97 
98  protected:
99  void process() override;
100 
101  void onInitPointCloudAndImageProcessor() override;
102  void onConnectPointCloudAndImageProcessor() override;
105 
106  std::pair<float, float> maskImageProviderFocalLength() const;
107 
108  std::array<std::int64_t, 2> xyz2uv(float x, float y, float z, float fx, float fy) const;
109  std::array<float, 3> uvz2xyz(int u, int v, float z, float fx, float fy) const;
110  /**
111  * @see PropertyUser::createPropertyDefinitions()
112  */
114  protected:
115  template<typename PointType> void process();
116  //robot sync
120  std::atomic_bool _syncRobotWithTimestamp{false};
121  //visualize
124  std::string _remoteGuiName;
125  RemoteGuiInterfacePrx _remoteGui;
128  //filter settings
129  std::atomic<std::uint8_t> _redLo;
130  std::atomic<std::uint8_t> _redHi;
131  std::atomic<std::uint8_t> _blueLo;
132  std::atomic<std::uint8_t> _blueHi;
133  std::atomic<std::uint8_t> _greenLo;
134  std::atomic<std::uint8_t> _greenHi;
135  std::atomic<float> _focalLengthAdjustment;
136  std::atomic<float> _maskZRotation;
139  std::atomic_bool _flipX {false};
140  std::atomic_bool _flipY {false};
141  std::atomic_bool _maskMatchOneRangeInsteadOfAll {false};
142  std::atomic<std::int64_t> _offsetX;
143  std::atomic<std::int64_t> _offsetY;
144  std::atomic<std::int64_t> _guiParamUpdated{false};
145  //point clouds
148  visionx::PointCloudProviderInterfacePrx _pointCloudProvider;
150 
151  std::mutex _cloudMutex;
152  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr _maskedCloud;
153  pcl::PointCloud<pcl::PointXYZRGBA>::Ptr _inputCloud;
154  //mask image
157  visionx::ImageProviderInterfacePrx _maskImageProvider;
158  std::vector<visionx::CByteImageUPtr> _maskImageProviderImageOwner;
159  std::vector<void*> _maskImageProviderImages;
163  //state
164  bool _newMaskImage {false};
165  bool _newPointCloud {false};
166  };
167 }
armarx::MaskFilterPointCloudProcessor::_maskImageProvider
visionx::ImageProviderInterfacePrx _maskImageProvider
Definition: MaskFilterPointCloudProcessor.h:157
armarx::MaskFilterPointCloudProcessor::_guiTab
RemoteGui::TabProxy _guiTab
Definition: MaskFilterPointCloudProcessor.h:127
armarx::MaskFilterPointCloudProcessor::_redLo
std::atomic< std::uint8_t > _redLo
Definition: MaskFilterPointCloudProcessor.h:129
PointCloudAndImageProcessor.h
armarx::MaskFilterPointCloudProcessor::getDefaultName
std::string getDefaultName() const override
Definition: MaskFilterPointCloudProcessor.h:93
armarx::MaskFilterPointCloudProcessor::maskImageProviderFocalLength
std::pair< float, float > maskImageProviderFocalLength() const
Definition: MaskFilterPointCloudProcessor.cpp:336
armarx::MaskFilterPointCloudProcessor::_maskMatchOneRangeInsteadOfAll
std::atomic_bool _maskMatchOneRangeInsteadOfAll
Definition: MaskFilterPointCloudProcessor.h:141
armarx::MaskFilterPointCloudProcessor::_inputCloud
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr _inputCloud
Definition: MaskFilterPointCloudProcessor.h:153
armarx::MaskFilterPointCloudProcessor::onInitPointCloudAndImageProcessor
void onInitPointCloudAndImageProcessor() override
Setup the vision component.
Definition: MaskFilterPointCloudProcessor.cpp:64
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
armarx::MaskFilterPointCloudProcessor::_maskedCloud
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr _maskedCloud
Definition: MaskFilterPointCloudProcessor.h:152
armarx::MaskFilterPointCloudProcessor::_redHi
std::atomic< std::uint8_t > _redHi
Definition: MaskFilterPointCloudProcessor.h:130
armarx::MaskFilterPointCloudProcessor::_localRobot
VirtualRobot::RobotPtr _localRobot
Definition: MaskFilterPointCloudProcessor.h:119
armarx::MaskFilterPointCloudProcessor::_maskImageProviderName
std::string _maskImageProviderName
Definition: MaskFilterPointCloudProcessor.h:155
armarx::MaskFilterPointCloudProcessor::_pointCloudReportFrame
std::string _pointCloudReportFrame
Definition: MaskFilterPointCloudProcessor.h:138
armarx::MaskFilterPointCloudProcessor::_maskImageProviderFocalLengthY
float _maskImageProviderFocalLengthY
Definition: MaskFilterPointCloudProcessor.h:162
armarx::MaskFilterPointCloudProcessor::_maskImageProviderFocalLengthX
float _maskImageProviderFocalLengthX
Definition: MaskFilterPointCloudProcessor.h:161
armarx::MaskFilterPointCloudProcessor::_focalLengthAdjustment
std::atomic< float > _focalLengthAdjustment
Definition: MaskFilterPointCloudProcessor.h:135
armarx::MaskFilterPointCloudProcessor::_offsetY
std::atomic< std::int64_t > _offsetY
Definition: MaskFilterPointCloudProcessor.h:143
armarx::MaskFilterPointCloudProcessor::_robotStateComponentName
std::string _robotStateComponentName
Definition: MaskFilterPointCloudProcessor.h:117
armarx::MaskFilterPointCloudProcessor::_guiTask
SimplePeriodicTask ::pointer_type _guiTask
Definition: MaskFilterPointCloudProcessor.h:126
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
armarx::MaskFilterPointCloudProcessor::_blueLo
std::atomic< std::uint8_t > _blueLo
Definition: MaskFilterPointCloudProcessor.h:131
armarx::MaskFilterPointCloudProcessor::_cloudMutex
std::mutex _cloudMutex
Definition: MaskFilterPointCloudProcessor.h:151
armarx::MaskFilterPointCloudProcessor::_pointCloudProviderRefFrame
std::string _pointCloudProviderRefFrame
Definition: MaskFilterPointCloudProcessor.h:149
visionx::PointCloudProcessorPropertyDefinitions::PointCloudProcessorPropertyDefinitions
PointCloudProcessorPropertyDefinitions(std::string prefix)
Definition: PointCloudProcessor.cpp:111
armarx::MaskFilterPointCloudProcessor::_syncRobotWithTimestamp
std::atomic_bool _syncRobotWithTimestamp
Definition: MaskFilterPointCloudProcessor.h:120
armarx::MaskFilterPointCloudProcessor::_flipX
std::atomic_bool _flipX
Definition: MaskFilterPointCloudProcessor.h:139
armarx::MaskFilterPointCloudProcessor::_greenHi
std::atomic< std::uint8_t > _greenHi
Definition: MaskFilterPointCloudProcessor.h:134
armarx::MaskFilterPointCloudProcessor::_remoteGuiName
std::string _remoteGuiName
Definition: MaskFilterPointCloudProcessor.h:124
armarx::MaskFilterPointCloudProcessor::_guiParamUpdated
std::atomic< std::int64_t > _guiParamUpdated
Definition: MaskFilterPointCloudProcessor.h:144
visionx::PointCloudProviderInfo
Definition: PointCloudProcessor.h:83
visionx::ImageProviderInfo
Definition: ImageProcessor.h:466
armarx::MaskFilterPointCloudProcessor::_debugDrawerTopic
DebugDrawerInterfacePrx _debugDrawerTopic
Definition: MaskFilterPointCloudProcessor.h:123
armarx::RemoteGui::TabProxy
Definition: WidgetProxy.h:17
armarx::MaskFilterPointCloudProcessor
Brief description of class MaskFilterPointCloudProcessor.
Definition: MaskFilterPointCloudProcessor.h:86
armarx::MaskFilterPointCloudProcessor::_maskImageProviderRefFrame
std::string _maskImageProviderRefFrame
Definition: MaskFilterPointCloudProcessor.h:160
armarx::MaskFilterPointCloudProcessorPropertyDefinitions
Definition: MaskFilterPointCloudProcessor.h:45
armarx::MaskFilterPointCloudProcessor::onExitPointCloudAndImageProcessor
void onExitPointCloudAndImageProcessor() override
Exit the ImapeProcessor component.
Definition: MaskFilterPointCloudProcessor.h:104
armarx::MaskFilterPointCloudProcessor::_offsetX
std::atomic< std::int64_t > _offsetX
Definition: MaskFilterPointCloudProcessor.h:142
armarx::MaskFilterPointCloudProcessor::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: MaskFilterPointCloudProcessor.cpp:386
WidgetProxy.h
visionx::PointCloudProcessorPropertyDefinitions
Properties of PointCloudProcessor.
Definition: PointCloudProcessor.h:173
armarx::MaskFilterPointCloudProcessor::_newPointCloud
bool _newPointCloud
Definition: MaskFilterPointCloudProcessor.h:165
TaskUtil.h
armarx::MaskFilterPointCloudProcessor::_pointCloudProviderInfo
visionx::PointCloudProviderInfo _pointCloudProviderInfo
Definition: MaskFilterPointCloudProcessor.h:147
armarx::MaskFilterPointCloudProcessorPropertyDefinitions::MaskFilterPointCloudProcessorPropertyDefinitions
MaskFilterPointCloudProcessorPropertyDefinitions(std::string prefix)
Definition: MaskFilterPointCloudProcessor.h:49
Component.h
armarx::MaskFilterPointCloudProcessor::_robotStateComponent
RobotStateComponentInterfacePrx _robotStateComponent
Definition: MaskFilterPointCloudProcessor.h:118
armarx::MaskFilterPointCloudProcessor::_maskImageProviderImages
std::vector< void * > _maskImageProviderImages
Definition: MaskFilterPointCloudProcessor.h:159
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
armarx::MaskFilterPointCloudProcessor::_remoteGui
RemoteGuiInterfacePrx _remoteGui
Definition: MaskFilterPointCloudProcessor.h:125
armarx::MaskFilterPointCloudProcessor::_pointCloudProvider
visionx::PointCloudProviderInterfacePrx _pointCloudProvider
Definition: MaskFilterPointCloudProcessor.h:148
armarx::MaskFilterPointCloudProcessor::_newMaskImage
bool _newMaskImage
Definition: MaskFilterPointCloudProcessor.h:164
armarx::MaskFilterPointCloudProcessor::xyz2uv
std::array< std::int64_t, 2 > xyz2uv(float x, float y, float z, float fx, float fy) const
Definition: MaskFilterPointCloudProcessor.cpp:363
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::MaskFilterPointCloudProcessor::_maskImageProviderImageOwner
std::vector< visionx::CByteImageUPtr > _maskImageProviderImageOwner
Definition: MaskFilterPointCloudProcessor.h:158
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::MaskFilterPointCloudProcessor::uvz2xyz
std::array< float, 3 > uvz2xyz(int u, int v, float z, float fx, float fy) const
Definition: MaskFilterPointCloudProcessor.cpp:341
armarx::MaskFilterPointCloudProcessor::_maskZRotation
std::atomic< float > _maskZRotation
Definition: MaskFilterPointCloudProcessor.h:136
armarx::MaskFilterPointCloudProcessor::onDisconnectPointCloudAndImageProcessor
void onDisconnectPointCloudAndImageProcessor() override
Implement this method in the PointCloudAndImageProcessor in order to execute parts when the component...
Definition: MaskFilterPointCloudProcessor.cpp:329
armarx::MaskFilterPointCloudProcessor::onConnectPointCloudAndImageProcessor
void onConnectPointCloudAndImageProcessor() override
Implement this method in your PointCloudAndImageProcessor in order execute parts when the component i...
Definition: MaskFilterPointCloudProcessor.cpp:89
armarx::MaskFilterPointCloudProcessor::_debugDrawerTopicName
std::string _debugDrawerTopicName
Definition: MaskFilterPointCloudProcessor.h:122
armarx::MaskFilterPointCloudProcessor::_pointCloudReportFrameMutex
std::mutex _pointCloudReportFrameMutex
Definition: MaskFilterPointCloudProcessor.h:137
armarx::MaskFilterPointCloudProcessor::_blueHi
std::atomic< std::uint8_t > _blueHi
Definition: MaskFilterPointCloudProcessor.h:132
armarx::MaskFilterPointCloudProcessor::_maskImageProviderInfo
visionx::ImageProviderInfo _maskImageProviderInfo
Definition: MaskFilterPointCloudProcessor.h:156
armarx::MaskFilterPointCloudProcessor::process
void process() override
Process the vision component.
Definition: MaskFilterPointCloudProcessor.cpp:59
armarx::MaskFilterPointCloudProcessor::_greenLo
std::atomic< std::uint8_t > _greenLo
Definition: MaskFilterPointCloudProcessor.h:133
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::MaskFilterPointCloudProcessor::_flipY
std::atomic_bool _flipY
Definition: MaskFilterPointCloudProcessor.h:140
armarx::SimplePeriodicTask
Usage:
Definition: ApplicationNetworkStats.h:32
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
visionx::PointCloudAndImageProcessor
The PointCloudAndImageProcessor class provides an interface for access to PointCloudProviders and Ima...
Definition: PointCloudAndImageProcessor.h:97
armarx::MaskFilterPointCloudProcessor::_pointCloudProviderName
std::string _pointCloudProviderName
Definition: MaskFilterPointCloudProcessor.h:146