PCL中添加点云数据问题:abort() has been called

将读入的一个点云数据赋值添加给一个新建的点云里:

pcl::PointCloud::Ptr cloud(new pcl::PointCloud());
pcl::io::loadPCDFile("input.pcd", *cloud);

pcl::PointCloud::Ptr cloud2(new pcl::PointCloud());
pcl::PointXYZ  Point = { 1, 1, 1 };

for (int i = 0; i < cloud->points.size(); i++)
{
	Point.x = cloud->points[i].x;
	Point.y = cloud->points[i].y;
	Point.z = cloud->points[i].z;
	cloud2->push_back(Point);
}

语句cloud2->push_back(Point);运行报错:abort() has been called。将程序改为:

pcl::PointCloud::Ptr cloud(new pcl::PointCloud());
pcl::io::loadPCDFile("input.pcd", *cloud);

pcl::PointCloud cloud2;
pcl::PointXYZ  Point = { 1, 1, 1 };

for (int i = 0; i < cloud->points.size(); i++)
{
	Point.x = cloud->points[i].x;
	Point.y = cloud->points[i].y;
	Point.z = cloud->points[i].z;
	cloud2.points.push_back(Point);
}

cloud2.points.push_back(Point);能够正常添加点云数据。

你可能感兴趣的:(PCL,PCL,点云)