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 "DepthImageUtils.h"
27 
30 
33 
34 #include <VisionX/interface/components/ImageToPointCloud.h>
35 
36 
37 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
39 #include <ArmarXCore/interface/observers/ObserverInterface.h>
40 
41 #include <pcl/point_types.h>
42 
43 #include <mutex>
44 
45 namespace armarx
46 {
47 
48 
49  typedef pcl::PointXYZRGBL PointL;
50 
51 
52  /**
53  * @class ImageToPointCloudPropertyDefinitions
54  * @brief
55  */
58  {
59  public:
62  {
63  defineOptionalProperty<std::string>("DebugObserverName", "DebugObserver", "Name of the topic the DebugObserver listens on");
64  // defineOptionalProperty<std::string>("DebugDrawerTopicName", "DebugDrawerUpdates", "Name of the DebugDrawerTopic");
65  defineOptionalProperty<int>("PointCloudWidth", 640, "Must match the image width (cannot be read automaically from imageprovider as early as needed)");
66  defineOptionalProperty<int>("PointCloudHeight", 480, "Must match the image height (cannot be read automaically from imageprovider as early as needed)");
67 
68  defineOptionalProperty<float>("VerticalViewAngle", 43.0f, "The vertical viewing angle of the camera. Only used when no calibration can be retrieved.");
69  defineOptionalProperty<float>("HorizontalViewAngle", 57.0f, "The horizontal viewing angle of the camera. Only used when no calibration can be retrieved.");
70  defineOptionalProperty<bool>("ComputeViewAngleFromCalibration", true, "Use the field of view provided by the calibration provider");
71 
72 
73  defineOptionalProperty<float>("NaNValue", -1.0, "NaN value to use if reported disparity is not available.");
74  defineOptionalProperty<float>("MaxDist", -1.0, "The maximum distance for measurements. Ignored if smaller than zero");
75  defineOptionalProperty<float>("MinDist", 0.0, "The minimum distance for measurements. ");
76 
77  defineOptionalProperty<float>("PointCloudRotationZ", 180.0f, "Rotation around Z of the provided pointcloud", PropertyDefinitionBase::eModifiable);
78 
79  defineRequiredProperty<std::string>("ProviderName", "ImageProvider name. image[0]: rgb image, image[1]: depth image, image[2](optional): label integer");
80  defineOptionalProperty<std::string>("CalibrationProviderName", "", "CalibrationProvider name. Optional. Useful if the images are processed and forwarded.");
81  }
82  };
83 
84  /**
85  * @defgroup Component-ImageToPointCloud ImageToPointCloud
86  * @ingroup VisionX-Components
87  * A description of the component ImageToPointCloud.
88  *
89  * @class ImageToPointCloud
90  * @ingroup Component-ImageToPointCloud
91  * @brief Brief description of class ImageToPointCloud.
92  *
93  * Detailed description of class ImageToPointCloud.
94  */
96  virtual public visionx::PointCloudProvider,
97  virtual public visionx::ImageProcessor,
98  virtual public armarx::ImageToPointCloudInterface
99  {
100  public:
101  /**
102  * @see armarx::ManagedIceObject::getDefaultName()
103  */
104  std::string getDefaultName() const override
105  {
106  return "ImageToPointCloud";
107  }
108 
110  {
111 
112  }
113 
115  {
116 
117  }
118 
119  visionx::StereoCalibration getStereoCalibration(const Ice::Current& c = Ice::emptyCurrent) override
120  {
121  return calibrationPrx->getStereoCalibration();
122  }
123 
124  bool getImagesAreUndistorted(const Ice::Current& c = Ice::emptyCurrent) override
125  {
126  return calibrationPrx->getImagesAreUndistorted();
127  }
128 
129  std::string getReferenceFrame(const Ice::Current& c = Ice::emptyCurrent) override
130  {
131  return calibrationPrx->getReferenceFrame();
132  }
133 
134 
135  protected:
136 
137  void onInitImageProcessor() override;
138  void onConnectImageProcessor() override;
139  void onExitImageProcessor() override;
140  void process() override;
141 
142  virtual visionx::MetaPointCloudFormatPtr getDefaultPointCloudFormat();
143 
144  void onInitComponent() override
145  {
148  }
149 
150  void onConnectComponent() override
151  {
154  }
155 
156  void onExitComponent() override
157  {
160  }
161 
162  void onDisconnectComponent() override;
163 
164  /**
165  * @see PropertyUser::createPropertyDefinitions()
166  */
168 
169  private:
170  // armarx::DebugDrawerInterfacePrx debugDrawer;
171  armarx::DebugObserverInterfacePrx debugObserver;
172  visionx::StereoCalibrationInterfacePrx calibrationPrx;
173 
174  armarx::MetaInfoSizeBasePtr imageMetaInfo;
175 
176  float fovH;
177  float fovV;
178 
179  std::mutex mutex;
180  float nanValue;
181  float maxDist;
182  float minDist;
183  int processCounter = 0;
184 
185  std::string providerName;
186  CByteImage** images;
187  size_t numImages;
188  visionx::ImageProviderInfo imageProviderInfo;
189  DepthImageUtils depthImageUtils;
190  pcl::PointCloud<PointL>::Ptr cloud, transformedCloud;
191  };
192 }
armarx::ImageToPointCloud::getStereoCalibration
visionx::StereoCalibration getStereoCalibration(const Ice::Current &c=Ice::emptyCurrent) override
Definition: ImageToPointCloud.h:119
CapturingPointCloudProvider.h
visionx::PointCloudProvider::onConnectComponent
void onConnectComponent() override
Definition: PointCloudProvider.cpp:77
armarx::ImageToPointCloud::onInitComponent
void onInitComponent() override
Definition: ImageToPointCloud.h:144
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
visionx::ImageProcessor::onInitComponent
void onInitComponent() override
Definition: ImageProcessor.cpp:52
armarx::ImageToPointCloud::onExitPointCloudProvider
void onExitPointCloudProvider()
This is called when the Component::onExitComponent() setup is called.
Definition: ImageToPointCloud.h:114
visionx::ImageProcessor
The ImageProcessor class provides an interface for access to ImageProviders via Ice and shared memory...
Definition: ImageProcessor.h:87
visionx::ImageProcessor::onExitComponent
void onExitComponent() override
Definition: ImageProcessor.cpp:89
armarx::ImageToPointCloud::getDefaultName
std::string getDefaultName() const override
Definition: ImageToPointCloud.h:104
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
armarx::ImageToPointCloud::onInitPointCloudProvider
void onInitPointCloudProvider()
This is called when the Component::onInitComponent() is called.
Definition: ImageToPointCloud.h:109
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
visionx::ImageProcessorPropertyDefinitions::ImageProcessorPropertyDefinitions
ImageProcessorPropertyDefinitions(std::string prefix)
Definition: ImageProcessor.h:65
armarx::ImageToPointCloud::createPropertyDefinitions
virtual armarx::PropertyDefinitionsPtr createPropertyDefinitions()
Definition: ImageToPointCloud.cpp:280
armarx::ImageToPointCloud::getImagesAreUndistorted
bool getImagesAreUndistorted(const Ice::Current &c=Ice::emptyCurrent) override
Definition: ImageToPointCloud.h:124
visionx::PointCloudProvider::onExitComponent
void onExitComponent() override
Definition: PointCloudProvider.cpp:106
armarx::ImageToPointCloud
Brief description of class ImageToPointCloud.
Definition: ImageToPointCloud.h:95
visionx::ImageProviderInfo
Definition: ImageProcessor.h:466
armarx::ImageToPointCloud::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: ImageToPointCloud.cpp:120
visionx::ImageProcessor::onConnectComponent
void onConnectComponent() override
Definition: ImageProcessor.cpp:72
armarx::ImageToPointCloud::process
void process() override
Process the vision component.
Definition: ImageToPointCloud.cpp:137
armarx::DepthImageUtils
Definition: DepthImageUtils.h:12
armarx::ImageToPointCloud::onExitComponent
void onExitComponent() override
Definition: ImageToPointCloud.h:156
ImageProcessor.h
armarx::ImageToPointCloudPropertyDefinitions
Definition: ImageToPointCloud.h:56
armarx::ImageToPointCloud::getReferenceFrame
std::string getReferenceFrame(const Ice::Current &c=Ice::emptyCurrent) override
Definition: ImageToPointCloud.h:129
visionx::PointCloudProvider::onInitComponent
void onInitComponent() override
Definition: PointCloudProvider.cpp:59
armarx::ImageToPointCloud::onConnectComponent
void onConnectComponent() override
Definition: ImageToPointCloud.h:150
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:61
armarx::ImageToPointCloud::onInitImageProcessor
void onInitImageProcessor() override
Setup the vision component.
Definition: ImageToPointCloud.cpp:43
Component.h
armarx::ImageToPointCloudPropertyDefinitions::ImageToPointCloudPropertyDefinitions
ImageToPointCloudPropertyDefinitions(std::string prefix)
Definition: ImageToPointCloud.h:60
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:75
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:28
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:131