diff --git a/segmentation/include/pcl/segmentation/impl/supervoxel_clustering.hpp b/segmentation/include/pcl/segmentation/impl/supervoxel_clustering.hpp index 909a29f2db3..6efc2247a98 100644 --- a/segmentation/include/pcl/segmentation/impl/supervoxel_clustering.hpp +++ b/segmentation/include/pcl/segmentation/impl/supervoxel_clustering.hpp @@ -767,85 +767,31 @@ pcl::SupervoxelClustering::getMaxLabel () const namespace pcl { - namespace octree { //Explicit overloads for RGB types template<> void - pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::addPoint (const pcl::PointXYZRGB &new_point) - { - ++num_points_; - //Same as before here - data_.xyz_[0] += new_point.x; - data_.xyz_[1] += new_point.y; - data_.xyz_[2] += new_point.z; - //Separate sums for r,g,b since we cant sum in uchars - data_.rgb_[0] += static_cast (new_point.r); - data_.rgb_[1] += static_cast (new_point.g); - data_.rgb_[2] += static_cast (new_point.b); - } + pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::addPoint (const pcl::PointXYZRGB &new_point); template<> void - pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::addPoint (const pcl::PointXYZRGBA &new_point) - { - ++num_points_; - //Same as before here - data_.xyz_[0] += new_point.x; - data_.xyz_[1] += new_point.y; - data_.xyz_[2] += new_point.z; - //Separate sums for r,g,b since we cant sum in uchars - data_.rgb_[0] += static_cast (new_point.r); - data_.rgb_[1] += static_cast (new_point.g); - data_.rgb_[2] += static_cast (new_point.b); - } - - + pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::addPoint (const pcl::PointXYZRGBA &new_point); //Explicit overloads for RGB types template<> void - pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::computeData () - { - data_.rgb_[0] /= (static_cast (num_points_)); - data_.rgb_[1] /= (static_cast (num_points_)); - data_.rgb_[2] /= (static_cast (num_points_)); - data_.xyz_[0] /= (static_cast (num_points_)); - data_.xyz_[1] /= (static_cast (num_points_)); - data_.xyz_[2] /= (static_cast (num_points_)); - } + pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::computeData (); template<> void - pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::computeData () - { - data_.rgb_[0] /= (static_cast (num_points_)); - data_.rgb_[1] /= (static_cast (num_points_)); - data_.rgb_[2] /= (static_cast (num_points_)); - data_.xyz_[0] /= (static_cast (num_points_)); - data_.xyz_[1] /= (static_cast (num_points_)); - data_.xyz_[2] /= (static_cast (num_points_)); - } - + pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::computeData (); + //Explicit overloads for XYZ types template<> void - pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::addPoint (const pcl::PointXYZ &new_point) - { - ++num_points_; - //Same as before here - data_.xyz_[0] += new_point.x; - data_.xyz_[1] += new_point.y; - data_.xyz_[2] += new_point.z; - } - + pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::addPoint (const pcl::PointXYZ &new_point); + template<> void - pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::computeData () - { - data_.xyz_[0] /= (static_cast (num_points_)); - data_.xyz_[1] /= (static_cast (num_points_)); - data_.xyz_[2] /= (static_cast (num_points_)); - } - + pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::computeData (); } } @@ -856,26 +802,10 @@ namespace pcl { template<> void - pcl::SupervoxelClustering::VoxelData::getPoint (pcl::PointXYZRGB &point_arg) const - { - point_arg.rgba = static_cast(rgb_[0]) << 16 | - static_cast(rgb_[1]) << 8 | - static_cast(rgb_[2]); - point_arg.x = xyz_[0]; - point_arg.y = xyz_[1]; - point_arg.z = xyz_[2]; - } + pcl::SupervoxelClustering::VoxelData::getPoint (pcl::PointXYZRGB &point_arg) const; template<> void - pcl::SupervoxelClustering::VoxelData::getPoint (pcl::PointXYZRGBA &point_arg ) const - { - point_arg.rgba = static_cast(rgb_[0]) << 16 | - static_cast(rgb_[1]) << 8 | - static_cast(rgb_[2]); - point_arg.x = xyz_[0]; - point_arg.y = xyz_[1]; - point_arg.z = xyz_[2]; - } + pcl::SupervoxelClustering::VoxelData::getPoint (pcl::PointXYZRGBA &point_arg ) const; template void pcl::SupervoxelClustering::VoxelData::getPoint (PointT &point_arg ) const @@ -896,7 +826,6 @@ namespace pcl normal_arg.curvature = curvature_; } } - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/segmentation/include/pcl/segmentation/supervoxel_clustering.h b/segmentation/include/pcl/segmentation/supervoxel_clustering.h index 1080d226aad..723bfbe838e 100644 --- a/segmentation/include/pcl/segmentation/supervoxel_clustering.h +++ b/segmentation/include/pcl/segmentation/supervoxel_clustering.h @@ -115,7 +115,8 @@ namespace pcl * \note Usually, color isn't needed (and can be detrimental)- spatial structure is mainly used * - J. Papon, A. Abramov, M. Schoeler, F. Woergoetter * Voxel Cloud Connectivity Segmentation - Supervoxels from PointClouds - * In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR) 2013 + * In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR) 2013 + * \ingroup segmentation * \author Jeremie Papon (jpapon@gmail.com) */ template diff --git a/segmentation/src/supervoxel_clustering.cpp b/segmentation/src/supervoxel_clustering.cpp index 5204507ffa3..f4685758fb4 100644 --- a/segmentation/src/supervoxel_clustering.cpp +++ b/segmentation/src/supervoxel_clustering.cpp @@ -40,15 +40,118 @@ #include #include #include - #include -#include -#include -#include -template class pcl::SupervoxelClustering; -template class pcl::SupervoxelClustering; -template class pcl::SupervoxelClustering; +namespace pcl +{ + namespace octree + { + //Explicit overloads for RGB types + template<> + void + pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::addPoint (const pcl::PointXYZRGB &new_point) + { + ++num_points_; + //Same as before here + data_.xyz_[0] += new_point.x; + data_.xyz_[1] += new_point.y; + data_.xyz_[2] += new_point.z; + //Separate sums for r,g,b since we cant sum in uchars + data_.rgb_[0] += static_cast (new_point.r); + data_.rgb_[1] += static_cast (new_point.g); + data_.rgb_[2] += static_cast (new_point.b); + } + + template<> + void + pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::addPoint (const pcl::PointXYZRGBA &new_point) + { + ++num_points_; + //Same as before here + data_.xyz_[0] += new_point.x; + data_.xyz_[1] += new_point.y; + data_.xyz_[2] += new_point.z; + //Separate sums for r,g,b since we cant sum in uchars + data_.rgb_[0] += static_cast (new_point.r); + data_.rgb_[1] += static_cast (new_point.g); + data_.rgb_[2] += static_cast (new_point.b); + } + + + + //Explicit overloads for RGB types + template<> void + pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::computeData () + { + data_.rgb_[0] /= (static_cast (num_points_)); + data_.rgb_[1] /= (static_cast (num_points_)); + data_.rgb_[2] /= (static_cast (num_points_)); + data_.xyz_[0] /= (static_cast (num_points_)); + data_.xyz_[1] /= (static_cast (num_points_)); + data_.xyz_[2] /= (static_cast (num_points_)); + } + + template<> void + pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::computeData () + { + data_.rgb_[0] /= (static_cast (num_points_)); + data_.rgb_[1] /= (static_cast (num_points_)); + data_.rgb_[2] /= (static_cast (num_points_)); + data_.xyz_[0] /= (static_cast (num_points_)); + data_.xyz_[1] /= (static_cast (num_points_)); + data_.xyz_[2] /= (static_cast (num_points_)); + } + + //Explicit overloads for XYZ types + template<> + void + pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::addPoint (const pcl::PointXYZ &new_point) + { + ++num_points_; + //Same as before here + data_.xyz_[0] += new_point.x; + data_.xyz_[1] += new_point.y; + data_.xyz_[2] += new_point.z; + } + + template<> void + pcl::octree::OctreePointCloudAdjacencyContainer::VoxelData>::computeData () + { + data_.xyz_[0] /= (static_cast (num_points_)); + data_.xyz_[1] /= (static_cast (num_points_)); + data_.xyz_[2] /= (static_cast (num_points_)); + } + + } +} + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +namespace pcl +{ + template<> void + pcl::SupervoxelClustering::VoxelData::getPoint (pcl::PointXYZRGB &point_arg) const + { + point_arg.rgba = static_cast(rgb_[0]) << 16 | + static_cast(rgb_[1]) << 8 | + static_cast(rgb_[2]); + point_arg.x = xyz_[0]; + point_arg.y = xyz_[1]; + point_arg.z = xyz_[2]; + } + + template<> void + pcl::SupervoxelClustering::VoxelData::getPoint (pcl::PointXYZRGBA &point_arg ) const + { + point_arg.rgba = static_cast(rgb_[0]) << 16 | + static_cast(rgb_[1]) << 8 | + static_cast(rgb_[2]); + point_arg.x = xyz_[0]; + point_arg.y = xyz_[1]; + point_arg.z = xyz_[2]; + } +} typedef pcl::SupervoxelClustering::VoxelData VoxelDataT; typedef pcl::SupervoxelClustering::VoxelData VoxelDataRGBT; @@ -58,17 +161,14 @@ typedef pcl::octree::OctreePointCloudAdjacencyContainer AdjacencyContainerRGBT; typedef pcl::octree::OctreePointCloudAdjacencyContainer AdjacencyContainerRGBAT; +template class pcl::SupervoxelClustering; +template class pcl::SupervoxelClustering; +template class pcl::SupervoxelClustering; + template class pcl::octree::OctreePointCloudAdjacencyContainer; template class pcl::octree::OctreePointCloudAdjacencyContainer; template class pcl::octree::OctreePointCloudAdjacencyContainer; template class pcl::octree::OctreePointCloudAdjacency; template class pcl::octree::OctreePointCloudAdjacency; -template class pcl::octree::OctreePointCloudAdjacency; - -//template class pcl::octree::OctreeBase; -//template class pcl::octree::OctreeBase; - -//template class pcl::octree::OctreeBreadthFirstIterator >; -//template class pcl::octree::OctreeBreadthFirstIterator >; - +template class pcl::octree::OctreePointCloudAdjacency; \ No newline at end of file