Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes necessary for lccp pull request #718 #919

Merged
merged 1 commit into from
Sep 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -767,85 +767,31 @@ pcl::SupervoxelClustering<PointT>::getMaxLabel () const

namespace pcl
{

namespace octree
{
//Explicit overloads for RGB types
template<>
void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGB,pcl::SupervoxelClustering<pcl::PointXYZRGB>::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<float> (new_point.r);
data_.rgb_[1] += static_cast<float> (new_point.g);
data_.rgb_[2] += static_cast<float> (new_point.b);
}
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGB,pcl::SupervoxelClustering<pcl::PointXYZRGB>::VoxelData>::addPoint (const pcl::PointXYZRGB &new_point);

template<>
void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGBA,pcl::SupervoxelClustering<pcl::PointXYZRGBA>::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<float> (new_point.r);
data_.rgb_[1] += static_cast<float> (new_point.g);
data_.rgb_[2] += static_cast<float> (new_point.b);
}


pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGBA,pcl::SupervoxelClustering<pcl::PointXYZRGBA>::VoxelData>::addPoint (const pcl::PointXYZRGBA &new_point);

//Explicit overloads for RGB types
template<> void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGB,pcl::SupervoxelClustering<pcl::PointXYZRGB>::VoxelData>::computeData ()
{
data_.rgb_[0] /= (static_cast<float> (num_points_));
data_.rgb_[1] /= (static_cast<float> (num_points_));
data_.rgb_[2] /= (static_cast<float> (num_points_));
data_.xyz_[0] /= (static_cast<float> (num_points_));
data_.xyz_[1] /= (static_cast<float> (num_points_));
data_.xyz_[2] /= (static_cast<float> (num_points_));
}
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGB,pcl::SupervoxelClustering<pcl::PointXYZRGB>::VoxelData>::computeData ();

template<> void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGBA,pcl::SupervoxelClustering<pcl::PointXYZRGBA>::VoxelData>::computeData ()
{
data_.rgb_[0] /= (static_cast<float> (num_points_));
data_.rgb_[1] /= (static_cast<float> (num_points_));
data_.rgb_[2] /= (static_cast<float> (num_points_));
data_.xyz_[0] /= (static_cast<float> (num_points_));
data_.xyz_[1] /= (static_cast<float> (num_points_));
data_.xyz_[2] /= (static_cast<float> (num_points_));
}

pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGBA,pcl::SupervoxelClustering<pcl::PointXYZRGBA>::VoxelData>::computeData ();

//Explicit overloads for XYZ types
template<>
void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZ,pcl::SupervoxelClustering<pcl::PointXYZ>::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<pcl::PointXYZ,pcl::SupervoxelClustering<pcl::PointXYZ>::VoxelData>::addPoint (const pcl::PointXYZ &new_point);

template<> void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZ,pcl::SupervoxelClustering<pcl::PointXYZ>::VoxelData>::computeData ()
{
data_.xyz_[0] /= (static_cast<float> (num_points_));
data_.xyz_[1] /= (static_cast<float> (num_points_));
data_.xyz_[2] /= (static_cast<float> (num_points_));
}

pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZ,pcl::SupervoxelClustering<pcl::PointXYZ>::VoxelData>::computeData ();
}
}

Expand All @@ -856,26 +802,10 @@ namespace pcl
{

template<> void
pcl::SupervoxelClustering<pcl::PointXYZRGB>::VoxelData::getPoint (pcl::PointXYZRGB &point_arg) const
{
point_arg.rgba = static_cast<uint32_t>(rgb_[0]) << 16 |
static_cast<uint32_t>(rgb_[1]) << 8 |
static_cast<uint32_t>(rgb_[2]);
point_arg.x = xyz_[0];
point_arg.y = xyz_[1];
point_arg.z = xyz_[2];
}
pcl::SupervoxelClustering<pcl::PointXYZRGB>::VoxelData::getPoint (pcl::PointXYZRGB &point_arg) const;

template<> void
pcl::SupervoxelClustering<pcl::PointXYZRGBA>::VoxelData::getPoint (pcl::PointXYZRGBA &point_arg ) const
{
point_arg.rgba = static_cast<uint32_t>(rgb_[0]) << 16 |
static_cast<uint32_t>(rgb_[1]) << 8 |
static_cast<uint32_t>(rgb_[2]);
point_arg.x = xyz_[0];
point_arg.y = xyz_[1];
point_arg.z = xyz_[2];
}
pcl::SupervoxelClustering<pcl::PointXYZRGBA>::VoxelData::getPoint (pcl::PointXYZRGBA &point_arg ) const;

template<typename PointT> void
pcl::SupervoxelClustering<PointT>::VoxelData::getPoint (PointT &point_arg ) const
Expand All @@ -896,7 +826,6 @@ namespace pcl
normal_arg.curvature = curvature_;
}
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ([email protected])
*/
template <typename PointT>
Expand Down
130 changes: 115 additions & 15 deletions segmentation/src/supervoxel_clustering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,118 @@
#include <pcl/point_types.h>
#include <pcl/impl/instantiate.hpp>
#include <pcl/segmentation/impl/supervoxel_clustering.hpp>

#include <pcl/octree/impl/octree_pointcloud_adjacency.hpp>
#include <pcl/octree/impl/octree_pointcloud.hpp>
#include <pcl/octree/impl/octree_base.hpp>
#include <pcl/octree/impl/octree_iterator.hpp>

