PCL点云库可视化常用函数与经验总结

目录

一, makeShared:使点云返回一个智能指针(深拷贝)

二,pcl::visualization::PCLVisualizer

viewer.setPointCloudRenderingProperties

setPointCloudRenderingProperties() 

Note

三,RenderingProperties

四, 添加文本addText、updateText

五,点云分割

getColoredCloud()

六, 经验总结


一, makeShared:使点云返回一个智能指针(深拷贝)

      /** \brief Copy the cloud to the heap and return a smart pointer
        * Note that deep copy is performed, so avoid using this function on non-empty clouds.
        * The changes of the returned cloud are not mirrored back to this one.
        * \return shared pointer to the copy of the cloud
        */
      inline Ptr 
      makeShared () const { return Ptr (new PointCloud<PointT> (*this)); }

二,pcl::visualization::PCLVisualizer

viewer.setPointCloudRenderingProperties

setPointCloudRenderingProperties() 

bool pcl::visualization::PCLVisualizer::setPointCloudRenderingProperties	(	
              int    property,
              double 	value,
              const std::string & 	id = "cloud",
              int 	viewport = 0 
)	

Set the rendering properties of a PointCloud.

Parameters

[in]propertythe property type
[in]valuethe value to be set
[in]idthe point cloud object id (default: cloud)
[in]viewportthe view port where the Point Cloud's rendering properties should be modified (default: all)

Note

注意事项:

设置属性前需要指定id,默认为“cloud”,如果没有设置“cloud”的id,或者其他id,将不起作用。

The list of properties can be found in pcl::visualization::LookUpTableRepresentationProperties.

三,RenderingProperties

enum pcl::visualization::RenderingProperties

Set of rendering properties.

Enumerator
PCL_VISUALIZER_POINT_SIZE 

integer starting from 1

PCL_VISUALIZER_OPACITY 

Float going from 0.0 (transparent) to 1.0 (opaque)

PCL_VISUALIZER_LINE_WIDTH 

Integer starting from 1.

PCL_VISUALIZER_FONT_SIZE 
PCL_VISUALIZER_COLOR 

3 floats (R, G, B) going from 0.0 (dark) to 1.0 (light)

PCL_VISUALIZER_REPRESENTATION 
PCL_VISUALIZER_IMMEDIATE_RENDERING 
PCL_VISUALIZER_SHADING 
PCL_VISUALIZER_LUT 

colormap type pcl::visualization::LookUpTableRepresentationProperties

PCL_VISUALIZER_LUT_RANGE 

two doubles (min and max) or PCL_VISUALIZER_LUT_RANGE_AUTO

四, 添加文本addText、updateText

        /** \brief Add a text to screen
          * \param[in] text the text to add
          * \param[in] xpos the X position on screen where the text should be added
          * \param[in] ypos the Y position on screen where the text should be added
          * \param[in] fontsize the fontsize of the text
          * \param[in] r the red color value
          * \param[in] g the green color value
          * \param[in] b the blue color value
          * \param[in] id the text object id (default: equal to the "text" parameter)
          * \param[in] viewport the view port (default: all)
          */
        bool
        addText (const std::string &text, int xpos, int ypos, int fontsize, double r, double g, double b,
                 const std::string &id = "", int viewport = 0);

五,点云分割

getColoredCloud()

如果云被成功分割,则函数返回彩色云。否则返回一个空指针。属于同一段的点具有相同的颜色。但是这个函数并不能保证不同的片段会有不同的颜色(这完全取决于RNG)。未在索引数组中列出的点将用红色表示。

六, 经验总结

在Visual Studio中使用Release模式运行速度更快,如果是为了运行程序,而不是调试,尽量选择Release模式,而不是Debug模式。

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
PCL(Point Cloud Library)是一个开源的点云处理,提供了点云数据的各种算法和工具。而MFC(Microsoft Foundation Classes)是一个用于开发Windows应用程序的C++。 要实现PCL点云可视化内嵌MFC,首先需要在MFC的应用程序中创建一个显示图像的控件,可以使用MFC中的CWnd派生类或自定义的继承自CWnd的窗口类。 在创建好显示点云的控件后,需要通过PCL的相关接口将点云数据加载到内存中。可以使用PCL中的PointCloud类来存储点云数据,使用PointCloud类的成员函数来进行点云数据的操作。 接下来,可以在MFC应用程序的消息循环中,利用PCL提供的可视化工具类(如pcl::visualization::PCLVisualizer)来实现点云可视化。可以将点云数据通过vtkSmartPointer<wndObj>将点云数据传递给可视化对象,并利用该可视化对象的成员函数来设置点云的颜色、大小、透明度等属性。 最后,通过在控件的绘制函数中调用可视化对象的成员函数来实现点云的实时更新和渲染。可以将绘制函数与消息循环结合起来,使得点云可以根据用户的操作实时更新显示。 总结起来,实现PCL点云可视化内嵌MFC的步骤包括:创建显示点云的控件,加载点云数据到内存,利用PCL提供的可视化工具类实现点云可视化,以及在控件的绘制函数中更新和渲染点云。这样就能够在MFC应用程序中实现PCL点云可视化了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SOC罗三炮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值