Last active
April 17, 2020 08:28
-
-
Save sergeyprokudin/0f82176585d19665afe72d02417e9a55 to your computer and use it in GitHub Desktop.
Simple point cloud visualization with pyntcloud library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Simple point cloud visualization with pyntcloud library | |
""" | |
import pyntcloud as pynt | |
import pandas as pd | |
import numpy as np | |
def show_cloud(xyz, rgb=None, initial_point_size=0.01): | |
""" Show point cloud with PyNT native function | |
""" | |
points = xyz_to_pynt(xyz, rgb=rgb) | |
points.plot(return_scene=True, initial_point_size=initial_point_size) | |
return | |
def show_cloud_pair(x1, x2, initial_point_size=0.01): | |
rgb1 = np.zeros(x1.shape) | |
rgb1[:, 1] = 255 | |
rgb2 = np.zeros(x2.shape) | |
rgb2[:, 0] = 255 | |
rgb = np.vstack([rgb1, rgb2]) | |
show_cloud(np.concatenate([x1, x2]), rgb=rgb, initial_point_size=initial_point_size) | |
return | |
def xyz_to_pynt(xyz, rgb=None): | |
""" Convert numpy array with xyz coords to pynt cloud | |
""" | |
if rgb is not None: | |
points = pd.DataFrame(np.hstack([xyz, rgb]), columns=['x', 'y', 'z', 'red', 'green', 'blue']) | |
else: | |
points = pd.DataFrame(xyz, columns=['x', 'y', 'z']) | |
points = pynt.PyntCloud(points) | |
return points |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment