1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] open3d compute distance between mesh and point cloud

Discussão em 'Python' iniciado por Stack, Outubro 8, 2024.

  1. Stack

    Stack Membro Participativo

    I have a CAD file (.stl) and several point clouds created by a laser scanner. now I want to calculate the difference between the CAD file and each point cloud.

    first I started with Cloud Compare which helps a lot to get a basic understanding. (reduction of points, remove duplicates, create a mesh and compare distances)

    In python, I was able to import the files and do some basic calculations. However, I am not able to calculate the distance.

    here is my code:

    import numpy as np
    import open3d as o3d

    #read point cloud
    dataname_pcd= "pcd.xyz"
    point_cloud = np.loadtxt(input_path+dataname_pcd,skiprows=1)
    #read mesh
    dataname_mesh = "cad.stl"
    mesh = o3d.io.read_triangle_mesh(input_path+dataname_mesh)
    print (mesh)

    #calulate the distance
    mD = o3d.geometry.PointCloud.compute_point_cloud_distance([point_cloud],[mesh])


    #calculate the distance gives me this error: "TypeError: compute_point_cloud_distance(): incompatible function arguments. The following argument types are supported: 1. (self: open3d.cpu.pybind.geometry.PointCloud, target: open3d.cpu.pybind.geometry.PointCloud) -> open3d.cpu.pybind.utility.DoubleVector"

    Questions: what pre transformations for mesh and point clouds are needed to calculate their distances? is there a recommended way to display the differences?

    so far I just used the visualization line below

    o3d.visualization.draw_geometries([pcd],
    zoom=0.3412,
    front=[0.4257, -0.2125, -0.8795],
    lookat=[2.6172, 2.0475, 1.532],
    up=[-0.0694, -0.9768, 0.2024])

    Continue reading...

Compartilhe esta Página