Reputation: 83
I want to cluster 6d data by PCL;
typedef Eigen::Matrix<double,6,1> Vector6d;
pcl::search::KdTree<Vector6d>::Ptr tree (new pcl::search::KdTree<Vector6d>);
tree->setInputCloud (pose_cloud);
pcl::EuclideanClusterExtraction<Vector6d> ec;
ec.setClusterTolerance (0.2);
ec.setMinClusterSize (1);
ec.setMaxClusterSize (25000)
ec.setSearchMethod (tree);
ec.setInputCloud (pose_cloud);
std::vector<pcl::PointIndices> cluster_indices;
ec.extract (cluster_indices);
There will many errors about undefined reference.
The pcl::PointXYZRGB
seems like a 6d data, Can I use pcl::PointXYZRGB
to store my data? But the clustering seems to only happen in the first three data of XYZ.
Upvotes: 0
Views: 253
Reputation: 2180
Eucleadien clustering distance is based on radius search queries, which is based on the point-representation. So the templated PointRepresentation
class is responsible for generating the vector on which the clustering is performed. In the case of pcl::PointXYZRGB
, only the x-y-z coordinates are vectorized.
Option 1
You can override the default PointRepresentation
, as is shown in the pair-wise registration tutorial.
Example - based on the tutorial, but adapted for pcl::PointXYZINormal (as you're interested in 6 floats, so pcl::PointXYZRGB isn't suitable). Also note that unlike the tutorial the PointRepresentation class should be set to the tree object.
class MyPointRepresentation : public pcl::PointRepresentation <pcl::PointXYZINormal>
{
using pcl::PointRepresentation<pcl::PointXYZINormal>::nr_dimensions_;
public:
MyPointRepresentation ()
{
// Define the number of dimensions
nr_dimensions_ = 6;
}
// Override the copyToFloatArray method to define our feature vector
virtual void copyToFloatArray (const pcl::PointXYZINormal &p, float * out) const
{
out[0] = p.x;
out[1] = p.y;
out[2] = p.z;
out[0] = p.normal_x;
out[1] = p.normal_y;
out[2] = p.normal_z;
}
};
// Instantiate our custom point representation (defined above) and weight the dimensions
MyPointRepresentation point_representation;
float alpha[6] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
point_representation.setRescaleValues (alpha);
pcl::search::KdTree<pcl::PointXYZINormal>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZINormal>);
tree->setPointRepresentation (boost::make_shared<const MyPointRepresentation> (point_representation));
Option 2
I think you can use the pcl::Histogram<N>
point type. I can't find where this is defined, but I believe it is safe to assume that it's point representation is just it's N
values.
Upvotes: 1