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
39namespace armarx
40{
41 /**
42 * @class MaskFilterPointCloudProcessorPropertyDefinitions
43 * @brief
44 */
47 {
48 public:
51 {
53 "DebugDrawerTopicName",
54 "DebugDrawerUpdates",
55 "Name of the debug drawer topic that should be used");
56
58 "RobotStateComponentName",
59 "RobotStateComponent",
60 "Name of the robot state component that should be used");
62 "RemoteGuiName", "RemoteGuiProvider", "Name of the remote gui");
63
64 defineRequiredProperty<std::string>("MaskImageProvider",
65 "The Image Provider used to get a mask");
66
68 "PointCloudProviderReferenceFrameOverride",
69 "",
70 "If set, the component will assume incoming point clouds to be in this frame");
72 "MaskImageProviderReferenceFrameOverride",
73 "",
74 "If set, the component will assume incoming mask images to be in this frame");
75
77 "CalibrationProviderName",
78 "",
79 "An alternative component to receive calibration data from (mono or stereo)");
80
82 "PointCloudReportFrame", "root", "The frame used to report the point clouds");
83
85 "MaskRedHi", 255, "Higher bound for the mask color's red channel");
87 "MaskGreenHi", 255, "Higher bound for the mask color's green channel");
89 "MaskBlueHi", 255, "Higher bound for the mask color's blue channel");
91 "MaskRedLo", 0, "Lower bound for the mask color's red channel");
93 "MaskGreenLo", 0, "Lower bound for the mask color's green channel");
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;
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
Brief description of class MaskFilterPointCloudProcessor.
visionx::PointCloudProviderInterfacePrx _pointCloudProvider
visionx::ImageProviderInterfacePrx _maskImageProvider
void onDisconnectPointCloudAndImageProcessor() override
Implement this method in the PointCloudAndImageProcessor in order to execute parts when the component...
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr _maskedCloud
void onConnectPointCloudAndImageProcessor() override
Implement this method in your PointCloudAndImageProcessor in order execute parts when the component i...
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void process() override
Process the vision component.
std::array< float, 3 > uvz2xyz(int u, int v, float z, float fx, float fy) const
std::vector< visionx::CByteImageUPtr > _maskImageProviderImageOwner
RobotStateComponentInterfacePrx _robotStateComponent
void onInitPointCloudAndImageProcessor() override
Setup the vision component.
visionx::PointCloudProviderInfo _pointCloudProviderInfo
std::pair< float, float > maskImageProviderFocalLength() const
pcl::PointCloud< pcl::PointXYZRGBA >::Ptr _inputCloud
void onExitPointCloudAndImageProcessor() override
Exit the ImapeProcessor component.
std::array< std::int64_t, 2 > xyz2uv(float x, float y, float z, float fx, float fy) const
IceUtil::Handle< PeriodicTask< T > > pointer_type
Shared pointer type for convenience.
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
PropertyDefinition< PropertyType > & defineRequiredProperty(const std::string &name, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
The PointCloudAndImageProcessor class provides an interface for access to PointCloudProviders and Ima...
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugDrawerInterface > DebugDrawerInterfacePrx
ArmarX headers.