Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 如何使用opencv显示RGB点云?_Visual Studio_Opencv_Visual C++_Point Cloud Library_Point Clouds - Fatal编程技术网

Visual studio 如何使用opencv显示RGB点云?

Visual studio 如何使用opencv显示RGB点云?,visual-studio,opencv,visual-c++,point-cloud-library,point-clouds,Visual Studio,Opencv,Visual C++,Point Cloud Library,Point Clouds,我尝试使用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>&g

我尝试使用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();
cv::viz::Viz3d查看器(“Velodyne”);
pcl::search::search::Ptr tree=boost::shared_Ptr(新的pcl::search::KdTree);
pcl::PointCloud::Ptr法线(新pcl::PointCloud);
pcl::正态估计正态估计;
正态_估计.集搜索法(树);
正态估值器。setInputCloud(cloud_过滤);
正态估计量setKSearch(50);
正态估计量计算(*正态);
pcl::IndicateSPTR指数(新std::vector);
pcl::PassThroughpass;
pass.setInputCloud(已过滤的云);
pass.setFilterFieldName(“z”);
通过设置过滤器限制(0.0,1.0);
通过过滤器(*索引);
pcl::RegionRowingReg;
注册设置最小集群大小(50);
注册表setMaxClusterSize(1000000);
注册设置搜索方法(树);
注册编号(30);
注册setInputCloud(云过滤);
//注册设置索引(索引);
注册设置输入法线(法线);
注册设置平滑度阈值(3.0/180.0*M_-PI);
注册设置曲率阈值(1.0);
int i=0,
nr_points=(int)输入_cloud->points.size();
while(输入\u cloud->points.size()>0.3*nr\u points){
std::向量簇;
注册摘录(集群);
pcl::PointCloud::Ptr colored_cloud=reg.getColoredCloud();
对于(int j=0;
jpoints.size();
(j++){
buffer.push_back(cv::Vec3f(彩色_云->点[j].x,彩色_云->点[j].y,彩色_云->点[j].z));
}
输入_cloud->clear();
云过滤->清除();
彩色云->清晰();
}
//创建小部件
cv::Mat cloudMat=cv::Mat(static_cast(buffer.size())、1、cv_32FC3和buffer[0]);
cv::viz::WCloudCollection all;
all.addCloud(cloudMat);
setBackgroundColor(cv::viz::Color::black());
查看器.showWidget(“云”,全部);
viewer.spinOnce();
buffer.clear();

使用体素栅格过滤器进行下采样后,过滤的云是相同的点云

为什么不使用pcl的可视化工具呢?我正在尝试处理激光雷达传感器的3D数据,而不仅仅是一个PCD文件。OpenCV在这方面一直在为我工作。我看到你使用的是彩色云的xyz坐标,而不是颜色数据。这是故意的吗?