`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
- 🚀 Blazing Fast:
- Mmap + parallel decoding for ~10ms read time on 1M points
- Powered by pcd-rs v0.2.0 optimizations (batch I/O, platform-optimized endianness)
- NumPy Integration: Read/write PCD fields directly as NumPy arrays
- Full Format Support:
ASCII,Binary, andBinary Compressed - Metadata Access: Easy access to PCD header info (version, fields, width, height, viewpoint)
Performance
Benchmarks on Apple Silicon (1M points, XYZIRT format):
| Operation | Time | Throughput |
|---|---|---|
| Read Binary (Mmap) | ~10 ms | ~3 GB/s ⚡ |
| Write Binary | ~120 ms | ~250 MB/s |
| Read Compressed | ~65 ms | ~460 MB/s |
Installation
# From PyPI (coming soon)
pip install pcd-py
# From source (requires Rust toolchain)
pip install maturin numpy
cd pcd-py
maturin develop --release
Quick Start
Reading a PCD File
import pcd_py
import numpy as np
# Read a PCD file (supports binary, binary_compressed, ascii)
meta, data = pcd_py.read_pcd("lidar.pcd")
print(f"Points: {meta.points}")
print(f"Fields: {meta.fields}") # e.g., ['x', 'y', 'z', 'intensity', 'ring', 'timestamp']
# Access fields as numpy arrays
x = data["x"] # np.ndarray (float32)
y = data["y"] # np.ndarray (float32)
z = data["z"] # np.ndarray (float32)
intensity = data["intensity"] # np.ndarray (float32)
ring = data["ring"] # np.ndarray (uint16)
timestamp = data["timestamp"] # np.ndarray (float64)
Reading from Memory Buffer
# Useful for network streams or embedded resources
with open("example.pcd", "rb") as f:
pcd_bytes = f.read()
meta, data = pcd_py.read_pcd_from_buffer(pcd_bytes)
Writing a PCD File
import numpy as np
import pcd_py
# Prepare data as dict of numpy arrays
points = 1000
data = {
"x": np.random.randn(points).astype(np.float32),
"y": np.random.randn(points).astype(np.float32),
"z": np.random.randn(points).astype(np.float32),
"intensity": np.random.rand(points).astype(np.float32),
"ring": np.random.randint(0, 64, points).astype(np.uint16),
"timestamp": np.arange(points, dtype=np.float64) * 0.1,
}
# Write as binary (fastest)
pcd_py.write_pcd("output.pcd", data, format="binary")
# Write as binary_compressed (smaller file size)
pcd_py.write_pcd("output_compressed.pcd", data, format="binary_compressed")
# Write as ASCII (human readable)
pcd_py.write_pcd("output_ascii.pcd", data, format="ascii")
API Reference
read_pcd(path: str) -> (MetaData, dict)
Read a PCD file from disk using memory-mapped I/O.
Returns:
MetaData: Object withversion,width,height,points,viewpoint,fieldsdict: Field name → numpy array mapping
read_pcd_from_buffer(buffer: bytes) -> (MetaData, dict)
Read a PCD file from a bytes buffer.
write_pcd(path, data, format="binary", viewpoint=None)
Write a PCD file to disk.
Args:
path: Output file pathdata: Dict of field_name → numpy arrayformat:"ascii","binary", or"binary_compressed"viewpoint: Optional[tx, ty, tz, qw, qx, qy, qz](default: identity)
Supported NumPy dtypes
| NumPy dtype | PCD Type |
|---|---|
float32 |
F32 |
float64 |
F64 |
uint8 |
U8 |
uint16 |
U16 |
uint32 |
U32 |
int8 |
I8 |
int16 |
I16 |
int32 |
I32 |
What's New in v0.2.0
- ⚡ 30-50% faster reading via pcd-rs v0.2.0 optimizations
- 📋
meta.fieldsnow available for schema inspection - 🔧 Improved error messages
- 🦀 Edition 2021 compatibility
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pcd_py-0.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pcd_py-0.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 434.9 kB
- Tags: PyPy, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fd1310e4efb665b2d6b9ebc28573b7d1a8cead46611f9b6072ded7f8f9b7aba
|
|
| MD5 |
26d3a49e02fa126741a5af6f2ba0064c
|
|
| BLAKE2b-256 |
c32db3215c176a9c204e1f87274668c6b839e7d251a7bfa422999692625433e5
|
File details
Details for the file pcd_py-0.2.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pcd_py-0.2.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 437.1 kB
- Tags: PyPy, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd733e8a13c0c933dff27cf9669ca7d537520e04f006c5097569ed499949ccdf
|
|
| MD5 |
4fb371b749d2b7027bcc0c8c678d2aab
|
|
| BLAKE2b-256 |
1e6fd2cd6346bf3c27a7dd20b148123480819fd6f5e817a2b4cfe914388447a1
|
File details
Details for the file pcd_py-0.2.0-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: pcd_py-0.2.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 270.2 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e1e2c7b40bf847436d0bce5b6832e1eed6a9806bef05736852a9654fdae3e97
|
|
| MD5 |
8424e4f620dd39b90ed4e989cbd6155f
|
|
| BLAKE2b-256 |
2bc72aae984f7760de2ad14d0b0ea16a370ba63e26e595917ecf8536fe68d3a4
|
File details
Details for the file pcd_py-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: pcd_py-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 449.5 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea5fbb2ce39c345ed56f5a217174cd5db2869443d72784df588a3ce742855e6f
|
|
| MD5 |
5a191ab4f135d69c7479afb09dd09ded
|
|
| BLAKE2b-256 |
c113312c685dd5c8edb9b127f3531fead1a2e5c9b394aabf8f6a1073058d1007
|
File details
Details for the file pcd_py-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: pcd_py-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 436.2 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
876156945bebd1cc90addf64772a395be96764f50a6440cfba8dfc647fd6ba6f
|
|
| MD5 |
2ef148167c6728a982cf65ddcdd4543b
|
|
| BLAKE2b-256 |
58ae5e65640b1e629d9641af5219a81e586c954229ebcc73fc12555455d7c29c
|
File details
Details for the file pcd_py-0.2.0-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: pcd_py-0.2.0-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 389.3 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
698131626ac05d65e7b1417d2deb6b6bae50ae523e182dd00a9803fc331992d6
|
|
| MD5 |
0bc96c037ea37508c704e86d7db8dc94
|
|
| BLAKE2b-256 |
19d1347950c056d3d7a2199f6d5dd8d59e0fec7be8628cc07543fcfad5295bcf
|
File details
Details for the file pcd_py-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: pcd_py-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 399.5 kB
- Tags: CPython 3.8+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f63976169bcb381a37d7a9ab37366910824572f1bd76ad3d8bd280873371c69
|
|
| MD5 |
dc8f3d80995f335061aadb595ccefb11
|
|
| BLAKE2b-256 |
f2f0279f74f60717d63664bdabd8704516f38c87f449299c82f22bd52ea264a1
|
File details
Details for the file pcd_py-0.2.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.
File metadata
- Download URL: pcd_py-0.2.0-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 782.2 kB
- Tags: CPython 3.8+, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8facb23ab97e6fb906b20b62ac35a24e554183f2be7b4183c3612497092503b3
|
|
| MD5 |
cd52dd6185d061439a04f67cc9d3881a
|
|
| BLAKE2b-256 |
c518cea2bf35c35602233c9926fcc7244e4e624c10e10590347d3c625f793679
|