31 #include <pcl/common/transforms.h>
32 #include <pcl/correspondence.h>
33 #include <pcl/features/fpfh_omp.h>
34 #include <pcl/features/normal_3d_omp.h>
35 #include <pcl/filters/filter.h>
36 #include <pcl/filters/passthrough.h>
37 #include <pcl/io/pcd_io.h>
38 #include <pcl/kdtree/kdtree_flann.h>
39 #include <pcl/point_types.h>
40 #include <pcl/recognition/cg/geometric_consistency.h>
41 #include <pcl/search/kdtree.h>
48 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
51 #include <VisionX/interface/components/DeepSegmenterInterface.h>
52 #include <VisionX/interface/components/PointCloudSegmenter.h>
58 #include <Image/ByteImage.h>
64 using PointL = pcl::PointXYZL;
89 defineOptionalProperty<std::string>(
90 "DebugDrawerTopicName",
"DebugDrawerUpdates",
"Name of the debug drawer topic");
91 defineOptionalProperty<std::string>(
"DeepSegmenterTopicName",
92 "DeepSegmenterPythonUpdates",
93 "Name of the deep segmenter topic");
94 defineOptionalProperty<std::string>(
97 "Name of the offered segmentation method (EC, LCCP or RG)");
98 defineOptionalProperty<bool>(
99 "StartEnabled",
true,
"Enable or disable the segmentation by default");
100 defineOptionalProperty<bool>(
101 "SingleRun",
false,
"Segment only one scene after each enable call");
104 defineOptionalProperty<int>(
"lccpMinimumSegmentSize",
106 "Minimum segment size required for the lccp segmentation");
107 defineOptionalProperty<float>(
108 "lccpVoxelResolution",
110 "Supervoxel resolution required for the lccp segmentation");
111 defineOptionalProperty<float>(
112 "lccpSeedResolution", 80,
"Seed resolution required for the lccp segmentation");
113 defineOptionalProperty<float>(
114 "lccpColorImportance", 0.0,
"Color importance required for the lccp segmentation");
115 defineOptionalProperty<float>(
"lccpSpatialImportance",
117 "Spatial importance required for the lccp segmentation");
118 defineOptionalProperty<float>(
"lccpNormalImportance",
120 "Normal importance required for the lccp segmentation");
121 defineOptionalProperty<float>(
"lccpConcavityThreshold",
123 "Concavity threshold required for the lccp segmentation");
124 defineOptionalProperty<float>(
125 "lccpSmoothnessThreshold",
127 "Smoothness threshold required for the lccp segmentation");
130 defineOptionalProperty<float>(
131 "rgSmoothnessThreshold",
133 "Smoothness threshold required for the region growing segmentation");
134 defineOptionalProperty<float>(
135 "rgCurvatureThreshold",
137 "Curvature threshold required for the region growing segmentation");
140 defineOptionalProperty<bool>(
141 "VisualizeCropBox",
false,
"Visualize crop box via debug drawer");
155 virtual public PointCloudSegmenterInterface,
168 return "PointCloudSegmenter";
171 void changePointCloudProvider(
const std::string& providerName,
172 const Ice::Current&
c = Ice::emptyCurrent)
override;
178 void onInitPointCloudProcessor()
override;
183 void onConnectPointCloudProcessor()
override;
188 void onDisconnectPointCloudProcessor()
override;
193 void onExitPointCloudProcessor()
override;
198 void process()
override;
205 void enablePipelineStep(
const Ice::Current&
c = Ice::emptyCurrent)
override;
206 void disablePipelineStep(
const Ice::Current&
c = Ice::emptyCurrent)
override;
207 bool isPipelineStepEnabled(
const Ice::Current&
c = Ice::emptyCurrent)
override;
208 armarx::TimestampBasePtr
209 getLastProcessedTimestamp(
const Ice::Current&
c = Ice::emptyCurrent)
override;
211 void setLccpParameters(
const LccpParameters& parameters,
212 const Ice::Current&
c = Ice::emptyCurrent)
override;
213 void loadLccpParametersFromFile(
const std::string&
filename,
214 const Ice::Current&
c = Ice::emptyCurrent)
override;
216 LccpParameters getLccpParameters(
const Ice::Current&
c = Ice::emptyCurrent)
override;
218 void setRgParameters(
float smoothnessThreshold,
219 float curvatureThreshold,
220 const Ice::Current&
c = Ice::emptyCurrent)
override;
221 void loadRgParametersFromFile(
const std::string&
filename,
222 const Ice::Current&
c = Ice::emptyCurrent)
override;
224 void createRemoteGuiTab();
225 void RemoteGui_update()
override;
228 void convertFromXYZRGBAtoXYZL(pcl::PointCloud<pcl::PointXYZRGBA>::Ptr& sourceCloudPtr,
229 pcl::PointCloud<pcl::PointXYZL>::Ptr& targetCloudPtr);
230 void pushColoredLabeledCloudtoBuffer();
241 std::mutex timestampMutex;
242 long lastProcessedTimestamp;
244 std::mutex enableMutex;
247 std::mutex providerMutex;
248 std::string providerName;
249 std::string segmentationMethod;
258 float concavityThres;
259 float smoothnessThes;
262 float rgSmoothnessThes;
263 float rgCurvatureThres;
265 void colorizeLabeledCloud();
268 armarx::DeepSegmenterInterfacePrx deepSegmenterTopic;
269 armarx::Blob rgbImage;