daavoo / pyntcloud

pyntcloud is a Python library for working with 3D point clouds.
http://pyntcloud.readthedocs.io
MIT License
1.39k stars 221 forks source link

manual normals calculation from Pyntcloud.points object #311

Open jkissi opened 2 years ago

jkissi commented 2 years ago

Hello I have a problem when load .pcd files.PyntCloud.from_file()does not automatically create normals from .pcd files as it does from .ply files. I have tried to manually load my point data into a PyntCloud object using

cloud = PyntCloud(points)

However the resulting dataframe only consists of the x y z coordinates and not the normal vectors, which I also need. Can you show an example of how these can be manually generated? Is there a way to automatically create all the same variables as if you are using the from_file() function?

Thanks! J

daavoo commented 2 years ago

Hola @jkissi !

Unfortunately, there is no support for oriented normals, only unoriented which can be computed as follows:

k_neighbors = cloud.get_k_neighbors(k=10, ...)
cloud.add_scalar_field(
        "normals",
        k_neighbors=k_neighbors)

However, if your point cloud file already contains normal information, it looks like the way to go should be to extend read_pcd to correctly parse the normals from the file.

Alternatively (or in addition) we could add a new from_instance option to parse PCD instances directly (similar to from_pyvista)