25 #include <pcl/octree/octree.h>
37 usingProxy(getProperty<std::string>(
"PointCloudProviderName").getValue());
38 usingProxy(getProperty<std::string>(
"PointCloudSegmenterName").getValue());
39 usingProxy(getProperty<std::string>(
"PrimitiveExtractorName").getValue());
43 exportDirectory = getProperty<std::string>(
"ExportDirectory").getValue();
51 ARMARX_ERROR <<
"Could not find point cloud files in ArmarXDataPath";
59 << getProperty<std::string>(
"GroundTruthPointCloud").getValue();
91 bestFitness = -std::numeric_limits<float>::infinity();
122 getProperty<std::string>(
"PointCloudProviderName").getValue());
125 ARMARX_ERROR <<
"Could not obtain point cloud provider proxy";
130 getProperty<std::string>(
"PointCloudSegmenterName").getValue());
133 ARMARX_ERROR <<
"Could not obtain point cloud segmenter proxy";
138 getProperty<std::string>(
"PrimitiveExtractorName").getValue());
172 pcl::PointCloud<pcl::PointXYZL>::Ptr primitives(
new pcl::PointCloud<pcl::PointXYZL>());
214 const pcl::PointCloud<pcl::PointXYZL>::Ptr& labeled,
215 const pcl::PointCloud<pcl::PointXYZRGBL>::Ptr& reference)
217 ARMARX_INFO << labeled->size() <<
" points in segmentation point cloud";
218 ARMARX_INFO << reference->size() <<
" points in ground truth point cloud";
220 pcl::octree::OctreePointCloudSearch<pcl::PointXYZL> octree(50);
221 octree.setInputCloud(labeled);
222 octree.addPointsFromInputCloud();
224 std::map<unsigned int, unsigned int> labelMap;
226 unsigned int num_covered = 0;
227 for (
auto& p : reference->points)
230 std::vector<float> squaredDistances;
237 if (octree.nearestKSearch(
q, 1,
indices, squaredDistances) > 0 && squaredDistances[0] < 50)
239 if (labelMap.find(p.label) == labelMap.end())
241 labelMap[p.label] = labeled->points[
indices[0]].label;
243 if (labelMap[p.label] == labeled->points[
indices[0]].label)
250 return ((
float)num_covered) / reference->size();
305 s <<
"Randomly determined parameter set: {" << std::endl
306 <<
" extractionPrm.minSegmentSize: " <<
extractionPrm.minSegmentSize <<
"," << std::endl
307 <<
" extractionPrm.maxSegmentSize: " <<
extractionPrm.maxSegmentSize <<
"," << std::endl
308 <<
" extractionPrm.euclideanClusteringTolerance: "
309 <<
extractionPrm.euclideanClusteringTolerance <<
"," << std::endl
310 <<
" extractionPrm.outlierThreshold: " <<
extractionPrm.outlierThreshold <<
","
312 <<
" extractionPrm.planeMaxIterations: " <<
extractionPrm.planeMaxIterations <<
","
314 <<
" extractionPrm.planeDistanceThreshold: " <<
extractionPrm.planeDistanceThreshold <<
","
316 <<
" extractionPrm.planeNormalDistance: " <<
extractionPrm.planeNormalDistance <<
","
318 <<
" extractionPrm.cylinderMaxIterations: " <<
extractionPrm.cylinderMaxIterations <<
","
320 <<
" extractionPrm.cylinderDistanceThreshold: " <<
extractionPrm.cylinderDistanceThreshold
322 <<
" extractionPrm.cylinderRadiusLimit: " <<
extractionPrm.cylinderRadiusLimit <<
","
324 <<
" extractionPrm.sphereMaxIterations: " <<
extractionPrm.sphereMaxIterations <<
","
326 <<
" extractionPrm.sphereDistanceThreshold: " <<
extractionPrm.sphereDistanceThreshold
328 <<
" extractionPrm.sphereNormalDistance: " <<
extractionPrm.sphereNormalDistance <<
","
330 <<
" extractionPrm.circularDistanceThreshold: " <<
extractionPrm.circularDistanceThreshold
332 <<
" segmentationPrm.minSegmentSize: " <<
segmentationPrm.minSegmentSize <<
","
334 <<
" segmentationPrm.voxelResolution: " <<
segmentationPrm.voxelResolution <<
","
336 <<
" segmentationPrm.seedResolution: " <<
segmentationPrm.seedResolution <<
","
338 <<
" segmentationPrm.colorImportance: " <<
segmentationPrm.colorImportance <<
","
340 <<
" segmentationPrm.spatialImportance: " <<
segmentationPrm.spatialImportance <<
","
342 <<
" segmentationPrm.normalImportance: " <<
segmentationPrm.normalImportance <<
","
344 <<
" segmentationPrm.concavityThreshold: " <<
segmentationPrm.concavityThreshold <<
","
346 <<
" segmentationPrm.smoothnessThreshold: " <<
segmentationPrm.smoothnessThreshold <<
","
355 float radius_percent = 0.05;
359 radius_percent = 0.3;
363 float r = ((
float)(rand() % 2000 - 1000)) / 1000.0f;
366 current += r * (bounds(1) - bounds(0)) * radius_percent;
369 current =
std::max(current, bounds(0));
370 current =
std::min(current, bounds(1));
377 const std::string& directory,
378 const pcl::PointCloud<pcl::PointXYZL>::Ptr& pointCloud,
379 const visionx::LccpParameters& lccp_prm,
380 const visionx::PrimitiveExtractorParameters& pe_prm)
382 std::stringstream path_pcd;
383 path_pcd << directory <<
"/point_cloud_" <<
iteration <<
".pcd";
385 std::stringstream path_prm;
386 path_prm << directory <<
"/parameters_" <<
iteration <<
".cfg";
388 ARMARX_INFO <<
"Exporting labeled point cloud to: " << path_pcd.str();
389 pcl::io::savePCDFile<pcl::PointXYZL>(path_pcd.str(), *pointCloud);
391 ARMARX_INFO <<
"Exporting parameters to: " << path_prm.str();
393 f.open(path_prm.str());
395 f <<
"Randomly determined parameter set: {" << std::endl
396 <<
" extractionPrm.minSegmentSize: " << pe_prm.minSegmentSize <<
"," << std::endl
397 <<
" extractionPrm.maxSegmentSize: " << pe_prm.maxSegmentSize <<
"," << std::endl
398 <<
" extractionPrm.euclideanClusteringTolerance: " << pe_prm.euclideanClusteringTolerance
400 <<
" extractionPrm.outlierThreshold: " << pe_prm.outlierThreshold <<
"," << std::endl
401 <<
" extractionPrm.planeMaxIterations: " << pe_prm.planeMaxIterations <<
"," << std::endl
402 <<
" extractionPrm.planeDistanceThreshold: " << pe_prm.planeDistanceThreshold <<
","
404 <<
" extractionPrm.planeNormalDistance: " << pe_prm.planeNormalDistance <<
"," << std::endl
405 <<
" extractionPrm.cylinderMaxIterations: " << pe_prm.cylinderMaxIterations <<
","
407 <<
" extractionPrm.cylinderDistanceThreshold: " << pe_prm.cylinderDistanceThreshold <<
","
409 <<
" extractionPrm.cylinderRadiusLimit: " << pe_prm.cylinderRadiusLimit <<
"," << std::endl
410 <<
" extractionPrm.sphereMaxIterations: " << pe_prm.sphereMaxIterations <<
"," << std::endl
411 <<
" extractionPrm.sphereDistanceThreshold: " << pe_prm.sphereDistanceThreshold <<
","
413 <<
" extractionPrm.sphereNormalDistance: " << pe_prm.sphereNormalDistance <<
","
415 <<
" extractionPrm.circularDistanceThreshold: " << pe_prm.circularDistanceThreshold <<
","
417 <<
" segmentationPrm.minSegmentSize: " << lccp_prm.minSegmentSize <<
"," << std::endl
418 <<
" segmentationPrm.voxelResolution: " << lccp_prm.voxelResolution <<
"," << std::endl
419 <<
" segmentationPrm.seedResolution: " << lccp_prm.seedResolution <<
"," << std::endl
420 <<
" segmentationPrm.colorImportance: " << lccp_prm.colorImportance <<
"," << std::endl
421 <<
" segmentationPrm.spatialImportance: " << lccp_prm.spatialImportance <<
"," << std::endl
422 <<
" segmentationPrm.normalImportance: " << lccp_prm.normalImportance <<
"," << std::endl
423 <<
" segmentationPrm.concavityThreshold: " << lccp_prm.concavityThreshold <<
","
425 <<
" segmentationPrm.smoothnessThreshold: " << lccp_prm.smoothnessThreshold <<
","