pcl::visualization::PCLVisualizer添加文字显示注意事项

注意

PCLVisualizer的addText()方法不支持中文显示

viewer.addText("不支持中文显示", 20, 60, "text");

最简单的用法,只设置文字显示的位置:

pcl::visualization::PCLVisualizer viewer("点云显示");
viewer.addText("cloud", 20, 60, "text");

复杂一点的用法,可以设置字体颜色和大小:

bool
        addText (const std::string &text,
                 int xpos, int ypos,
                 const std::string &id = "", int viewport = 0);

        /** \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] 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, double r, double g, double b,
                 const std::string &id = "", int viewport = 0);

        /** \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);
viewer.addText("cloud", 20, 60,16,255,255,255, "text");

#include <iostream> #include <pcl/io/pcd_io.h> #include <pcl/point_types.h> #include <pcl/features/normal_3d_omp.h> // 使用OMP加速法向量计算 #include <pcl/registration/icp_nl.h> // 非线性ICP算法 #include <pcl/visualization/pcl_visualizer.h> #include <boost/thread/thread.hpp> #include <pcl/console/time.h> // 控制台时间计时器 using namespace std; // 计算法线 pcl::PointCloud<pcl::PointNormal>::Ptr compute_normals(pcl::PointCloud<pcl::PointXYZ>::Ptr input_cloud) { pcl::NormalEstimationOMP<pcl::PointXYZ, pcl::Normal> normal_estimator; pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud<pcl::Normal>); pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>); normal_estimator.setNumberOfThreads(8); // 使用多线程加速法线计算 normal_estimator.setInputCloud(input_cloud); // 设置输入点云 normal_estimator.setSearchMethod(tree); // 设置 KD 树搜索 normal_estimator.setKSearch(10); // 设置 K 近邻搜索 normal_estimator.compute(*normals); // 计算法线 // 拼接点云数据与法线 pcl::PointCloud<pcl::PointNormal>::Ptr cloud_with_normals(new pcl::PointCloud<pcl::PointNormal>); pcl::concatenateFields(*input_cloud, *normals, *cloud_with_normals); return cloud_with_normals; } // 执行 LM-ICP 配准 void run_lm_icp(pcl::PointCloud<pcl::PointNormal>::Ptr& source_normal, pcl::PointCloud<pcl::PointNormal>::Ptr& target_normal, Eigen::Matrix4f& final_transform, pcl::PointCloud<pcl::PointNormal>::Ptr& icp_cloud) { // 初始化 LM ICP 对象 pcl::IterativeClosestPointNonLinear<pcl::PointNormal, pcl::PointNormal> lm_icp; // 设置 ICP 参数 lm_icp.setInputSource(source_normal); lm_icp.setInputTarget(target_normal); lm_icp.setTransformationEpsilon(1e-10); // 设置最小转换差异 lm_icp.setMaxCorrespondenceDistance(10); // 设置最大对应点距离 lm_icp.setEuclideanFitnessEpsilon(0.001); // 设置均方误差收敛条件 lm_icp.setMaximumIterations(50); // 设置最大迭代次数 // 执行 LM-ICP 配准 lm_icp.align(*icp_cloud); final_transform = lm_icp.getFinalTransformation(); std::cout
03-08
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

SOC罗三炮

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

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

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

打赏作者

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

抵扣说明:

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

余额充值