https://github.com/drprojects/point_geometric_features

Python wrapper around C++ utilities for computing neighbors and local geometric features of a point cloud

https://github.com/drprojects/point_geometric_features

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.2%) to scientific vocabulary

Keywords

3d cpu fast features geometric-features machine-learning nanoflann nearest-neighbors neighbor-search numpy point-cloud python radius-neighbors

Keywords from Contributors

partition
Last synced: 5 months ago · JSON representation

Repository

Python wrapper around C++ utilities for computing neighbors and local geometric features of a point cloud

Basic Info
  • Host: GitHub
  • Owner: drprojects
  • License: mit
  • Language: C++
  • Default Branch: main
  • Homepage:
  • Size: 131 KB
Statistics
  • Stars: 65
  • Watchers: 2
  • Forks: 5
  • Open Issues: 0
  • Releases: 0
Topics
3d cpu fast features geometric-features machine-learning nanoflann nearest-neighbors neighbor-search numpy point-cloud python radius-neighbors
Created over 3 years ago · Last pushed 7 months ago
Metadata Files
Readme License

README.md

# Point Geometric Features [![python](https://img.shields.io/badge/-Python_3.9_%7C_3.10_%7C_3.11_%7C_3.12-blue?logo=python&logoColor=white)](#) ![C++](https://img.shields.io/badge/c++-%2300599C.svg?style=for-the-badge&logo=c%2B%2B&logoColor=white) [![license](https://img.shields.io/badge/License-MIT-green.svg?labelColor=gray)](#)

📌 Description

The pgeof library provides utilities for fast, parallelized computing ⚡ of local geometric features for 3D point clouds ☁️ on CPU .

️List of available features ️👇 - linearity - planarity - scattering - verticality (two formulations) - normal_x - normal_y - normal_z - length - surface - volume - curvature - optimal neighborhood size

pgeof allows computing features in multiple fashions: on-the-fly subset of features a la jakteristics, array of features, or multiscale features. Moreover, pgeof also offers functions for fast K-NN or radius-NN searches 🔍.

Behind the scenes, the library is a Python wrapper around C++ utilities. The overall code is not intended to be DRY nor generic, it aims at providing efficient as possible implementations for some limited scopes and usages.

🧱 Installation

From binaries

bash python -m pip install pgeof

or

bash python -m pip install git+https://github.com/drprojects/point_geometric_features

Building from sources

pgeof depends on Eigen library, Taskflow, nanoflann and nanobind. The library adheres to PEP 517 and uses scikit-build-core as build backend. Build dependencies (nanobind, scikit-build-core, ...) are fetched at build time. C++ third party libraries are embedded as submodules.

```bash

Clone project

git clone --recurse-submodules https://github.com/drprojects/pointgeometricfeatures.git cd pointgeometricfeatures

Build and install the package

python -m pip install . ```

🚀 Using Point Geometric Features

Here we summarize the very basics of pgeof usage. Users are invited to use help(pgeof) for further details on parameters.

At its core pgeof provides three functions to compute a set of features given a 3D point cloud and some precomputed neighborhoods.

```python import pgeof

Compute a set of 11 predefined features per points

pgeof.computefeatures( xyz, # The point cloud. A numpy array of shape (n, 3) nn, # CSR data structure see below nnptr, # CSR data structure see below k_min = 1 # Minimum number of neighbors to consider for features computation verbose = false # Basic verbose output, for debug purposes ) ```

```python

Sequence of n scales feature computation

pgeof.computefeaturesmultiscale( ... k_scale # array of neighborhood size ) ```

```python

Feature computation with optimal neighborhood selection as exposed in Weinmann et al., 2015

return a set of 12 features per points (11 + the optimal neighborhood size)

pgeof.computefeaturesoptimal( ... kmin = 1, # Minimum number of neighbors to consider for features computation kstep = 1, # Step size to take when searching for the optimal neighborhood kminsearch = 1, # Starting size for searching the optimal neighborhood size. Should be >= k_min ) ```

⚠️ Please note that for theses three functions the neighbors are expected in CSR format. This allows expressing neighborhoods of varying sizes with dense arrays (e.g. the output of a radius search).

We provide very tiny and specialized k-NN and radius-NN search routines. They rely on nanoflann C++ library and should be faster and lighter than scipy and sklearn alternatives.

Here are some examples of how to easily compute and convert typical k-NN or radius-NN neighborhoods to CSR format (nn and nn_ptr are two flat uint32 arrays):

```python import pgeof import numpy as np

Generate a random synthetic point cloud and k-nearest neighbors

numpoints = 10000 k = 20 xyz = np.random.rand(numpoints, 3).astype("float32") knn, _ = pgeof.knn_search(xyz, xyz, k)

Converting k-nearest neighbors to CSR format

nnptr = np.arange(numpoints + 1) * k nn = knn.flatten()

You may need to convert nn/nn_ptr to uint32 arrays

nnptr = nnptr.astype("uint32") nn = nn.astype("uint32")

features = pgeof.computefeatures(xyz, nn, nnptr) ```

