I have the vector to store pointers of point clouds:
std::vector<pcl::PointCloud<PointType>::Ptr> List;
In a loop I am trying to push_back point cloud pointers in it.
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
while(condition)
{...
List.push_back(cloud);
cloud->clear();
}
It adds point clouds, but at each iteration all values stored in the vector previously are replaced by the newly added value.
So lets say the size of the last point cloud I added is 400 and I added 5 point clouds in the iteration.
After the loop, if I check the sizes of stored 5 clouds, the results will be 400 400 400 400 400
Does anyone have an idea how to fix it?
Thanks