#point-cloud #points #data-points #lidar #pasture

pasture-io

使用pasture支持读取和写入点云文件

5个版本 (破坏性)

0.5.0 2024年6月20日
0.4.0 2023年11月2日
0.3.0 2022年1月13日
0.2.0 2021年10月11日
0.1.0 2021年3月22日

#428解析器实现

Download history 1/week @ 2024-05-17 104/week @ 2024-06-14 41/week @ 2024-06-21 5/week @ 2024-06-28 27/week @ 2024-07-05

每月274次下载

自定义许可

770KB
16K SLoC

pasture

一个用于处理点云数据的Rust库。它具有

  • 对任意点属性的细粒度支持,类似于PDAL,但增加了类型安全性
  • 一个非常灵活的内存模型,原生支持数组和结构体数组(AoS)以及结构体数组(SoA)内存布局(pasture称为'交错'和'列式')
  • 使用pasture-io crate支持读取和写入各种点云格式(如LASLAZ3D Tiles以及ASCII文件)
  • 带有pasture-algorithms crate的算法集

为此,pasture选择了灵活性而非简单性。如果你在寻找一些小而简单的工具,例如处理LAS文件,尝试像las这样的crate。如果你打算实现高性能的工具和服务,将处理非常大的点云数据,pasture就是你要找的!

用法

将此添加到你的Cargo.toml

[dependencies]
pasture-core = "0.4.0"
# You probably also want I/O support
pasture-io = "0.4.0"

以下是如何从LAS文件中加载点云并进行操作的示例

use anyhow::{bail, Context, Result};
use pasture_core::{
    containers::{BorrowedBuffer, VectorBuffer},
    layout::attributes::POSITION_3D,
    nalgebra::Vector3,
};
use pasture_io::base::{read_all};

fn main() -> Result<()> {
    // Reading a point cloud file is as simple as calling `read_all`
    let points = read_all::<VectorBuffer, _>("pointcloud.las").context("Failed to read points")?;

    if points.point_layout().has_attribute(&POSITION_3D) {
        for position in points
            .view_attribute::<Vector3<f64>>(&POSITION_3D)
            .into_iter()
            .take(10)
        {
            println!("({};{};{})", position.x, position.y, position.z);
        }
    } else {
        bail!("Point cloud files has no positions!");
    }

    Ok(())
}

有关更多示例,请参阅pasture_core示例pasture_io示例

从版本<0.4以下迁移

从版本0.4开始,pasture-core的缓冲区API被重写。如果你从早期版本迁移,以下是一些迁移指南。同时,请查看containers模块的文档。

新的缓冲区类型

主要的缓冲区类型已被重命名

  • InterleavedVecPointStorage现在是VectorBuffer
  • PerAttributeVecPointStorage现在是HashMapBuffer

特质的结构也不同

  • PointBufferPointBufferWriteable 已被替换为 BorrowedBufferBorrowedMutBufferOwningBuffer,它们定义了缓冲区内存的所有权模型。
  • InterleavedPointBufferInterleavedPointBufferMut 现在是 InterleavedBufferInterleavedBufferMut
  • PerAttributePointBufferPerAttributePointBufferMut 现在是 ColumnarBufferColumnarBufferMut。一般来说,术语 PerAttribute 被更常见的术语 Columnar 替换。

不再有扩展特性(例如 PointBufferExt)。要获取/设置强类型点数据,您现在使用 视图,这些视图可以通过 BorrowedBufferBorrowedBufferMut 特性获取。

let view = buffer.view_attribute::<Vector3<f64>>(&POSITION_3D);

视图支持对数据的强类型访问,并且可以转换为迭代器。

新的读写接口

PointReaderPointWriter 特性不再安全地作为对象。相反,它们具有 readread_into 方法,这些方法在缓冲区类型上强类型化,以提高效率。有一个 GenericPointReader 类型,它使用静态分派并封装了LAS、LAZ和3D Tiles的读取器。

开发

pasture 处于开发初期阶段,可能会出现错误。

许可

pasture 根据 Apache 许可协议(版本 2.0)进行分发。有关详细信息,请参阅 LICENSE

依赖项

~9MB
~176K SLoC