Skip to main content

`pcd-py` is a high-speed Python library for reading and writing PCD (Point Cloud Data) files, powered by a core implementation in Rust (`rs-pcd`). It integrates seamlessly with **NumPy** for efficient data handling.

Project description

pcd-py: High-Performance PCD I/O for Python

pcd-py is a high-speed Python library for reading and writing PCD (Point Cloud Data) files, powered by a core implementation in Rust (rs-pcd). It integrates seamlessly with NumPy for efficient data handling.

Features

  • Fast I/O: Leverages Rust for multi-threaded binary and compressed PCD handling.
  • NumPy Integration: Reads/writes PCD fields directly as NumPy arrays.
  • Full Format Support: Supports ASCII, Binary, and Binary Compressed formats.
  • Metadata Access: Easy access to PCD header information (version, width, height, viewpoint).

Installation

# Requires maturin to build from source
pip install maturin numpy
cd pcd-py
maturin develop --release

Quick Start

import pcd_py
import numpy as np

# 1. Read a PCD file
meta, data = pcd_py.read_pcd("example.pcd")

print(f"Points: {meta.points}")
print(f"Fields: {data.keys()}")

x = data["x"]  # numpy array (f32)
intensity = data["intensity"]  # numpy array (f32)

# 2. Read from memory (e.g., from network)
with open("example.pcd", "rb") as f:
    data_bytes = f.read()

meta_buf, data_buf = pcd_py.read_pcd_from_buffer(data_bytes)

# 3. Write a PCD file
new_data = {
    "x": np.array([1.0, 2.0, 3.0], dtype=np.float32),
    "y": np.array([0.0, 0.0, 0.0], dtype=np.float32),
    "z": np.array([5.0, 5.0, 5.0], dtype=np.float32),
    "id": np.array([1, 2, 3], dtype=np.uint32),
}

pcd_py.write_pcd("output.pcd", new_data, format="binary_compressed")

Performance

For a point cloud with 1,000,000 points (XYZIRT schema):

  • Read Binary: ~12 ms (Zero-Copy Mmap)
  • Write Binary: ~135 ms

[!NOTE] Performance is now equivalent to native Rust, reading 1 million points in under 12ms.

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pcd_py-0.1.2-cp38-abi3-manylinux_2_28_x86_64.whl (393.3 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.28+ x86-64

File details

Details for the file pcd_py-0.1.2-cp38-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pcd_py-0.1.2-cp38-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 974d6b8f69e1537e23dbbce969380a6e759405d4e6b57034f9874b56405628eb
MD5 47f2fbed9253dd50e886a652c8a15d45
BLAKE2b-256 cf0a8f8473b0121913b18354a108eed67b9b0379cf5568f33267a61573e7aa85

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page