34 #include <RobotAPI/interface/visualization/DebugDrawerInterface.h>
35 #include <VisionX/interface/components/DeepSegmenterInterface.h>
38 #include <VisionX/interface/components/PointCloudSegmenter.h>
40 #include <pcl/filters/filter.h>
41 #include <pcl/filters/passthrough.h>
42 #include <pcl/common/transforms.h>
43 #include <pcl/io/pcd_io.h>
44 #include <pcl/point_types.h>
45 #include <pcl/features/normal_3d_omp.h>
46 #include <pcl/features/fpfh_omp.h>
47 #include <pcl/search/kdtree.h>
48 #include <pcl/kdtree/kdtree_flann.h>
49 #include <pcl/correspondence.h>
50 #include <pcl/recognition/cg/geometric_consistency.h>
57 #include <Image/ByteImage.h>
65 using PointL = pcl::PointXYZL;
89 defineOptionalProperty<std::string>(
"DebugDrawerTopicName",
"DebugDrawerUpdates",
"Name of the debug drawer topic");
90 defineOptionalProperty<std::string>(
"DeepSegmenterTopicName",
"DeepSegmenterPythonUpdates",
"Name of the deep segmenter topic");
91 defineOptionalProperty<std::string>(
"segmentationMethod",
"EC",
"Name of the offered segmentation method (EC, LCCP or RG)");
92 defineOptionalProperty<bool>(
"StartEnabled",
true,
"Enable or disable the segmentation by default");
93 defineOptionalProperty<bool>(
"SingleRun",
false,
"Segment only one scene after each enable call");
96 defineOptionalProperty<int>(
"lccpMinimumSegmentSize", 10,
"Minimum segment size required for the lccp segmentation");
97 defineOptionalProperty<float>(
"lccpVoxelResolution", 25,
"Supervoxel resolution required for the lccp segmentation");
98 defineOptionalProperty<float>(
"lccpSeedResolution", 80,
"Seed resolution required for the lccp segmentation");
99 defineOptionalProperty<float>(
"lccpColorImportance", 0.0,
"Color importance required for the lccp segmentation");
100 defineOptionalProperty<float>(
"lccpSpatialImportance", 1.0,
"Spatial importance required for the lccp segmentation");
101 defineOptionalProperty<float>(
"lccpNormalImportance", 4.0,
"Normal importance required for the lccp segmentation");
102 defineOptionalProperty<float>(
"lccpConcavityThreshold", 10.0,
"Concavity threshold required for the lccp segmentation");
103 defineOptionalProperty<float>(
"lccpSmoothnessThreshold", 0.1,
"Smoothness threshold required for the lccp segmentation");
106 defineOptionalProperty<float>(
"rgSmoothnessThreshold", 6.0,
"Smoothness threshold required for the region growing segmentation");
107 defineOptionalProperty<float>(
"rgCurvatureThreshold", 50.0,
"Curvature threshold required for the region growing segmentation");
110 defineOptionalProperty<bool>(
"VisualizeCropBox",
false,
"Visualize crop box via debug drawer");
124 :
virtual public PointCloudSegmenterInterface
136 return "PointCloudSegmenter";
139 void changePointCloudProvider(
const std::string& providerName,
const Ice::Current&
c = Ice::emptyCurrent)
override;
145 void onInitPointCloudProcessor()
override;
150 void onConnectPointCloudProcessor()
override;
155 void onDisconnectPointCloudProcessor()
override;
160 void onExitPointCloudProcessor()
override;
165 void process()
override;
172 void enablePipelineStep(
const Ice::Current&
c = Ice::emptyCurrent)
override;
173 void disablePipelineStep(
const Ice::Current&
c = Ice::emptyCurrent)
override;
174 bool isPipelineStepEnabled(
const Ice::Current&
c = Ice::emptyCurrent)
override;
175 armarx::TimestampBasePtr getLastProcessedTimestamp(
const Ice::Current&
c = Ice::emptyCurrent)
override;
177 void setLccpParameters(
const LccpParameters& parameters,
const Ice::Current&
c = Ice::emptyCurrent)
override;
178 void loadLccpParametersFromFile(
const std::string&
filename,
const Ice::Current&
c = Ice::emptyCurrent)
override;
180 LccpParameters getLccpParameters(
const Ice::Current&
c = Ice::emptyCurrent)
override;
182 void setRgParameters(
float smoothnessThreshold,
float curvatureThreshold,
const Ice::Current&
c = Ice::emptyCurrent)
override;
183 void loadRgParametersFromFile(
const std::string&
filename,
const Ice::Current&
c = Ice::emptyCurrent)
override;
185 void createRemoteGuiTab();
186 void RemoteGui_update()
override;
189 void convertFromXYZRGBAtoXYZL(pcl::PointCloud<pcl::PointXYZRGBA>::Ptr& sourceCloudPtr, pcl::PointCloud<pcl::PointXYZL>::Ptr& targetCloudPtr);
190 void pushColoredLabeledCloudtoBuffer();
201 std::mutex timestampMutex;
202 long lastProcessedTimestamp;
204 std::mutex enableMutex;
207 std::mutex providerMutex;
208 std::string providerName;
209 std::string segmentationMethod;
218 float concavityThres;
219 float smoothnessThes;
222 float rgSmoothnessThes;
223 float rgCurvatureThres;
225 void colorizeLabeledCloud();
228 armarx::DeepSegmenterInterfacePrx deepSegmenterTopic;
229 armarx::Blob rgbImage;