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.1-cp38-abi3-manylinux_2_34_x86_64.whl (380.4 kB view details)

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

File details

Details for the file pcd_py-0.1.1-cp38-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pcd_py-0.1.1-cp38-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 76d1e66c3163f9b9657b44512d65169a65f086a98dd882dadb974b82ad151a48
MD5 47e5d5cb0a36116772504c9c7ec02b1e
BLAKE2b-256 7a0ce64a27f9d7fe0d51accf2004d62a0ab7cd2db6eb2cf1ade78e470dfed6f8

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