首先,我不得不说,我对编程非常陌生,尤其是在Open3D中。我试图裁剪一个点云,但不是如Open3D教程中所示,使用一个*.json文件,而是使用4个坐标( 2D边界框的角点)创建的多边形卷。我的代码如下所示。
model = "point_cloud.ply"
pcd = o3d.io.read_point_cloud(model)
downpcd = pcd.voxel_down_sample(voxel_size = 0.015)
corners = np.array([
[ -0.091687413867212741, -0.14071210477866827, 0.0 ],
[ 0.030980770065893004, -0.14071210477866827, 0.0 ],
[ 0.030980770065893004, -0.044064443478879611, 0.0 ],
[ -0.091687413867212741, -0.044064443478879611, 0.0 ]
])
bounding_polygon = corners.astype("float64")
vol = o3d.visualization.SelectionPolygonVolume()
vol.orthogonal_axis = "Z"
vol.axis_max = 0.81700000000000017
vol.axis_min = -2.8580000000000001
vol.bounding_polygon = o3d.utility.Vector3dVector(bounding_polygon)直到这一行,一切看起来都很好,但是当我试图使用这个多边形卷用这个函数裁剪我的加载点云时,我总是会收到一个错误。
cropped_pcd = vol.crop_point_cloud([downpcd])这是我得到的错误:
Traceback (most recent call last):
File "c:\Users\Privat\Desktop\User\PCD\CropPCDByCoordinates.py", line 42, in <module>
cropped_pcd = vol.crop_point_cloud([downpcd])
TypeError: crop_point_cloud(): incompatible function arguments. The following argument types are supported:
1. (self: open3d.cpu.pybind.visualization.SelectionPolygonVolume, input: open3d.cpu.pybind.geometry.PointCloud) -> open3d.cpu.pybind.geometry.PointCloud
Invoked with: SelectionPolygonVolume, access its members:
orthogonal_axis, bounding_polygon, axis_min, axis_max, [PointCloud with 364980 points.]当我使用具有相同信息的*.json文件时,一切正常工作,但我希望在不加载*.json文件的情况下对其进行裁剪。
这是我从以下地方获得信息的*.json文件:
{
"axis_max" : 0.81700000000000017,
"axis_min" : -2.8580000000000001,
"bounding_polygon" :
[
[ -0.091687413867212741, -0.14071210477866827, 0.0 ],
[ 0.030980770065893004, -0.14071210477866827, 0.0 ],
[ 0.030980770065893004, -0.044064443478879611, 0.0 ],
[ -0.091687413867212741, -0.044064443478879611, 0.0 ]
],
"class_name" : "SelectionPolygonVolume",
"orthogonal_axis" : "Z",
"version_major" : 1,
"version_minor" : 0
} 如有任何建议和/或解释如何避免此错误,将不胜感激。谢谢。
我在Windows 10上使用代码中的Python3.9。
https://stackoverflow.com/questions/70449880
复制相似问题