Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove Nan in pointcloud when loading via Open3D

I'm trying to open a pcd file in python using open3d, but the array of the point cloud is filled by nan.

import numpy as np
import open3d as o3d
from pypcd4 import PointCloud

if __name__ == "__main__":

    print("Load a ply point cloud, print it, and render it")
    pcd = o3d.io.read_point_cloud("TestData1/000_00_cloud.pcd")
    print(pcd)
    print(np.asarray(pcd.points))
    o3d.visualization.draw_geometries([pcd])

Error:

Load a ply point cloud, print it, and render it
PointCloud with 518400 points.
[[nan nan nan]
 [nan nan nan]
 [nan nan nan]
 ...
 [nan nan nan]
 [nan nan nan]
 [nan nan nan]]

How can i exclude the nan point? I need to do something with the numpy?

like image 647
Alberto Fasan Avatar asked Dec 28 '25 14:12

Alberto Fasan


1 Answers

There are 2 ways to do this -

  1. Pass remove_nan_points=True and remove_infinite_points=True to o3d.io.read_point_cloud.
  2. Read the pointcloud and later call pcd.remove_non_finite_points()

See docs here and here.

like image 135
saurabheights Avatar answered Dec 31 '25 17:12

saurabheights