Skip to content

Commit

Permalink
Removed Supervoxel template parameter from lccp. Now we should get so…
Browse files Browse the repository at this point in the history
…me conflicts with PointCloudLibrary#718
  • Loading branch information
jpapon committed Sep 24, 2014
1 parent 3de94b0 commit 98a85b7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
10 changes: 5 additions & 5 deletions examples/segmentation/example_lccp_segmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ LCCPSegmentation Parameters: \n\
super.setColorImportance (color_importance);
super.setSpatialImportance (spatial_importance);
super.setNormalImportance (normal_importance);
std::map<uint32_t, pcl::Supervoxel<PointT>::Ptr> supervoxel_clusters;
std::map<uint32_t, pcl::Supervoxel::Ptr> supervoxel_clusters;

PCL_INFO ("Extracting supervoxels\n");
super.extract (supervoxel_clusters);
Expand Down Expand Up @@ -444,13 +444,13 @@ LCCPSegmentation Parameters: \n\
colors->InsertNextTupleValue (color);
colors->InsertNextTupleValue (color);

pcl::Supervoxel<PointT>::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<PointT>::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);
Expand Down
31 changes: 14 additions & 17 deletions segmentation/include/pcl/segmentation/impl/lccp_segmentation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pcl::LCCPSegmentation<PointT>::removeSmallSegments (uint32_t min_segment_size_ar
}

template <typename PointT> void
pcl::LCCPSegmentation<PointT>::prepareSegmentation (const std::map<uint32_t, typename pcl::Supervoxel<PointT>::Ptr>& supervoxel_clusters_arg,
pcl::LCCPSegmentation<PointT>::prepareSegmentation (const std::map<uint32_t, typename pcl::Supervoxel::Ptr>& supervoxel_clusters_arg,
const std::multimap<boost::uint32_t, boost::uint32_t>& label_adjaceny_arg)
{
// Clear internal data
Expand All @@ -238,7 +238,7 @@ pcl::LCCPSegmentation<PointT>::prepareSegmentation (const std::map<uint32_t, typ
std::map<uint32_t, VertexID> label_ID_map;

// Add all supervoxel labels as vertices
for (typename std::map<uint32_t, typename pcl::Supervoxel<PointT>::Ptr>::iterator svlabel_itr = sv_label_to_supervoxel_map_.begin ();
for (typename std::map<uint32_t, typename pcl::Supervoxel::Ptr>::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;
Expand All @@ -261,7 +261,7 @@ pcl::LCCPSegmentation<PointT>::prepareSegmentation (const std::map<uint32_t, typ
}

// Initialization
for (typename std::map<uint32_t, typename pcl::Supervoxel<PointT>::Ptr>::iterator svlabel_itr = sv_label_to_supervoxel_map_.begin ();
for (typename std::map<uint32_t, typename pcl::Supervoxel::Ptr>::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;
Expand All @@ -271,7 +271,7 @@ pcl::LCCPSegmentation<PointT>::prepareSegmentation (const std::map<uint32_t, typ
}

template <typename PointT> void
pcl::LCCPSegmentation<PointT>::segment (std::map<uint32_t, typename pcl::Supervoxel<PointT>::Ptr>& supervoxel_clusters_arg,
pcl::LCCPSegmentation<PointT>::segment (std::map<uint32_t, typename pcl::Supervoxel::Ptr>& supervoxel_clusters_arg,
std::multimap<boost::uint32_t, boost::uint32_t>& label_adjacency_arg)
{
/// Initialization
Expand Down Expand Up @@ -425,14 +425,11 @@ template <typename PointT> bool
pcl::LCCPSegmentation<PointT>::connIsConvex (uint32_t source_label_arg,
uint32_t target_label_arg)
{
typename pcl::Supervoxel<PointT>::Ptr& sv_source = sv_label_to_supervoxel_map_[source_label_arg];
typename pcl::Supervoxel<PointT>::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)
Expand All @@ -442,7 +439,7 @@ pcl::LCCPSegmentation<PointT>::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
Expand All @@ -461,18 +458,18 @@ pcl::LCCPSegmentation<PointT>::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

Expand Down
6 changes: 3 additions & 3 deletions segmentation/include/pcl/segmentation/lccp_segmentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t, typename pcl::Supervoxel<PointT>::Ptr> &supervoxel_clusters_arg,
segment (std::map<uint32_t, typename pcl::Supervoxel::Ptr> &supervoxel_clusters_arg,
std::multimap<uint32_t, uint32_t> &label_adjacency_arg);

/** \brief Relabels cloud with supervoxel labels with the computed segment labels
Expand Down Expand Up @@ -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<uint32_t, typename pcl::Supervoxel<PointT>::Ptr> &supervoxel_clusters_arg,
prepareSegmentation (const std::map<uint32_t, typename pcl::Supervoxel::Ptr> &supervoxel_clusters_arg,
const std::multimap<uint32_t, uint32_t> &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.
Expand Down Expand Up @@ -276,7 +276,7 @@ namespace pcl
SupervoxelAdjacencyList sv_adjacency_list_;

/** \brief map from the supervoxel labels to the supervoxel objects */
std::map<uint32_t, typename pcl::Supervoxel<PointT>::Ptr> sv_label_to_supervoxel_map_;
std::map<uint32_t, typename pcl::Supervoxel::Ptr> 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<uint32_t, uint32_t> sv_label_to_seg_label_map_;
Expand Down

0 comments on commit 98a85b7

Please sign in to comment.