Skip to main content

A lightweight PCD file processing library

Project description

PCDKit

A lightweight and efficient Python library for working with PCD (Point Cloud Data) files.
Supports both in-memory and memory-mapped processing, and provides modular tools for I/O, transformation, merge and metadata management.

📦 Features

  • ✅ Read/write PCD files (ASCII, binary, and compressed)
  • ✅ Structured NumPy or memory-mapped point cloud representation
  • ✅ Add/drop/set custom fields
  • ✅ Apply geometric transformations (e.g., rotation, translation)
  • ✅ Metadata-aware, type-safe interface

🚀 Installation

pip install pcdkit

🧪 Usgae

from pathlib import Path

import numpy as np
import pcloud

# Create a structured NumPy array with 5 3D points
array = np.array([
    (1.0, 2.0, 3.0),
    (4.0, 5.0, 6.0),
    (7.0, 8.0, 9.0),
    (10.0, 11.0, 12.0),
    (13.0, 14.0, 15.0),
], dtype=[("x", "f4"), ("y", "f4"), ("z", "f4")])

# Temporary paths for saving memory-mapped file and PCD
memmap_path = Path("test.memmap")
pcd_path = Path("test.pcd")

# ----------------------------
# 1. Construct PointCloud from NumPy array
# ----------------------------
cloud = pcloud.from_array(array, memmap_file_path=memmap_path)

# Add a new field called 'intensity' with default value 1.0
cloud.add_field("intensity", "f4", default=1.0)

# Set the intensity field to a constant value
cloud.set_field("intensity", 5.0)

# Overwrite the intensity field with a per-point array
cloud.set_field("intensity", np.array([10, 20, 30, 40, 50]))

# Apply an affine transformation (scale coordinates by 2)
transform = np.eye(4)
transform[:3, :3] *= 2
cloud.transform(transform)

# Drop the intensity field
cloud.drop_field("intensity")

# Save the point cloud to a binary PCD file
cloud.save(pcd_path, format="binary")
print(f"Saved PointCloud from array to: {pcd_path}")

# ----------------------------
# 2. Load the saved PCD back and verify structure
# ----------------------------
cloud_loaded = pcloud.load_pcd_from_path(
    file_path=pcd_path,
    memmap_file_path=memmap_path.with_suffix(".reloaded.memmap"),
    replace_nan_with_zero=True,
)

print("Reloaded PointCloud:")
print(cloud_loaded)

# ----------------------------
# 3. Merge the original and reloaded clouds
# ----------------------------
merged_cloud = pcloud.merge(
    [cloud, cloud_loaded],
    memmap_file_path=Path("merged.memmap")
)

print("Merged PointCloud:")
print(merged_cloud)
merged_cloud.save("merged.pcd", format="binary")

Project details


Download files

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

Source Distribution

pcdkit-0.2.3.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

pcdkit-0.2.3-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file pcdkit-0.2.3.tar.gz.

File metadata

  • Download URL: pcdkit-0.2.3.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pcdkit-0.2.3.tar.gz
Algorithm Hash digest
SHA256 268247a1735399861cb394ab2746e57a9a9677713112c310bde59d0b25cfb6be
MD5 439bf469dac3446fa479ba956bdf7097
BLAKE2b-256 987efcc4f1a9fde0bf0f264054f3c2f1138733989078bfc0623bf3d76b0127ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for pcdkit-0.2.3.tar.gz:

Publisher: release.yml on FledgeXu/PCDKit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pcdkit-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: pcdkit-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pcdkit-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2ff9942c42280385152a176fa0cfa7fde27003d0915ee4f162cd7dc9e8431ac2
MD5 ddeac817d2aad6a05b924df0eb5ba482
BLAKE2b-256 8363103ed4ffa65cc13231b99e4e468c5e99b10f95d9b774aa5e59410926dd53

See more details on using hashes here.

Provenance

The following attestation bundles were made for pcdkit-0.2.3-py3-none-any.whl:

Publisher: release.yml on FledgeXu/PCDKit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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