template class pcl::SupervoxelClustering<pcl::PointXYZRGBA>;
template class pcl::SupervoxelClustering<pcl::PointXYZRGB>;
template class pcl::SupervoxelClustering<pcl::PointXYZ>;
namespace pcl
{
namespace octree
{
//Explicit overloads for RGB types
template<>
void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGB,pcl::SupervoxelClustering<pcl::PointXYZRGB>::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<float> (new_point.r);
data_.rgb_[1] += static_cast<float> (new_point.g);
data_.rgb_[2] += static_cast<float> (new_point.b);
}

template<>
void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGBA,pcl::SupervoxelClustering<pcl::PointXYZRGBA>::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<float> (new_point.r);
data_.rgb_[1] += static_cast<float> (new_point.g);
data_.rgb_[2] += static_cast<float> (new_point.b);
}



//Explicit overloads for RGB types
template<> void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGB,pcl::SupervoxelClustering<pcl::PointXYZRGB>::VoxelData>::computeData ()
{
data_.rgb_[0] /= (static_cast<float> (num_points_));
data_.rgb_[1] /= (static_cast<float> (num_points_));
data_.rgb_[2] /= (static_cast<float> (num_points_));
data_.xyz_[0] /= (static_cast<float> (num_points_));
data_.xyz_[1] /= (static_cast<float> (num_points_));
data_.xyz_[2] /= (static_cast<float> (num_points_));
}

template<> void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGBA,pcl::SupervoxelClustering<pcl::PointXYZRGBA>::VoxelData>::computeData ()
{
data_.rgb_[0] /= (static_cast<float> (num_points_));
data_.rgb_[1] /= (static_cast<float> (num_points_));
data_.rgb_[2] /= (static_cast<float> (num_points_));
data_.xyz_[0] /= (static_cast<float> (num_points_));
data_.xyz_[1] /= (static_cast<float> (num_points_));
data_.xyz_[2] /= (static_cast<float> (num_points_));
}

//Explicit overloads for XYZ types
template<>
void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZ,pcl::SupervoxelClustering<pcl::PointXYZ>::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<pcl::PointXYZ,pcl::SupervoxelClustering<pcl::PointXYZ>::VoxelData>::computeData ()
{
data_.xyz_[0] /= (static_cast<float> (num_points_));
data_.xyz_[1] /= (static_cast<float> (num_points_));
data_.xyz_[2] /= (static_cast<float> (num_points_));
}

}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace pcl
{
template<> void
pcl::SupervoxelClustering<pcl::PointXYZRGB>::VoxelData::getPoint (pcl::PointXYZRGB &point_arg) const
{
point_arg.rgba = static_cast<uint32_t>(rgb_[0]) << 16 |
static_cast<uint32_t>(rgb_[1]) << 8 |
static_cast<uint32_t>(rgb_[2]);
point_arg.x = xyz_[0];
point_arg.y = xyz_[1];
point_arg.z = xyz_[2];
}

template<> void
pcl::SupervoxelClustering<pcl::PointXYZRGBA>::VoxelData::getPoint (pcl::PointXYZRGBA &point_arg ) const
{
point_arg.rgba = static_cast<uint32_t>(rgb_[0]) << 16 |
static_cast<uint32_t>(rgb_[1]) << 8 |
static_cast<uint32_t>(rgb_[2]);
point_arg.x = xyz_[0];
point_arg.y = xyz_[1];
point_arg.z = xyz_[2];
}
}

typedef pcl::SupervoxelClustering<pcl::PointXYZ>::VoxelData VoxelDataT;
typedef pcl::SupervoxelClustering<pcl::PointXYZRGB>::VoxelData VoxelDataRGBT;
Expand All @@ -58,17 +161,14 @@ typedef pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZ, VoxelData
typedef pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGB, VoxelDataRGBT> AdjacencyContainerRGBT;
typedef pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGBA, VoxelDataRGBAT> AdjacencyContainerRGBAT;

template class pcl::SupervoxelClustering<pcl::PointXYZ>;
template class pcl::SupervoxelClustering<pcl::PointXYZRGB>;
template class pcl::SupervoxelClustering<pcl::PointXYZRGBA>;

template class pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZ, VoxelDataT>;
template class pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGB, VoxelDataRGBT>;
template class pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGBA, VoxelDataRGBAT>;

template class pcl::octree::OctreePointCloudAdjacency<pcl::PointXYZ, AdjacencyContainerT>;
template class pcl::octree::OctreePointCloudAdjacency<pcl::PointXYZRGB, AdjacencyContainerRGBT>;
template class pcl::octree::OctreePointCloudAdjacency<pcl::PointXYZRGBA, AdjacencyContainerRGBAT>;

//template class pcl::octree::OctreeBase<AdjacencyContainerRGBT, pcl::octree::OctreeContainerEmpty>;
//template class pcl::octree::OctreeBase<AdjacencyContainerRGBAT, pcl::octree::OctreeContainerEmpty>;

//template class pcl::octree::OctreeBreadthFirstIterator<pcl::octree::OctreeBase<AdjacencyContainerRGBT, pcl::octree::OctreeContainerEmpty> >;
//template class pcl::octree::OctreeBreadthFirstIterator<pcl::octree::OctreeBase<AdjacencyContainerRGBAT, pcl::octree::OctreeContainerEmpty> >;

template class pcl::octree::OctreePointCloudAdjacency<pcl::PointXYZRGBA, AdjacencyContainerRGBAT>;