Skip to content

Conversation

MaximSmolskiy
Copy link
Contributor

Resolve #6356

For deterministic comparison of implementations I made the following changes:

--- a/segmentation/include/pcl/segmentation/impl/region_growing.hpp
+++ b/segmentation/include/pcl/segmentation/impl/region_growing.hpp
@@ -614,7 +614,7 @@ pcl::RegionGrowing<PointT, NormalT>::getColoredCloud ()
   {
     colored_cloud.reset(new pcl::PointCloud<pcl::PointXYZRGB>);
 
-    srand (static_cast<unsigned int> (time (nullptr)));
+    srand (static_cast<unsigned int> (0));
     std::vector<unsigned char> colors;
     for (std::size_t i_segment = 0; i_segment < clusters_.size (); i_segment++)
     {
@@ -664,7 +664,7 @@ pcl::RegionGrowing<PointT, NormalT>::getColoredCloudRGBA ()
   {
     colored_cloud.reset(new pcl::PointCloud<pcl::PointXYZRGBA>);
 
-    srand (static_cast<unsigned int> (time (nullptr)));
+    srand (static_cast<unsigned int> (0));
     std::vector<unsigned char> colors;
     for (std::size_t i_segment = 0; i_segment < clusters_.size (); i_segment++)
     {

and replaced std::sort with std::stable_sort for old implementation

Total reg.extract (clusters) time decreased from 16 to 4 seconds and applyRegionMergingAlgorithm time - from 12 to 0.3 seconds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[segmentation] Make RegionGrowingRGB faster
1 participant