报错信息
做PCL时报错如下:
错误产生的位置为:
错误原因
registerCallback的参数function定义时候的参数必须是constPtr。
解决方案
注意我们的参数function。
在定义位置有下面两种定义方式:
boost::function<void(const pcl::PointCloud<PointType>::ConstPtr&)> function = [&pointCloud_XYZRGBA, &mutex](const pcl::PointCloud<PointType>::ConstPtr& ptr) {
boost::mutex::scoped_lock lock(mutex);
/* Point Cloud Processing */
pointCloud_XYZRGBA = ptr->makeShared();
//ptr->makeShared() = NULL;
};
boost::function<void(const pcl::PointCloud<PointType>::Ptr&)> function = [&pointCloud_XYZRGBA, &mutex](const pcl::PointCloud<PointType>::Ptr& ptr) {
boost::mutex::scoped_lock lock(mutex);
/* Point Cloud Processing */
pointCloud_XYZRGBA = ptr->makeShared();
//ptr->makeShared() = NULL;
};
第一种方式不会出错。