自己定义了一个函数:
void gridCalculation( pcl::PointCloud<PointT> pointcloud, vector<grid>& vgrid){
........
}
然后传入参数:
pcl::PointCloud<PointT>::Ptr cloud_max_cluster(new pcl::PointCloud<PointT>);
vector<grid> vgrid;
gridCalculation(*cloud_max_cluster, vgrid);
然后出现下述报错
error: could not convert ‘cloud_max_cluster.boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ> >::operator*()’
from ‘pcl::PointCloud<pcl::PointXYZ>’ to ‘pcl::PointCloud<pcl::PointXYZ>::Ptr {aka boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ> >}’
gridCalculation(*cloud_max_cluster, vgrid);
cloud_max_cluster是Ptr的格式,所以传入*cloud_max_cluster,对指针进行取值,结果还是出现报错。
后来找到问题的原因了:
在函数声明的地方忘记改了,函数声明的地方,参数是智能指针。将函数声明的地方和函数定义的地方改成一样的即可。
void gridCalculation( pcl::PointCloud<PointT>::Ptr pointcloud, vector<grid>& vgrid);
下面是点云智能指针格式和非指针格式的转换:
pcl::PointCloud<PointT>::Ptr cloud_ptr(new pcl::PointCloud<PointT>);
pcl::PointCloud<PointT> cloud;
cloud = *cloud_ptr;
cloud_ptr = boost::make_shared<pcl::PointCloud<PointT>>(cloud);