PCL中将回调函数封装到类中
Posted summerio
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PCL中将回调函数封装到类中相关的知识,希望对你有一定的参考价值。
这是类中的声明
private://点云回调函数 NuClearTask_MyPointCloudHandle //点云选择 static void ps_callback(const pcl::visualization::AreaPickingEvent& event, void* object) { NuClearTask *pThisObject = (NuClearTask*)object; pThisObject->PointSelect_callback(event); } void PointSelect_callback(const pcl::visualization::AreaPickingEvent& event);
调用的时候把点云所在类的对象指针传入
NuPointCloudHandle.viewer->registerAreaPickingCallback(ps_callback, (void*)this);
方法的实现在PointSelect_callback函数中
//点云选择 void NuClearTask::PointSelect_callback(const pcl::visualization::AreaPickingEvent& event) { static int num = 0; NuPointCloudHandle.selected_points_3d->points.clear(); std::vector< int > indices; if ((int)event.getPointsIndices(indices) == -1) return; for (int i = 0; i < indices.size(); ++i) { NuPointCloudHandle.selected_points_3d->points.push_back(NuPointCloudHandle.cloud->points.at(indices[i])); } std::string cloudName = to_string(num++) + "cloudred"; pcl::visualization::PointCloudColorHandlerCustom<PointTypeXYZ> red(NuPointCloudHandle.selected_points_3d, 255, 0, 0); NuPointCloudHandle.viewer->addPointCloud(NuPointCloudHandle.selected_points_3d, red, cloudName); NuPointCloudHandle.viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, cloudName); NuPointCloudHandle.viewer->updatePointCloud(NuPointCloudHandle.cloud, CloudID); }
以上是关于PCL中将回调函数封装到类中的主要内容,如果未能解决你的问题,请参考以下文章
如何通过单击适配器类中代码的项目中的删除按钮来删除列表视图中的项目后重新加载片段?
为啥 Typescript 在转译代码中将 .default() 添加到类构造函数中?
Android当中的MVP模式终篇---关于对MVP模式中代码臃肿