将点云添加到查看器时出错

时间:2015-02-10 11:15:44

标签: point-cloud-library point-clouds

运行此代码时遇到错误..

access violation in reading memory location

pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);  //fill the cloud. 
cloud-> width = 100;  
cloud->height = 10;
cloud->is_dense = false;
cloud->points.resize(cloud->width*cloud->height);  // generate the data 
//double temp_x , temp_y , temp_z;
for (size_t i = 0; i!=cloud->points.size(); i++)  { 
    cloud->points[i].x = 1024*rand()/(RAND_MAX + 1.0f); 
    cloud->points[i].y = 1024*rand()/(RAND_MAX + 1.0f);
    cloud->points[i].z = 1024*rand()/(RAND_MAX + 1.0f); 
}  
pcl::visualization::PCLVisualizer viewer;     
viewer.addPointCloud<pcl::PointXYZ>(cloud);
while(!viewer.wasStopped()){  
    viewer.spinOnce();  
}  
system("PAUSE");
return EXIT_SUCCESS;

1 个答案:

答案 0 :(得分:0)

我认为“cloud-&gt; height = 10”意味着它是有组织的点云类型。 你应该尝试设置cloud-&gt; height = 1。 祝你好运!