我正在尝试使用PCL(1.8.1)教程中给出的代码实现区域增长算法进行分割,但我使用Opencv(3.3.0)进行显示 . 然而,当我尝试简单地使用小部件和垫子来显示时,我没有得到任何颜色 . 我该怎么办?

cv::viz::Viz3d viewer("Velodyne");
pcl::search::Search<pcl::PointXYZ>::Ptr tree=boost::shared_ptr<pcl::search::Search<pcl::PointXYZ>>(new pcl::search::KdTree<pcl::PointXYZ>);
pcl::PointCloud <pcl::Normal>::Ptr normals(new pcl::PointCloud <pcl::Normal>);
pcl::NormalEstimation<pcl::PointXYZ,
pcl::Normal>normal_estimator;
normal_estimator.setSearchMethod(tree);
normal_estimator.setInputCloud(cloud_filtered);
normal_estimator.setKSearch(50);
normal_estimator.compute(*normals);
pcl::IndicesPtr indices(new std::vector <int>);
pcl::PassThrough<pcl::PointXYZ>pass;
pass.setInputCloud(cloud_filtered);
pass.setFilterFieldName("z");
pass.setFilterLimits(0.0, 1.0);
pass.filter(*indices);
pcl::RegionGrowing<pcl::PointXYZ,
pcl::Normal>reg;
reg.setMinClusterSize(50);
reg.setMaxClusterSize(1000000);
reg.setSearchMethod(tree);
reg.setNumberOfNeighbours(30);
reg.setInputCloud(cloud_filtered);
//reg.setIndices (indices);
reg.setInputNormals(normals);
reg.setSmoothnessThreshold(3.0 / 180.0 * M_PI);
reg.setCurvatureThreshold(1.0);
int i=0,
nr_points=(int)input_cloud->points.size();
while (input_cloud->points.size() > 0.3 * nr_points) {
  std: :vector <pcl::PointIndices> clusters;
  reg.extract(clusters);
  pcl: :PointCloud <pcl::PointXYZRGB>::Ptr colored_cloud=reg.getColoredCloud();
  for (int j=0;
  j < colored_cloud->points.size();
  j++) {
    buffer.push_back(cv: :Vec3f(colored_cloud->points[j].x, colored_cloud->points[j].y, colored_cloud->points[j].z));
  }
  input_cloud->clear();
  cloud_filtered->clear();
  colored_cloud->clear();
}

// Create Widget
cv::Mat cloudMat=cv::Mat(static_cast<int>(buffer.size()), 1, CV_32FC3, &buffer[0]);
cv::viz::WCloudCollection all;
all.addCloud(cloudMat);
viewer.setBackgroundColor(cv::viz::Color::black());
viewer.showWidget("Cloud", all);
viewer.spinOnce();
buffer.clear();

cloud_filtered是使用体素网格过滤器进行下采样后的相同点 Cloud .