42 #include <pcl/ml/kmeans.h>
51 template <
typename Po
intT>
55 template <
typename Po
intT>
59 if (!initCompute() || (input_ != 0 && input_->points.empty()) ||
60 (indices_ != 0 && indices_->empty())) {
66 std::vector<pcl::PCLPointField> fields;
69 if (strcmp(cluster_field_name_.c_str(),
"") == 0) {
73 x_index = pcl::getFieldIndex<PointT>(
"x", fields);
75 y_index = pcl::getFieldIndex<PointT>(
"y", fields);
77 z_index = pcl::getFieldIndex<PointT>(
"z", fields);
79 if (x_index == -1 && y_index == -1 && z_index == -1) {
80 PCL_ERROR(
"Failed to find match for field 'x y z'\n");
84 PCL_INFO(
"Use X Y Z as input data\n");
97 std::cout <<
"x index: " << x_index << std::endl;
100 memcpy(&x, &(*input_)[0] + fields[x_index].offset,
sizeof(
float));
102 std::cout <<
"xxx: " << x << std::endl;
115 int user_index = pcl::getFieldIndex<PointT>(cluster_field_name_.c_str(), fields);
117 if (user_index == -1) {
118 PCL_ERROR(
"Failed to find match for field '%s'\n", cluster_field_name_.c_str());
159 #define PCL_INSTANTIATE_Kmeans(T) template class PCL_EXPORTS pcl::Kmeans<T>;
Kmeans(unsigned int num_points, unsigned int num_dimensions)
Empty constructor.
PointCloud represents the base class in PCL for storing collections of 3D points.