4 个版本 (重大更新)
| 0.5.0 | 2024年6月20日 |
|---|---|
| 0.4.0 | 2023年11月14日 |
| 0.3.0 | 2022年1月13日 |
| 0.2.0 | 2021年10月11日 |
#222 在 算法 中
197 每月下载
490KB
9K SLoC
牧草
A Rust 库,用于处理点云数据。它具有
- 对任意点属性进行细粒度支持,类似于 PDAL,但增加了类型安全性
- 非常灵活的内存模型,原生支持 Array-of-Structs (AoS) 和 Struct-of-Arrays (SoA) 内存布局(牧草称为 '交错' 和 '列式')
- 通过
pasture-io包支持读取和写入各种点云格式(如LAS、LAZ、3D Tiles以及 ASCII 文件) - 随着
pasture-algorithms包的增长,算法集也在不断增加
为此,pasture 选择灵活性而非简单性。如果您在寻找小巧简单的东西,例如处理 LAS 文件,请尝试类似 las 的包。如果您计划实现高性能工具和服务,这些工具和服务将处理非常大的点云数据,那么 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现在是VectorBufferPerAttributeVecPointStorage现在是HashMapBuffer
特性结构也有所不同
PointBuffer和PointBufferWriteable被替换为BorrowedBuffer、BorrowedMutBuffer和OwningBuffer,这些定义了缓冲区内存的所有权模型InterleavedPointBuffer和InterleavedPointBufferMut现在是InterleavedBuffer和InterleavedBufferMutPerAttributePointBuffer和PerAttributePointBufferMut现在是ColumnarBuffer和ColumnarBufferMut。一般来说,术语PerAttribute被更常用的术语Columnar所替换
不再有扩展特性(例如 PointBufferExt)。要获取/设置强类型化的点数据,你现在使用 视图,这些视图可以通过 BorrowedBuffer 和 BorrowedBufferMut 特性获得
let view = buffer.view_attribute::<Vector3<f64>>(&POSITION_3D);
视图支持对数据进行强类型访问,并且可以转换为迭代器
读者和写者新接口
PointReader 和 PointWriter 特性不再对象安全。相反,它们有 read 和 read_into 方法,这些方法在缓冲区类型上是强类型的,以提高效率。有一个 GenericPointReader 类型,它使用静态分发并封装了LAS、LAZ和3D Tiles的读取器
开发
pasture 处于开发初期,可能存在错误。
许可证
pasture 根据 Apache 许可证(版本 2.0)的条款分发。有关详细信息,请参阅 LICENSE。
依赖项
~6.5–10MB
~161K SLoC