• 驱动点云格式修改带来的效率提升


    驱动点云格式修改带来的效率提升

    背景:
    原有的自定义点云结构在读取、传输、解码整个时间段耗时非常巨大,因此将点云结构进行升级,提高整体运行时间。

    protobuf字段类型介绍

    .proto TypeNotesC++ Type
    doubledouble
    floatfloat
    int32Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead.int32
    int64Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead.int64
    uint32Uses variable-length encoding.uint32
    uint64Uses variable-length encoding.uint64
    sint32Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s.int32
    sint64Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s.int64
    fixed32Always four bytes. More efficient than uint32 if values are often greater than 228.uint32
    fixed64Always eight bytes. More efficient than uint64 if values are often greater than 256.uint64
    sfixed32Always four bytes.int32
    sfixed64Always eight bytes.int64
    boolbool
    stringA string must always contain UTF-8 encoded text.string
    bytesMay contain any arbitrary sequence of bytes.string

    修改前:

    message PointXYZI {
      optional float x = 1 [default = nan];
      optional float y = 2 [default = nan];
      optional float z = 3 [default = nan];
      optional uint32 intensity = 4 [default = 0];
    }
    
    message PointCloud {
      repeated PointXYZIT point = 1;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    修改后:

    message PointXYZI2 {
      repeate float x_array = 1 [default = nan];
      repeate float y_array = 2 [default = nan];
      repeate float z_array = 3 [default = nan];
      optional bytes intensity_array = 4 [default = 0];
    }
    
    message PointCloud {
      optional PointXYZI2 point_array = 1;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    修改点:

    • PointXYZI由重复的数据结构,改为重复的点。

    意义在于:

    • 原本读写需要多次读写这个结构体,现在改为直接一次性存储点,将所有点都存到这个结构体里面。
    • 而且将intensity等参数改为bytes,后续解析出来,减少了整体点云包的大小,减少传输时间。

    protobuf修改字段为bytes需要考虑一些问题:

    • 电脑大序端和小序端的问题;不同系统会不一样,解读出的bytes会不同。如果其他语言调用C++的库,不通过自己的语言解析,能解决问题?
    • 多语言兼容问题,解析问题
    • 字段对齐问题

    目前占用时间分析:

    经验:

    • 通过减小字段类型,提高传输速率,空间换时间;
    • 通过一次性写入替代多次写入,解决时间,这部分节约的时间占大头。
  • 相关阅读:
    目前最稳定的Win10 21H2版本19044.2006
    2500家门店倒闭:实体店败给电商已成定局?
    java基于Springboot+vue的购物电商平台设计与实现 elementui
    Jenkins实践指南--pipeline概述
    责任链模式 行为型设计模式之十
    6.1.2 基于MSI文件安装MySQL
    10个优秀的Python库,实用且有趣
    单调栈!!!
    11设计模式-结构型模式-外观模式
    DEJA_VU3D - Cesium功能集 之 086-地图打印(场景专题图输出)完整版
  • 原文地址:https://blog.csdn.net/moneymyone/article/details/126017023