ImageToPointCloud.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 ActiveVision::ArmarXObjects::ImageToPointCloud
17 * @author Markus Grotz ( markus dot grotz at kit dot edu )
18 * @author Mirko Waechter ( waechter at kit dot edu )
19 * @date 2019
20 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21 * GNU General Public License
22 */
23
24#pragma once
25
26#include <mutex>
27
28#include <pcl/point_types.h>
29
31#include <ArmarXCore/interface/observers/ObserverInterface.h>
32
33#include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
34
37#include <VisionX/interface/components/ImageToPointCloud.h>
40
41#include "DepthImageUtils.h"
42
43namespace armarx
44{
45
46
47 typedef pcl::PointXYZRGBL PointL;
48
49 /**
50 * @class ImageToPointCloudPropertyDefinitions
51 * @brief
52 */
54 {
55 public:
58 {
59 defineOptionalProperty<std::string>("DebugObserverName",
60 "DebugObserver",
61 "Name of the topic the DebugObserver listens on");
62 // defineOptionalProperty<std::string>("DebugDrawerTopicName", "DebugDrawerUpdates", "Name of the DebugDrawerTopic");
63 defineOptionalProperty<int>("PointCloudWidth",
64 640,
65 "Must match the image width (cannot be read automaically "
66 "from imageprovider as early as needed)");
67 defineOptionalProperty<int>("PointCloudHeight",
68 480,
69 "Must match the image height (cannot be read automaically "
70 "from imageprovider as early as needed)");
71
72 defineOptionalProperty<float>("VerticalViewAngle",
73 43.0f,
74 "The vertical viewing angle of the camera. Only used "
75 "when no calibration can be retrieved.");
76 defineOptionalProperty<float>("HorizontalViewAngle",
77 57.0f,
78 "The horizontal viewing angle of the camera. Only used "
79 "when no calibration can be retrieved.");
81 "ComputeViewAngleFromCalibration",
82 true,
83 "Use the field of view provided by the calibration provider");
84
85
87 "NaNValue", -1.0, "NaN value to use if reported disparity is not available.");
89 "MaxDist",
90 -1.0,
91 "The maximum distance for measurements. Ignored if smaller than zero");
93 "MinDist", 0.0, "The minimum distance for measurements. ");
94
95 defineOptionalProperty<float>("PointCloudRotationZ",
96 180.0f,
97 "Rotation around Z of the provided pointcloud",
99
101 "ProviderName",
102 "ImageProvider name. image[0]: rgb image, image[1]: depth image, "
103 "image[2](optional): label integer");
104 defineOptionalProperty<std::string>("CalibrationProviderName",
105 "",
106 "CalibrationProvider name. Optional. Useful if the "
107 "images are processed and forwarded.");
108 }
109 };
110
111 /**
112 * @defgroup Component-ImageToPointCloud ImageToPointCloud
113 * @ingroup VisionX-Components
114 * A description of the component ImageToPointCloud.
115 *
116 * @class ImageToPointCloud
117 * @ingroup Component-ImageToPointCloud
118 * @brief Brief description of class ImageToPointCloud.
119 *
120 * Detailed description of class ImageToPointCloud.
121 */
123 virtual public visionx::PointCloudProvider,
124 virtual public visionx::ImageProcessor,
125 virtual public armarx::ImageToPointCloudInterface
126 {
127 public:
128 /// @see armarx::ManagedIceObject::getDefaultName()
129 std::string getDefaultName() const override
130 {
131 return GetDefaultName();
132 }
133
134 static std::string GetDefaultName();
135
136 void
140
141 void
145
146 visionx::StereoCalibration
147 getStereoCalibration(const Ice::Current& c = Ice::emptyCurrent) override
148 {
149 return calibrationPrx->getStereoCalibration();
150 }
151
152 bool
153 getImagesAreUndistorted(const Ice::Current& c = Ice::emptyCurrent) override
154 {
155 return calibrationPrx->getImagesAreUndistorted();
156 }
157
158 std::string
159 getReferenceFrame(const Ice::Current& c = Ice::emptyCurrent) override
160 {
161 return calibrationPrx->getReferenceFrame();
162 }
163
164
165 protected:
166 void onInitImageProcessor() override;
167 void onConnectImageProcessor() override;
168 void onExitImageProcessor() override;
169 void process() override;
170
171 virtual visionx::MetaPointCloudFormatPtr getDefaultPointCloudFormat();
172
173 void
179
180 void
186
187 void
193
194 void onDisconnectComponent() override;
195
196 /**
197 * @see PropertyUser::createPropertyDefinitions()
198 */
200
201 private:
202 // armarx::DebugDrawerInterfacePrx debugDrawer;
204 visionx::StereoCalibrationInterfacePrx calibrationPrx;
205
206 armarx::MetaInfoSizeBasePtr imageMetaInfo;
207
208 float fovH;
209 float fovV;
210
211 std::mutex mutex;
212 float nanValue;
213 float maxDist;
214 float minDist;
215 int processCounter = 0;
216
217 std::string providerName;
218 CByteImage** images;
219 size_t numImages;
220 visionx::ImageProviderInfo imageProviderInfo;
221 DepthImageUtils depthImageUtils;
222 pcl::PointCloud<PointL>::Ptr cloud, transformedCloud;
223 };
224} // namespace armarx
constexpr T c
Brief description of class ImageToPointCloud.
std::string getReferenceFrame(const Ice::Current &c=Ice::emptyCurrent) override
virtual armarx::PropertyDefinitionsPtr createPropertyDefinitions()
void onInitComponent() override
Pure virtual hook for the subclass.
virtual visionx::MetaPointCloudFormatPtr getDefaultPointCloudFormat()
default point cloud format used to initialize shared memory
void onConnectImageProcessor() override
Implement this method in the ImageProcessor in order execute parts when the component is fully initia...
void onDisconnectComponent() override
Hook for subclass.
void onExitImageProcessor() override
Exit the ImapeProcessor component.
visionx::StereoCalibration getStereoCalibration(const Ice::Current &c=Ice::emptyCurrent) override
void process() override
Process the vision component.
void onInitImageProcessor() override
Setup the vision component.
bool getImagesAreUndistorted(const Ice::Current &c=Ice::emptyCurrent) override
void onConnectComponent() override
Pure virtual hook for the subclass.
void onInitPointCloudProvider()
This is called when the Component::onInitComponent() is called.
static std::string GetDefaultName()
void onExitComponent() override
Hook for subclass.
void onExitPointCloudProvider()
This is called when the Component::onExitComponent() setup is called.
std::string getDefaultName() const override
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)
ImageProcessorPropertyDefinitions(std::string prefix)
The ImageProcessor class provides an interface for access to ImageProviders via Ice and shared memory...
void onInitComponent() override
void onConnectComponent() override
void onExitComponent() override
PointCloudProvider abstract class defines a component which provide point clouds via ice or shared me...
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
pcl::PointXYZRGBL PointL
ArmarX headers.