【发布时间】:2022-05-18 21:28:49
【问题描述】:
首先我不得不说我对编程很陌生,尤其是在 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 上的 MS Visual Studio Code 中使用 Python 3.9。
【问题讨论】:
-
快速浏览后,我想知道您为什么将
[downpcd]传递给crop_point_cloud而不是downpcd。该函数需要一个 PointCloud,但您传递的是一个包含一个 PointCloud 元素的列表。
标签: open3d