Exemplo n.º 1
0
template <typename PointT, typename NormalT> void
pcl::RegionGrowingHSV<PointT, NormalT>::findSegmentNeighbours()
{
	std::vector<int> neighbours;
	std::vector<float> distances;
	segment_neighbours_.clear();
	segment_distances_.clear();
	num_pts_in_segment_.clear();
	number_of_segments_ = clusters_.size();
	for (int i=0;i<number_of_segments_;i++)
	{
		num_pts_in_segment_.push_back(clusters_[i].indices.size());
	}

	segment_neighbours_.resize(number_of_segments_, neighbours);
	segment_distances_.resize(number_of_segments_, distances);
	std::vector<pcl::PointIndices>::iterator seg_itr;
	int count = 0;
	for (int i=0; i< point_labels_.size();i++)
	{
		point_labels_[i] = 0;

	}
	for (seg_itr = clusters_.begin();seg_itr < clusters_.end(); ++seg_itr)
	{
		for (int j = 0; j < seg_itr->indices.size(); j++ )
		{
			int idx = seg_itr->indices.at(j);
			point_labels_[idx] = count;
		}
		count++;
	}

	for (int i_seg = 0; i_seg < number_of_segments_; i_seg++)
	{
		if (i_seg == 33)
		{
			std::cout <<"arriving 33"<<std::endl;
		}
		std::vector<int> nghbrs;
		std::vector<float> dist;
		findRegionsKNN(i_seg, region_neighbour_number_, nghbrs, dist);
		segment_neighbours_[i_seg].swap(nghbrs);
		segment_distances_[i_seg].swap(dist);
	}
}
template <typename PointT, typename NormalT> void
pcl::RegionGrowingRGB2<PointT, NormalT>::findSegmentNeighbours ()
{
  std::vector<int> neighbours;
  std::vector<float> distances;
  segment_neighbours_.resize (number_of_segments_, neighbours);
  segment_distances_.resize (number_of_segments_, distances);

  for (int i_seg = 0; i_seg < number_of_segments_; i_seg++)
  {
    std::vector<int> nghbrs;
    std::vector<float> dist;
    findRegionsKNN (i_seg, region_neighbour_number_, nghbrs, dist);
    segment_neighbours_[i_seg].swap (nghbrs);
    segment_distances_[i_seg].swap (dist);
  }
}