首页 > 解决方案 > 如何在 Open3D 中更改点云中选定点的位置和颜色?

问题描述

我在 Open3D 中创建了一个具有 200 个点的点云(例如 pcd)。现在,我想使用“非阻塞可视化”,例如更改点云中点 0 的位置和颜色。所以,我尝试了这段代码:

for i in range(icp_iteration):
pcd.points[0] = o3d.utility.Vector3dVector(New_Location)
vis.update_geometry(pcd)
vis.poll_events()
vis.update_renderer()
vis.destroy_window()

其中 New_Location 是 (1, 3) numpy 数组。但我得到这个错误:

    pcd.points[0] = o3d.utility.Vector3dVector(New_Location)
TypeError: __setitem__(): incompatible function arguments. The following argument types are supported:
    1. (self: open3d.cpu.pybind.utility.Vector3dVector, arg0: int, arg1: numpy.ndarray[float64[3, 1]]) -> None
    2. (self: open3d.cpu.pybind.utility.Vector3dVector, arg0: slice, arg1: open3d.cpu.pybind.utility.Vector3dVector) -> None

Invoked with: std::vector<Eigen::Vector3d> with 166 elements.
Use numpy.asarray() to access data., 0, std::vector<Eigen::Vector3d> with 1 elements.
Use numpy.asarray() to access data.

Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>,
<pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic
conversions are optional and require extra headers to be included
when compiling your pybind11 module.

如果我使用,“颜色”也会发生同样的事情:

pcd.colors[0] = o3d.utility.Vector3dVector(New_Color)

其中“New_Color”是一个 (1, 3) numpy 数组。请注意,我不能使用“翻译”矩阵,因为我只想更改一组点(不是全部)的位置。

如何手动更改点云中一组点的位置、颜色、大小等?

标签: pythondata-visualizationpoint-cloudsopen3d

解决方案


推荐阅读