@@ -15,16 +15,19 @@ namespace diffCheck::segmentation
1515 int radiusNeighborhoodSize,
1616 bool colorClusters)
1717 {
18+ if (!pointCloud->HasNormals ())
19+ {
20+ DIFFCHECK_WARN (" The point cloud does not have normals. Estimating normals with 50 neighbors." );
21+ pointCloud->EstimateNormals (true , 50 );
22+ }
23+
1824 std::shared_ptr<cilantro::PointCloud3f> cilantroPointCloud = pointCloud->Cvt2CilantroPointCloud ();
1925
2026 std::vector<std::shared_ptr<geometry::DFPointCloud>> segments;
2127 if (useKnnNeighborhood)
2228 {
2329 cilantro::KNNNeighborhoodSpecification<int > neighborhood (knnNeighborhoodSize);
2430
25- // FIXME: not clear why this is needed all the time
26- cilantroPointCloud->estimateNormals (neighborhood);
27-
2831 cilantro::NormalsProximityEvaluator<float , 3 > similarityEvaluator (
2932 cilantroPointCloud->normals ,
3033 normalThresholdDegree*M_PI/180 .0f );
@@ -58,8 +61,6 @@ namespace diffCheck::segmentation
5861 {
5962 cilantro::RadiusNeighborhoodSpecification<float > neighborhood (radiusNeighborhoodSize);
6063
61- // cilantroPointCloud->estimateNormals(neighborhood);
62-
6364 cilantro::NormalsProximityEvaluator<float , 3 > similarityEvaluator (
6465 cilantroPointCloud->normals ,
6566 normalThresholdDegree*M_PI/180 .0f );
@@ -79,7 +80,14 @@ namespace diffCheck::segmentation
7980 Eigen::Vector3d normal = cilantroPointCloud->normals .col (pointIndice).cast <double >();
8081 segment->Points .push_back (point);
8182 segment->Normals .push_back (normal);
83+ if (cilantroPointCloud->hasColors ())
84+ {
85+ Eigen::Vector3d color = cilantroPointCloud->colors .col (pointIndice).cast <double >();
86+ segment->Colors .push_back (color);
87+ }
8288 }
89+ if (colorClusters)
90+ segment->ApplyColor (Eigen::Vector3d::Random ());
8391 segments.push_back (segment);
8492 }
8593 }
0 commit comments