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 
43 namespace 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.");
80  defineOptionalProperty<bool>(
81  "ComputeViewAngleFromCalibration",
82  true,
83  "Use the field of view provided by the calibration provider");
84 
85 
86  defineOptionalProperty<float>(
87  "NaNValue", -1.0, "NaN value to use if reported disparity is not available.");
88  defineOptionalProperty<float>(
89  "MaxDist",
90  -1.0,
91  "The maximum distance for measurements. Ignored if smaller than zero");
92  defineOptionalProperty<float>(
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 
100  defineRequiredProperty<std::string>(
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  /**
129  * @see armarx::ManagedIceObject::getDefaultName()
130  */
131  std::string
132  getDefaultName() const override
133  {
134  return "ImageToPointCloud";
135  }
136 
137  void
139  {
140  }
141 
142  void
144  {
145  }
146 
147  visionx::StereoCalibration
148  getStereoCalibration(const Ice::Current& c = Ice::emptyCurrent) override
149  {
150  return calibrationPrx->getStereoCalibration();
151  }
152 
153  bool
154  getImagesAreUndistorted(const Ice::Current& c = Ice::emptyCurrent) override
155  {
156  return calibrationPrx->getImagesAreUndistorted();
157  }
158 
159  std::string
160  getReferenceFrame(const Ice::Current& c = Ice::emptyCurrent) override
161  {
162  return calibrationPrx->getReferenceFrame();
163  }
164 
165 
166  protected:
167  void onInitImageProcessor() override;
168  void onConnectImageProcessor() override;
169  void onExitImageProcessor() override;
170  void process() override;
171 
172  virtual visionx::MetaPointCloudFormatPtr getDefaultPointCloudFormat();
173 
174  void
175  onInitComponent() override
176  {
179  }
180 
181  void
183  {
186  }
187 
188  void
189  onExitComponent() override
190  {
193  }
194 
195  void onDisconnectComponent() override;
196 
197  /**
198  * @see PropertyUser::createPropertyDefinitions()
199  */
201 
202  private:
203  // armarx::DebugDrawerInterfacePrx debugDrawer;
204  armarx::DebugObserverInterfacePrx debugObserver;
205  visionx::StereoCalibrationInterfacePrx calibrationPrx;
206 
207  armarx::MetaInfoSizeBasePtr imageMetaInfo;
208 
209  float fovH;
210  float fovV;
211 
212  std::mutex mutex;
213  float nanValue;
214  float maxDist;
215  float minDist;
216  int processCounter = 0;
217 
218  std::string providerName;
219  CByteImage** images;
220  size_t numImages;
221  visionx::ImageProviderInfo imageProviderInfo;
222  DepthImageUtils depthImageUtils;
223  pcl::PointCloud<PointL>::Ptr cloud, transformedCloud;
224  };
225 } // namespace armarx
armarx::ImageToPointCloud::getStereoCalibration
visionx::StereoCalibration getStereoCalibration(const Ice::Current &c=Ice::emptyCurrent) override
Definition: ImageToPointCloud.h:148
CapturingPointCloudProvider.h
visionx::PointCloudProvider::onConnectComponent
void onConnectComponent() override
Definition: PointCloudProvider.cpp:80
armarx::ImageToPointCloud::onInitComponent
void onInitComponent() override
Definition: ImageToPointCloud.h:175
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::ImageProcessor::onInitComponent
void onInitComponent() override
Definition: ImageProcessor.cpp:55
armarx::ImageToPointCloud::onExitPointCloudProvider
void onExitPointCloudProvider()
This is called when the Component::onExitComponent() setup is called.
Definition: ImageToPointCloud.h:143
visionx::ImageProcessor
The ImageProcessor class provides an interface for access to ImageProviders via Ice and shared memory...
Definition: ImageProcessor.h:98
visionx::ImageProcessor::onExitComponent
void onExitComponent() override
Definition: ImageProcessor.cpp:97
armarx::ImageToPointCloud::getDefaultName
std::string getDefaultName() const override
Definition: ImageToPointCloud.h:132
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:345
armarx::ImageToPointCloud::onInitPointCloudProvider
void onInitPointCloudProvider()
This is called when the Component::onInitComponent() is called.
Definition: ImageToPointCloud.h:138
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
visionx::ImageProcessorPropertyDefinitions::ImageProcessorPropertyDefinitions
ImageProcessorPropertyDefinitions(std::string prefix)
Definition: ImageProcessor.h:64
armarx::ImageToPointCloud::createPropertyDefinitions
virtual armarx::PropertyDefinitionsPtr createPropertyDefinitions()
Definition: ImageToPointCloud.cpp:279
armarx::ImageToPointCloud::getImagesAreUndistorted
bool getImagesAreUndistorted(const Ice::Current &c=Ice::emptyCurrent) override
Definition: ImageToPointCloud.h:154
visionx::PointCloudProvider::onExitComponent
void onExitComponent() override
Definition: PointCloudProvider.cpp:112
armarx::ImageToPointCloud
Brief description of class ImageToPointCloud.
Definition: ImageToPointCloud.h:122
visionx::ImageProviderInfo
Definition: ImageProcessor.h:479
armarx::ImageToPointCloud::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: ImageToPointCloud.cpp:124
visionx::ImageProcessor::onConnectComponent
void onConnectComponent() override
Definition: ImageProcessor.cpp:78
armarx::ImageToPointCloud::process
void process() override
Process the vision component.
Definition: ImageToPointCloud.cpp:141
armarx::DepthImageUtils
Definition: DepthImageUtils.h:15
armarx::ImageToPointCloud::onExitComponent
void onExitComponent() override
Definition: ImageToPointCloud.h:189
ImageProcessor.h
armarx::ImageToPointCloudPropertyDefinitions
Definition: ImageToPointCloud.h:53
armarx::ImageToPointCloud::getReferenceFrame
std::string getReferenceFrame(const Ice::Current &c=Ice::emptyCurrent) override
Definition: ImageToPointCloud.h:160
visionx::PointCloudProvider::onInitComponent
void onInitComponent() override
Definition: PointCloudProvider.cpp:61
armarx::ImageToPointCloud::onConnectComponent
void onConnectComponent() override
Definition: ImageToPointCloud.h:182
armarx::ImageToPointCloud::onConnectImageProcessor
void onConnectImageProcessor() override
Implement this method in the ImageProcessor in order execute parts when the component is fully initia...
Definition: ImageToPointCloud.cpp:60
armarx::ImageToPointCloud::onInitImageProcessor
void onInitImageProcessor() override
Setup the vision component.
Definition: ImageToPointCloud.cpp:41
Component.h
armarx::ImageToPointCloudPropertyDefinitions::ImageToPointCloudPropertyDefinitions
ImageToPointCloudPropertyDefinitions(std::string prefix)
Definition: ImageToPointCloud.h:56
IceUtil::Handle< class PropertyDefinitionContainer >
visionx::ImageProcessorPropertyDefinitions
Definition: ImageProcessor.h:61
IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface >
DepthImageUtils.h
ImageUtil.h
TypeMapping.h
armarx::PropertyDefinitionBase::eModifiable
@ eModifiable
Definition: PropertyDefinitionInterface.h:57
armarx::PointL
pcl::PointXYZRGBL PointL
Definition: TabletopSegmentation.h:73
visionx::PointCloudProvider
PointCloudProvider abstract class defines a component which provide point clouds via ice or shared me...
Definition: PointCloudProvider.h:58
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::ImageToPointCloud::getDefaultPointCloudFormat
virtual visionx::MetaPointCloudFormatPtr getDefaultPointCloudFormat()
default point cloud format used to initialize shared memory
Definition: ImageToPointCloud.cpp:268
armarx::ImageToPointCloud::onExitImageProcessor
void onExitImageProcessor() override
Exit the ImapeProcessor component.
Definition: ImageToPointCloud.cpp:136