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