zoukankan      html  css  js  c++  java
  • 02 PCD文件格式

    pcd文件数据举例

    # .PCD v.7 - Point Cloud Data file format
    VERSION .7                                # 版本号
    FIELDS x y z rgb                #  指定一个点可以有的每一个维度和字段的名字
    SIZE 4 4 4 4                                # 用字节数指定每一个维度的大小。例如:
    TYPE F FFF                                    # 用一个字符指定每一个维度的类型 int uint folat
    COUNT 1 1 1 1                        # 指定每一个维度包含的元素数目
    WIDTH 640                               # 像图像一样的有序结构,有640行和480列,
    HEIGHT 480                          # 这样该数据集中共有640*480=307200个点
    VIEWPOINT 0 0 0 1 0 0 0            # 指定数据集中点云的获取视点 视点信息被指定为平移(txtytz)+四元数(qwqxqyqz)
    POINTS 307200                        # 指定点云中点的总数。从0.7版本开始,该字段就有点多余了
    DATA ascii                                        # 指定存储点云数据的数据类型。支持两种数据类型:ascii和二进制
    0.93773 0.33763 0 4.2108e+06
    0.90805 0.35641 0 4.2108e+06
    View Code

    代码:

    #include <iostream>
    #include <pcl/io/pcd_io.h>
    #include <pcl/point_types.h>
    
    int main(int argc, char **argv)
    {
        
        pcl::PointCloud<pcl::PointXYZ> cloud;
    
        // Fill in the cloud data
        cloud.width = 5;
        cloud.height = 1;
        cloud.is_dense = false;
        cloud.points.resize(cloud.width*cloud.height);
    
        for (auto &point : cloud) 
        {
            point.x = 1024 * rand() / (RAND_MAX + 1.0f);
            point.y = 1024 * rand() / (RAND_MAX + 1.0f);
            point.z = 1024 * rand() / (RAND_MAX + 1.0f);
        }
    
        pcl::io::savePCDFileASCII("test_pcd.pcd", cloud);
        std::cerr << "Saved " << cloud.size() << " data points to test_pcd.pcd." << std::endl;
    
    
        for (const auto &point : cloud) 
        {
            std::cerr << "   " << point.x << "    " << point.y << "    " << point.z << std::endl;
        }
    
    
        system("pause");
    
        return (0);
    }
    View Code

     

     

     

    参考:https://www.yuque.com/huangzhongqing/pcl/hl1582

  • 相关阅读:
    读《构建之法》8、9、10章有感
    评论
    复利计算器(4)——jQuery界面美化、自动补全
    送给搭档的“汉堡”
    MFC之TreeCtrl控件使用经验总结
    MFC绘制图片闪烁详解
    MFC 网络编程中::connect返回-1问题
    C++网络编程之select
    C++关于Condition Variable
    Mutex 和 Lock
  • 原文地址:https://www.cnblogs.com/zhaopengpeng/p/15566847.html
Copyright © 2011-2022 走看看