42 #include <pcl/ml/kmeans.h>
51 template <
typename Po
intT>
55 template <
typename Po
intT>
59 template <
typename Po
intT>
63 if (!initCompute() || (input_ != 0 && input_->points.empty()) ||
64 (indices_ != 0 && indices_->empty())) {
70 std::vector<pcl::PCLPointField> fields;
73 if (strcmp(cluster_field_name_.c_str(),
"") == 0) {
77 x_index = pcl::getFieldIndex<PointT>(
"x", fields);
79 y_index = pcl::getFieldIndex<PointT>(
"y", fields);
81 z_index = pcl::getFieldIndex<PointT>(
"z", fields);
83 if (x_index == -1 && y_index == -1 && z_index == -1) {
84 PCL_ERROR(
"Failed to find match for field 'x y z'\n");
88 PCL_INFO(
"Use X Y Z as input data\n");
101 std::cout <<
"x index: " << x_index << std::endl;
104 memcpy(&x, &(*input_)[0] + fields[x_index].offset,
sizeof(
float));
106 std::cout <<
"xxx: " << x << std::endl;
119 int user_index = pcl::getFieldIndex<PointT>(cluster_field_name_.c_str(), fields);
121 if (user_index == -1) {
122 PCL_ERROR(
"Failed to find match for field '%s'\n", cluster_field_name_.c_str());
163 #define PCL_INSTANTIATE_Kmeans(T) template class PCL_EXPORTS pcl::Kmeans<T>;
~Kmeans()
This destructor destroys.
Kmeans(unsigned int num_points, unsigned int num_dimensions)
Empty constructor.
PointCloud represents the base class in PCL for storing collections of 3D points.