Reputation: 15
I need to extract all vertices from a usd/a file, currently I'm doing it like this:
from pxr import Usd, UsdGeom, Sdf
def extract_points_from_usd(file_path):
"""Extracts 3D points from a USD or USDA file."""
stage = Usd.Stage.Open(file_path)
points = []
for prim in stage.Traverse():
if prim.IsA(UsdGeom.Mesh):
usd_points = UsdGeom.Mesh(prim).GetPointsAttr().Get()
if usd_points:
points.extend(usd_points)
return np.array(points)
But it's not accurate as there seems to be fewer vertices and all the Z values are either 0 or very close to 0.
I need this to make a point cloud file (.las), alternatively, I could transform the .usd file to .ply and convert that to a point cloud, which is much more straight forward, but I can't find the way to do that conversion on python script. This is for an aws lambda function so I can't rely on software like blender or cloudcompare.
Upvotes: 1
Views: 53