MCPcopy Create free account
hub / github.com/apple/ml-pointersect / from_o3d_pcd

Method from_o3d_pcd

pointersect/inference/structures.py:73–99  ·  view source on GitHub ↗

Return a point cloud object from o3d_pcd Args: o3d_pcd: (n,) Returns: (b=1, n)

(
            o3d_pcd: o3d.geometry.PointCloud,
    )

Source from the content-addressed store, hash-verified

71
72 @staticmethod
73 def from_o3d_pcd(
74 o3d_pcd: o3d.geometry.PointCloud,
75 ) -> 'PointCloud':
76 """
77 Return a point cloud object from o3d_pcd
78 Args:
79 o3d_pcd:
80 (n,)
81 Returns:
82 (b=1, n)
83 """
84 xyz_w = torch.from_numpy(np.array(o3d_pcd.points)).float().unsqueeze(0) # (1, n, 3)
85 if o3d_pcd.has_normals():
86 normals = torch.from_numpy(np.array(o3d_pcd.normals)).float().unsqueeze(0) # (1, n, 3)
87 else:
88 normals = None
89 if o3d_pcd.has_colors():
90 colors = torch.from_numpy(np.array(o3d_pcd.colors)).float().unsqueeze(0) # (1, n, 3)
91 assert colors.ndim == 3
92 assert colors.size(-1) == 3
93 else:
94 colors = None
95 return PointCloud(
96 xyz_w=xyz_w, # (1, n, 3)
97 rgb=colors,
98 normal_w=normals,
99 )
100
101 def get_num_points(self) -> int:
102 """

Callers 2

render_arkitscenesFunction · 0.80
render_point_cloudFunction · 0.80

Calls 2

PointCloudClass · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected