1

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.

2
  • pxr is from nvidia, right? Commented Dec 12, 2024 at 21:21
  • I think so, yeah Commented Dec 12, 2024 at 22:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.