Skip to content

Commit

Permalink
Removed supervoxel changes from branch, switched to using macro for i…
Browse files Browse the repository at this point in the history
…nstantiation
  • Loading branch information
jpapon committed Sep 19, 2014
1 parent 9299e55 commit b345e39
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 133 deletions.
4 changes: 2 additions & 2 deletions examples/segmentation/example_supervoxels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bool show_refined = false;
bool show_help = true;

void
keyboardEventOccurred (const pcl::visualization::KeyboardEvent& event, void*)
keyboard_callback (const pcl::visualization::KeyboardEvent& event, void*)
{
int key = event.getKeyCode ();

Expand Down Expand Up @@ -303,7 +303,7 @@ main (int argc, char ** argv)
std::cout << "Loading visualization...\n";
boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
viewer->setBackgroundColor (0, 0, 0);
viewer->registerKeyboardCallback(keyboardEventOccurred, 0);
viewer->registerKeyboardCallback(keyboard_callback, 0);


bool refined_normal_shown = show_refined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,26 +769,79 @@ namespace pcl
//Explicit overloads for RGB types
template<>
void
pcl::octree::OctreePointCloudAdjacencyContainer<pcl::PointXYZRGB,pcl::SupervoxelClustering<pcl::PointXYZRGB>::VoxelData>::addPoint (const pcl::PointXYZRGB &new_point);

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);
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 ();

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 ();
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);
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 ();
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_));
}

}
}

Expand All @@ -799,10 +852,26 @@ namespace pcl
{

template<> void
pcl::SupervoxelClustering<pcl::PointXYZRGB>::VoxelData::getPoint (pcl::PointXYZRGB &point_arg) const;
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;
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];
}

template<typename PointT> void
pcl::SupervoxelClustering<PointT>::VoxelData::getPoint (PointT &point_arg ) const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ namespace pcl
* Voxel Cloud Connectivity Segmentation - Supervoxels from PointClouds
* In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR) 2013
* \author Jeremie Papon (jpapon@gmail.com)
* \ingroup segmentation
*/
template <typename PointT>
class PCL_EXPORTS SupervoxelClustering : public pcl::PCLBase<PointT>
Expand Down
7 changes: 1 addition & 6 deletions segmentation/src/lccp_segmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,4 @@
#include <pcl/segmentation/lccp_segmentation.h>
#include <pcl/segmentation/impl/lccp_segmentation.hpp>

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

// Use Macro below to instantiate for all XYZ point types
// PCL_INSTANTIATE(LCCPSegmentation,PCL_XYZ_POINT_TYPES)
PCL_INSTANTIATE(LCCPSegmentation, (pcl::PointXYZ)(pcl::PointXYZRGB)(pcl::PointXYZRGBA)(pcl::PointXYZRGBNormal))
127 changes: 13 additions & 114 deletions segmentation/src/supervoxel_clustering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,117 +42,13 @@
#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>

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];
}
}
template class pcl::SupervoxelClustering<pcl::PointXYZRGBA>;
template class pcl::SupervoxelClustering<pcl::PointXYZRGB>;
template class pcl::SupervoxelClustering<pcl::PointXYZ>;

typedef pcl::SupervoxelClustering<pcl::PointXYZ>::VoxelData VoxelDataT;
typedef pcl::SupervoxelClustering<pcl::PointXYZRGB>::VoxelData VoxelDataRGBT;
Expand All @@ -162,14 +58,17 @@ 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::PointXYZRGBA>;
template class pcl::SupervoxelClustering<pcl::PointXYZRGB>;
template class pcl::SupervoxelClustering<pcl::PointXYZ>;

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> >;

0 comments on commit b345e39

Please sign in to comment.