zoukankan      html  css  js  c++  java
  • 基于PCL绘制模型并渲染

    博客转载自:https://blog.csdn.net/wokaowokaowokao12345/article/details/51321988

    前言

    抛开算法层面不谈,要利用PCL库中PCLVisualizer可视化类,显示出不同模型并对模型做出不同渲染,制作出丰富的可视化效果以增强自己应用的功能。下面将对如何添加立方体模型和圆球模型到视窗并渲染进行一个大概描述。

    立方体模型

    //向视窗添加一个立方体模型并渲染,只显示线框。若不要显示线框将下面一行代码注释即可。
    viewer->addCube(0.1, 0.2, 0.1, 0.2, 0.1, 0.2);
    viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_REPRESENTATION, pcl::visualization::PCL_VISUALIZER_REPRESENTATION_WIREFRAME,"cube");
    

    PCL Docs 

    bool addCube (const pcl::ModelCoefficients &coefficients, const std::string &id="cube", int viewport=0)
    bool addCube (const Eigen::Vector3f &translation, const Eigen::Quaternionf &rotation, double width, double height, double depth, const std::string &id="cube", int viewport=0)
    bool addCube (float x_min, float x_max, float y_min, float y_max, float z_min, float z_max, double r=1.0, double g=1.0, double b=1.0, const std::string &id="cube", int viewport=0)

    圆球模型

    //向视窗添加一个立方体模型并渲染,透明显示。若不要透明显示将下面一行代码注释即可。
    viewer->addSphere(cloud->points.at(0), 0.1, 1, 1, 1);
    viewer->setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_OPACITY, 0.3, "sphere");

    圆球模型

    #include"Eigen/Core"
    //绕Z轴旋转15°
    Eigen::AngleAxisf rotation_vector(M_PI / 4, Eigen::Vector3f(0, 0, 1));
    _viewer->addCube(Eigen::Vector3f(16.4842, 11.3017, 0), Eigen::Quaternionf(rotation_vector),1.3,1.0,1.1,"cube2");
    _viewer>setShapeRenderingProperties(pcl::visualization::PCL_VISUALIZER_REPRESENTATION, pcl::visualization::PCL_VISUALIZER_REPRESENTATION_WIREFRAME, "cube2");
    //移除Shape
    _viewer->removeShape("cube2");

    PCL Docs

    bool addSphere (const PointT &center, double radius, double r, double g, double b, const std::string &id="sphere", int viewport=0)
    bool addSphere (const pcl::ModelCoefficients &coefficients, const std::string &id="sphere", int viewport=0)
    bool addSphere (const PointT &center, double radius, const std::string &id="sphere", int viewport=0)
    

    渲染模式

    PCL Docs

    //Set the rendering properties of a shape
    bool setShapeRenderingProperties (int property, double value, const std::string &id, int viewport=0)
    //Set the rendering properties of a shape (2x values - e.g., LUT minmax values) 
    bool setShapeRenderingProperties (int property, double val1, double val2, const std::string &id, int viewport=0)
    //Set the rendering properties of a shape (3x values - e.g., RGB)
    bool setShapeRenderingProperties (int property, double val1, double val2, double val3, const std::string &id, int viewport=0)
    

    渲染参数说明

  • 相关阅读:
    Android PopupWindow 弹窗背景半透明,设置最大高度
    Android性能优化之:ViewStub
    EventBus使用详解(一)——初步使用EventBus
    Android开发中,那些让你相见恨晚的方法、类或接口
    android 提高进程优先级 拍照永不崩溃(闪退)
    Android框架 加载图片 库 Picasso 的使用简介
    vc 取windows系统信息 版本 cpu信息 内存信息 ie版本信息 office版本
    VC 三点 划 曲线
    VC 类泡泡龙游戏算法
    vc 判断哪个按键 被按下 消息 按键 状态
  • 原文地址:https://www.cnblogs.com/flyinggod/p/9389196.html
Copyright © 2011-2022 走看看