对于一个研究项目,我尝试进行点云比较。为了简短起见,我有一个 CAD 文件 (.stl) 和几个由激光扫描仪创建的点云。现在我想计算 CAD 文件和每个点云之间的差异。
首先,我从 Cloud Compare 开始,这有助于获得基本的理解。(减少点、删除重复项、创建网格并比较距离)
在 python 中,我能够导入文件并进行一些基本计算。但是,我无法计算距离。
这是我的代码:
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 给了我这个错误:“TypeError:compute_point_cloud_distance():不兼容的函数参数。支持以下参数类型:1.(self:open3d.cpu.pybind.geometry.PointCloud,target:open3d.cpu.pybind。几何.PointCloud) -> open3d.cpu.pybind.utility.DoubleVector"
问题:需要对网格和点云进行哪些预转换来计算它们的距离?有没有推荐的方法来显示差异?
到目前为止,我只使用了下面的可视化线
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])