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

Method get_o3d_pcds

pointersect/inference/structures.py:319–358  ·  view source on GitHub ↗

Return a list of b o3d pcds containing xyz and rgb.

(
            self,
            estimate_normal_if_not_exist: bool = False,
    )

Source from the content-addressed store, hash-verified

317 return new_point_cloud
318
319 def get_o3d_pcds(
320 self,
321 estimate_normal_if_not_exist: bool = False,
322 ) -> T.List[o3d.geometry.PointCloud]:
323 """Return a list of b o3d pcds containing xyz and rgb."""
324
325 o3d_pcds = []
326 for i in range(self.xyz_w.size(0)):
327
328 xyz_w = self.extract_valid_attr(
329 arr=self.xyz_w,
330 bidx=i,
331 ) # (n, 3)
332 if xyz_w is not None:
333 xyz_w = xyz_w.detach().cpu().numpy() # (n, 3)
334 rgb = self.extract_valid_attr(
335 arr=self.rgb,
336 bidx=i,
337 ) # (n, 3)
338 if rgb is not None:
339 rgb = rgb.detach().cpu().numpy() # (n, 3)
340 normal_w = self.extract_valid_attr(
341 arr=self.normal_w,
342 bidx=i,
343 ) # (n, 3)
344 if normal_w is not None:
345 normal_w = normal_w.detach().cpu().numpy() # (n, 3)
346
347 o3d_pcd = o3d.geometry.PointCloud()
348 o3d_pcd.points = o3d.utility.Vector3dVector(xyz_w) # (n, 3)
349 if rgb is not None:
350 o3d_pcd.colors = o3d.utility.Vector3dVector(rgb) # (n, 3)
351 if normal_w is not None:
352 o3d_pcd.normals = o3d.utility.Vector3dVector(normal_w) # (n, 3)
353
354 if estimate_normal_if_not_exist and normal_w is None:
355 o3d_pcd.estimate_normals() # default parameter (number of neighbor points = 30), random direction
356
357 o3d_pcds.append(o3d_pcd)
358 return o3d_pcds
359
360 def get_mesh(
361 self,

Callers 5

get_meshMethod · 0.95
saveMethod · 0.95
save_as_npbgppMethod · 0.95
rasterize_surfelMethod · 0.95

Calls 3

extract_valid_attrMethod · 0.95
sizeMethod · 0.80
detachMethod · 0.45

Tested by

no test coverage detected