码迷,mamicode.com
首页 > 其他好文 > 详细

PCL中将回调函数封装到类中

时间:2018-12-22 13:52:16      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:现在   方法   ice   udid   poi   static   end   pcl   vat   

这是类中的声明

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中将回调函数封装到类中

标签:现在   方法   ice   udid   poi   static   end   pcl   vat   

原文地址:https://www.cnblogs.com/Summerio/p/10160731.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!