```python import pgeof import numpy as np

Generate a random synthetic point cloud and k-nearest neighbors

numpoints = 10000 radius = 0.2 k = 20 xyz = np.random.rand(numpoints, 3).astype("float32") knn, _ = pgeof.radius_search(xyz, xyz, radius, k)

Converting radius neighbors to CSR format

nnptr = np.r[0, (knn >= 0).sum(axis=1).cumsum()] nn = knn[knn >= 0]

You may need to convert nn/nn_ptr to uint32 arrays

nnptr = nnptr.astype("uint32") nn = nn.astype("uint32")

features = pgeof.computefeatures(xyz, nn, nnptr) ```

At last, and as a by-product, we also provide a function to compute a subset of features on the fly. It is inspired by the jakteristics python package (while being less complete but faster). The list of features to compute is given as an array of EFeatureID.

```python import pgeof from pgeof import EFeatureID import numpy as np

Generate a random synthetic point cloud and k-nearest neighbors

numpoints = 10000 radius = 0.2 k = 20 xyz = np.random.rand(numpoints, 3)

Compute verticality and curvature

features = pgeof.computefeaturesselected(xyz, radius, k, [EFeatureID.Verticality, EFeatureID.Curvature]) ```

Known limitations

Some functions only accept float scalar types and uint32 index types, and we avoid implicit cast / conversions. This could be a limitation in some situations (e.g. point clouds with double coordinates or involving very large big integer indices). Some C++ functions could be templated / to accept other types without conversion. For now, this feature is not enabled everywhere, to reduce compilation time and enhance code readability. Please let us know if you need this feature !

By convention, our normal vectors are forced to be oriented towards positive Z values. We make this design choice in order to return consistently-oriented normals.

Testing

Some basic tests and benchmarks are provided in the tests directory. Tests can be run in a clean and reproducible environments via tox (tox run and tox run -e bench).

💳 Credits

This implementation was largely inspired from Superpoint Graph. The main modifications here allow: - parallel computation on all points' local neighborhoods, with neighborhoods of varying sizes - more geometric features - optimal neighborhood search from this paper - some corrections on geometric features computation

Some heavy refactoring (port to nanobind, test, benchmarks), packaging, speed optimization, feature addition (NN search, on the fly feature computation...) were funded by:

Centre of Wildfire Research of Swansea University (UK) in collaboration with the Research Institute of Biodiversity (CSIC, Spain) and the Department of Mining Exploitation of the University of Oviedo (Spain).

Funding provided by the UK NERC project (NE/T001194/1):

'Advancing 3D Fuel Mapping for Wildfire Behaviour and Risk Mitigation Modelling'

and by the Spanish Knowledge Generation project (PID2021-126790NB-I00):

‘Advancing carbon emission estimations from wildfires applying artificial intelligence to 3D terrestrial point clouds’.

License

Point Geometric Features is licensed under the MIT License.

Owner

  • Name: Damien ROBERT
  • Login: drprojects
  • Kind: user
  • Location: France
  • Company: ENGIE Lab CRIGEN & IGN

PhD candidate at IGN and ENGIE Lab CRIGEN. I design deep learning methods for computer vision on 3D and 2D data.

GitHub Events

Total
  • Issues event: 1
  • Watch event: 12
  • Issue comment event: 3
  • Push event: 3
  • Pull request event: 2
  • Pull request review event: 2
Last Year
  • Issues event: 1
  • Watch event: 12
  • Issue comment event: 3
  • Push event: 3
  • Pull request event: 2
  • Pull request review event: 2

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 77
  • Total Committers: 4
  • Avg Commits per committer: 19.25
  • Development Distribution Score (DDS): 0.273
Past Year
  • Commits: 17
  • Committers: 2
  • Avg Commits per committer: 8.5
  • Development Distribution Score (DDS): 0.059
Top Committers
Name Email Commits
Romain Janvier r****r@h****r 56
drprojects d****1@w****r 18
loicland l****c@g****m 2
dam d****m@m****x 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 6
  • Total pull requests: 14
  • Average time to close issues: 25 days
  • Average time to close pull requests: 3 days
  • Total issue authors: 5
  • Total pull request authors: 2
  • Average comments per issue: 4.83
  • Average comments per pull request: 1.36
  • Merged pull requests: 14
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 4
  • Average time to close issues: about 3 hours
  • Average time to close pull requests: 3 days
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 1.0
  • Average comments per pull request: 1.0
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • rjanvier (2)
  • noisyneighbour (1)
  • gardiens (1)
  • SherlockCorleone (1)
  • drprojects (1)
Pull Request Authors
  • rjanvier (19)
  • loicland (1)
Top Labels
Issue Labels
help wanted (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 843 last-month
  • Total dependent packages: 1
  • Total dependent repositories: 0
  • Total versions: 8
  • Total maintainers: 1
pypi.org: pgeof

Compute the geometric features associated with each point's neighborhood:

  • Documentation: https://pgeof.readthedocs.io/
  • License: MIT License Copyright (c) 2023-2024 Damien Robert, Loic Landrieu, Romain Janvier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  • Latest release: 0.3.3
    published 8 months ago
  • Versions: 8
  • Dependent Packages: 1
  • Dependent Repositories: 0
  • Downloads: 843 Last month
Rankings
Dependent packages count: 7.3%
Average: 38.0%
Dependent repos count: 68.6%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/wheels.yml actions
  • actions/checkout v4 composite
  • actions/checkout v3 composite
  • actions/download-artifact v3 composite
  • actions/setup-python v3 composite
  • actions/upload-artifact v3 composite
pyproject.toml pypi
  • numpy *
setup.py pypi