Metadata-Version: 2.1
Name: pypcd4
Version: 0.4.8
Summary: Read and write PCL .pcd files in python
Project-URL: Release Notes, https://github.com/MapIV/pypcd4/releases
Project-URL: Source, https://github.com/MapIV/pypcd4
Project-URL: Tracker, https://github.com/MapIV/pypcd4/issues
Author-email: urasakikeisuke <keisuke.urasaki@map4.jp>
License: BSD 3-Clause License
        
        Copyright (c) 2018, Daniel Maturana
        Copyright (c) 2023-present, MAP IV, Inc.
        
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        * Redistributions of source code must retain the above copyright notice, this
          list of conditions and the following disclaimer.
        
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        
        * Neither the name of wsrv.nl and images.weserv.nl nor the names of its
          contributors may be used to endorse or promote products derived from
          this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE.txt
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Utilities
Requires-Python: >=3.8.2
Requires-Dist: numpy>=1.21.0
Requires-Dist: pydantic<=2.5.2,>=1.10.8
Requires-Dist: python-lzf>=0.2.4
Provides-Extra: dev
Requires-Dist: black; extra == 'dev'
Requires-Dist: isort; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: setuptools-scm; extra == 'dev'
Description-Content-Type: text/markdown

# pypcd4

## Description

pypcd4 is a modern reimagining of the original [pypcd](https://github.com/dimatura/pypcd) library,
offering enhanced capabilities and performance for working with Point Cloud Data (PCD) files.

This library builds upon the foundation laid by the original pypcd while incorporating modern
Python3 syntax and methodologies to provide a more efficient and user-friendly experience.

## Install

You can install pypcd4 via pip,

```shell
pip install pypcd4
```

## How to use

### Import pypcd4

```python
from pypcd4 import PointCloud
```

### Read from .pcd file

```python
pc: PointCloud = PointCloud.from_path("xyzi.pcd")
```

### PointCloud -> NumPy array

```python
array: np.ndarray = pc.numpy()

array.shape
# (1000, 4)
```

### NumPy array -> PointCloud

```python
# Depends on number of features of your array

# If PointXYZI,
pc = PointCloud.from_xyzi_points(array)

# If PointXYZL,
pc = PointCloud.from_xyzl_points(array, label_type=np.uint32)
```

### ROS PointCloud2 Message -> PointCloud

Added in v0.4.0

```python
def callback(msg):
    pc = PointCloud.from_msg(msg)

    pc.fields
    # ("x", "y", "z", "intensity", "ring", "time")
```

### Create custom conversion method

If you cannot find preferred point type in pre-defined conversion methods,
you can create it easily like,

```python
fields = ("x", "y", "z", "intensity", "new_field")
types = (np.float32, np.float32, np.float32, np.float32, np.float64)

pc = PointCloud.from_points(array, fields, types)
```

### Save as .pcd file

```python
pc.save("nice_point_cloud.pcd")
```

## License

The library was rewritten and does not borrow any code from the original [pypcd](https://github.com/dimatura/pypcd) library.
Since it was heavily inspired by the original author's work, we extend his original BSD 3-Clause License and include his Copyright notice.

## TODO

- [ ] Support ROS message conversion
  - [x] ROS message -> PointCloud
  - [ ] PointCloud  -> ROS message
- [ ] Visualization
