Package: pgeof
Point Geometric Features📌 DescriptionPython wrapper around C++ helper to compute, for each point in a 3D point cloud, local geometric features in parallel on CPU:️List of computed features️linearityplanarityscatteringverticalitynormal_xnormal_ynormal_zlengthsurfacevolumecurvatureoptimal neighborhood size🧱 InstallationPgeof willsoonbe available as pre compiled package on PyPI for both Linux and Windows OSes.python-mpipinstallpgeofbuilding from sourcesPgeof depends onEigen libraryand numpy headers at build time.
The good version of numpy will be fetched from PyPI automatically by the build system but your are responsible for providing
the path to the Eigen library you want to use (for example py usingCXXFLAGSvariable on Linux or settingEIGEN_LIB_PATH)# clone projectgitclonehttps://github.com/drprojects/point_geometric_features.gitcdpoint_geometric_features# set the EIGEN_LIB_PATH if neededexportEIGEN_LIB_PATH="path_to_eigen_root_dir"# build and install the packagepython-mpipinstall.condaThe following will install the project in a newpgeofconda environment.# clone projectgitclonehttps://github.com/drprojects/point_geometric_features.gitcdpoint_geometric_features# Installation in a new dedicated `pgeof` conda environmentbashinstall.shYou can easily adaptinstall.shto install the project in an already-existing
environment.🚀 Using Point Geometric FeaturesThepgeoffunction should be used as follows:frompgeofimportpgeofpgeof(xyz,# [n_points, 3] float32 2D array - 3D point coordinatesnn,# [num_neighborhoods] uint32 1D array - Flattened neighbor indices. Make sure those are all positive, '-1' indices will either crash or silently compute incorrect featuresnn_ptr,# [n_points+1] uint32 1D array - Pointers wrt `nn`. More specifically, the neighbors of point `i` are `nn[nn_ptr[i]:nn_ptr[i + 1]]`k_min=1,# (optional, default=1) int - Minimum number of neighbors to consider for features computation. If a point has less, it will be given 0 featuresk_step=-1,# (optional, default=-1) int - Step size to take when searching for the optimal neighborhood size for each point, following: http://lareg.ensg.eu/labos/matis/pdf/articles_revues/2015/isprs_wjhm_15.pdf. If k_step < 1, pgeof will not search for the optimal neighborhood and features will be computed based on the all available neighbors for each pointk_min_search=10,# (optional, default=10) int - Minimum neighborhood size at which to start when searching for the optimal neighborhood size for each point. It is advised to use a value of 10 or higher, for geometric features robustnessverbose=False)# (optional, default=False) bool - Whether computation progress should be printed out# Print details on how pgeof works and expected input parametersprint(help(pgeof))👇 You may check out the provideddemo.pyscript to get started.pythondemo.py⚠️ Please note theneighbors are expected in CSR format. This allows
expressing neighborhoods of varying sizes with dense arrays (eg the output of a
radius search). Here are examples of how to easily convert typical k-NN or
radius-NN neighborhoods to CSR format.fromsklearn.neighborsimportNearestNeighborsimportnumpyasnp# Generate a random synthetic point cloud and k-nearest neighborsnum_points=10000k=20xyz=np.random.rand(num_points,3)kneigh=NearestNeighbors(n_neighbors=k).fit(xyz).kneighbors(xyz)# Converting k-nearest neighbors to CSR formatnn_ptr=np.arange(num_points+1)*knn=kneigh[1].flatten()fromsklearn.neighborsimportNearestNeighborsimportnumpyasnp# Generate a random synthetic point cloud and radius neighborsnum_points=10000radius=0.1xyz=np.random.rand(num_points,3)rneigh=NearestNeighbors(radius=radius).fit(xyz).radius_neighbors(xyz)# Converting radius neighbors to CSR formatnn_ptr=np.r_[0,np.array([x.shape[0]forxinrneigh[1]]).cumsum()]nn=np.concatenate(rneigh[1])💳 CreditsThis implementation was largely inspired fromSuperpoint Graph. The main modifications here allow:parallel computation on all points' local neighborhoods, with neighborhoods of varying sizesmore geometric featuresoptimal neighborhood search from thispapersome corrections on geometric features computationLicensePoint Geometric Features is licensed under the MIT License.