From 98a85b7a693f969701f55d87ae15a9df61517d9d Mon Sep 17 00:00:00 2001 From: Jeremie Papon Date: Wed, 24 Sep 2014 16:43:17 +0200 Subject: [PATCH] Removed Supervoxel template parameter from lccp. Now we should get some conflicts with #718 --- .../example_lccp_segmentation.cpp | 10 +++--- .../segmentation/impl/lccp_segmentation.hpp | 31 +++++++++---------- .../pcl/segmentation/lccp_segmentation.h | 6 ++-- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/examples/segmentation/example_lccp_segmentation.cpp b/examples/segmentation/example_lccp_segmentation.cpp index 5776fab7fdc..993386d2edf 100644 --- a/examples/segmentation/example_lccp_segmentation.cpp +++ b/examples/segmentation/example_lccp_segmentation.cpp @@ -304,7 +304,7 @@ LCCPSegmentation Parameters: \n\ super.setColorImportance (color_importance); super.setSpatialImportance (spatial_importance); super.setNormalImportance (normal_importance); - std::map::Ptr> supervoxel_clusters; + std::map supervoxel_clusters; PCL_INFO ("Extracting supervoxels\n"); super.extract (supervoxel_clusters); @@ -444,13 +444,13 @@ LCCPSegmentation Parameters: \n\ colors->InsertNextTupleValue (color); colors->InsertNextTupleValue (color); - pcl::Supervoxel::Ptr supervoxel = supervoxel_clusters.at (sv_label); - pcl::PointXYZRGBA vert_curr = supervoxel->centroid_; + pcl::Supervoxel::Ptr supervoxel = supervoxel_clusters.at (sv_label); + pcl::Supervoxel::CentroidT vert_curr = supervoxel->centroid_; const uint32_t sv_neighbor_label = sv_adjacency_list[*itr_neighbor]; - pcl::Supervoxel::Ptr supervoxel_neigh = supervoxel_clusters.at (sv_neighbor_label); - pcl::PointXYZRGBA vert_neigh = supervoxel_neigh->centroid_; + pcl::Supervoxel::Ptr supervoxel_neigh = supervoxel_clusters.at (sv_neighbor_label); + pcl::Supervoxel::CentroidT vert_neigh = supervoxel_neigh->centroid_; points->InsertNextPoint (vert_curr.data); diff --git a/segmentation/include/pcl/segmentation/impl/lccp_segmentation.hpp b/segmentation/include/pcl/segmentation/impl/lccp_segmentation.hpp index e0b0fb677d0..88f2ebeffde 100644 --- a/segmentation/include/pcl/segmentation/impl/lccp_segmentation.hpp +++ b/segmentation/include/pcl/segmentation/impl/lccp_segmentation.hpp @@ -225,7 +225,7 @@ pcl::LCCPSegmentation::removeSmallSegments (uint32_t min_segment_size_ar } template void -pcl::LCCPSegmentation::prepareSegmentation (const std::map::Ptr>& supervoxel_clusters_arg, +pcl::LCCPSegmentation::prepareSegmentation (const std::map& supervoxel_clusters_arg, const std::multimap& label_adjaceny_arg) { // Clear internal data @@ -238,7 +238,7 @@ pcl::LCCPSegmentation::prepareSegmentation (const std::map label_ID_map; // Add all supervoxel labels as vertices - for (typename std::map::Ptr>::iterator svlabel_itr = sv_label_to_supervoxel_map_.begin (); + for (typename std::map::iterator svlabel_itr = sv_label_to_supervoxel_map_.begin (); svlabel_itr != sv_label_to_supervoxel_map_.end (); ++svlabel_itr) { const uint32_t SV_LABEL = svlabel_itr->first; @@ -261,7 +261,7 @@ pcl::LCCPSegmentation::prepareSegmentation (const std::map::Ptr>::iterator svlabel_itr = sv_label_to_supervoxel_map_.begin (); + for (typename std::map::iterator svlabel_itr = sv_label_to_supervoxel_map_.begin (); svlabel_itr != sv_label_to_supervoxel_map_.end (); ++svlabel_itr) { const uint32_t sv_label = svlabel_itr->first; @@ -271,7 +271,7 @@ pcl::LCCPSegmentation::prepareSegmentation (const std::map void -pcl::LCCPSegmentation::segment (std::map::Ptr>& supervoxel_clusters_arg, +pcl::LCCPSegmentation::segment (std::map& supervoxel_clusters_arg, std::multimap& label_adjacency_arg) { /// Initialization @@ -425,14 +425,11 @@ template bool pcl::LCCPSegmentation::connIsConvex (uint32_t source_label_arg, uint32_t target_label_arg) { - typename pcl::Supervoxel::Ptr& sv_source = sv_label_to_supervoxel_map_[source_label_arg]; - typename pcl::Supervoxel::Ptr& sv_target = sv_label_to_supervoxel_map_[target_label_arg]; + typename pcl::Supervoxel::Ptr& sv_source = sv_label_to_supervoxel_map_[source_label_arg]; + typename pcl::Supervoxel::Ptr& sv_target = sv_label_to_supervoxel_map_[target_label_arg]; - const pcl::PointXYZRGBA& source_centroid = sv_source->centroid_; - const pcl::PointXYZRGBA& target_centroid = sv_target->centroid_; - - const pcl::Normal& source_normal = sv_source->normal_; - const pcl::Normal& target_normal = sv_target->normal_; + const pcl::Supervoxel::CentroidT& source_centroid = sv_source->centroid_; + const pcl::Supervoxel::CentroidT& target_centroid = sv_target->centroid_; //NOTE For angles below 0 nothing will be merged if (concavity_tolerance_threshold_ < 0) @@ -442,7 +439,7 @@ pcl::LCCPSegmentation::connIsConvex (uint32_t source_label_arg, bool is_convex = true; bool is_smooth = true; - float normal_angle = std::acos (source_normal.getNormalVector3fMap ().dot (target_normal.getNormalVector3fMap ())) * 180. / M_PI; + float normal_angle = std::acos (source_centroid.getNormalVector3fMap ().dot (target_centroid.getNormalVector3fMap ())) * 180. / M_PI; // float curvature_difference = std::fabs (SOURCE_NORMAL.curvature - TARGET_NORMAL.curvature); /// Geometric comparisons @@ -461,18 +458,18 @@ pcl::LCCPSegmentation::connIsConvex (uint32_t source_label_arg, float dot_p_source, dot_p_target; // vec_t_to_s is the reference direction for angle measurements - dot_p_source = unitvec_t_to_s.getVector3fMap ().dot (source_normal.getNormalVector3fMap ()); - dot_p_target = unitvec_t_to_s.getVector3fMap ().dot (target_normal.getNormalVector3fMap ()); + dot_p_source = unitvec_t_to_s.getVector3fMap ().dot (source_centroid.getNormalVector3fMap ()); + dot_p_target = unitvec_t_to_s.getVector3fMap ().dot (target_centroid.getNormalVector3fMap ()); pcl::Normal ncross; - ncross.getNormalVector3fMap () = source_normal.getNormalVector3fMap ().cross (target_normal.getNormalVector3fMap ()); + ncross.getNormalVector3fMap () = source_centroid.getNormalVector3fMap ().cross (target_centroid.getNormalVector3fMap ()); /// Smoothness Check: Check if there is a step between adjacent patches if (use_smoothness_check_) { float expected_distance = ncross.getNormalVector3fMap ().norm () * seed_resolution_; - float dot_p_1 = vec_t_to_s.getVector3fMap ().dot (source_normal.getNormalVector3fMap ()); - float dot_p_2 = vec_s_to_t.getVector3fMap ().dot (target_normal.getNormalVector3fMap ()); + float dot_p_1 = vec_t_to_s.getVector3fMap ().dot (source_centroid.getNormalVector3fMap ()); + float dot_p_2 = vec_s_to_t.getVector3fMap ().dot (target_centroid.getNormalVector3fMap ()); float point_dist = (std::fabs (dot_p_1) < std::fabs (dot_p_2)) ? std::fabs (dot_p_1) : std::fabs (dot_p_2); const float dist_smoothing = smoothness_threshold_ * voxel_resolution_; // This is a slacking variable especially important for patches with very similar normals diff --git a/segmentation/include/pcl/segmentation/lccp_segmentation.h b/segmentation/include/pcl/segmentation/lccp_segmentation.h index ffe2d65b123..a1de7bac0c3 100644 --- a/segmentation/include/pcl/segmentation/lccp_segmentation.h +++ b/segmentation/include/pcl/segmentation/lccp_segmentation.h @@ -92,7 +92,7 @@ namespace pcl * \param[in] supervoxel_clusters_arg Map of < supervoxel labels, supervoxels > * \param[in] label_adjacency_arg The graph defining the supervoxel adjacency relations */ void - segment (std::map::Ptr> &supervoxel_clusters_arg, + segment (std::map &supervoxel_clusters_arg, std::multimap &label_adjacency_arg); /** \brief Relabels cloud with supervoxel labels with the computed segment labels @@ -215,7 +215,7 @@ namespace pcl * \param[in] supervoxel_clusters_arg map of < supervoxel labels, supervoxels > * \param[in] label_adjacency_arg The graph defining the supervoxel adjacency relations */ void - prepareSegmentation (const std::map::Ptr> &supervoxel_clusters_arg, + prepareSegmentation (const std::map &supervoxel_clusters_arg, const std::multimap &label_adjacency_arg); /** \brief Assigns neighbors of the query point to the same group as the query point. Recursive part of groupSupervoxels (..). Grouping is done by a depth-search of nodes in the adjacency-graph. @@ -276,7 +276,7 @@ namespace pcl SupervoxelAdjacencyList sv_adjacency_list_; /** \brief map from the supervoxel labels to the supervoxel objects */ - std::map::Ptr> sv_label_to_supervoxel_map_; + std::map sv_label_to_supervoxel_map_; /** \brief Storing relation between original SuperVoxel Labels and new segmantion labels. svLabel_segLabel_map_[old_labelID] = new_labelID */ std::map sv_label_to_seg_label_map_;