Skip to content
Advertisement

Adding new points to point cloud in real time – Open3D

I am using Open3D to visualize point clouds in Python. Essentially, what I want to do is add another point to the point cloud programmatically and then render it in real time.

This is what I have so far. I could not find any solution to this.

In the code below, I show one possible solution, but it is not effective. The points get added and a new window is opened as soon as the first one is closed. This is not what I want. I want it to dynamically show new points, without closing and opening again. As well as the fact that a new variable is created, which I think can be problematic when working with larger and larger data sets

JavaScript

Is there any possible solution to this?

If not, what other libraries can I look at that has the ability to render new incoming points in real time.

Advertisement

Answer

New points can be added and visualized interactively to a PointCloud by extending PointCloud.points with the new coordinates.

This is because when we use numpy arrays, we need to create a Vector3dVector isntance which has the convenient method extend implemented. From the docs:

extend(*args, **kwargs)

Overloaded function.

  1. extend(self: open3d.cpu.pybind.utility.Vector3dVector, L: open3d.cpu.pybind.utility.Vector3dVector) -> None

Extend the list by appending all the items in the given list

  1. extend(self: open3d.cpu.pybind.utility.Vector3dVector, L: Iterable) -> None

Extend the list by appending all the items in the given list

So we can use different object instances e.g. ndarrays, Vector3dVector, lists etc.

A toy example and its result:

image-right

JavaScript

Why not create an updated geometry and remove the old one?

For completeness, other (which I believe to be not better) alternative approach could consist on the following steps:

  1. Remove the current PointCloud
  2. concatenate the new points as in the OP’s question
  3. Create new Pointcloud and add it to the visualizer.

This yields worse perfomance and barely allows interaction with the visualization.

To see this, let’s have a look to the following comparison, with the same settings (code below). Both versions run the same time (~10 secs).

Using extend Removing and creating PointCloud
✔️ Allows interaction ❌ Difficult interaction
enter image description here enter image description here
Mean execution time (for adding points): 0.590 ms Mean execution time (for adding points): 1.550 ms

Code to reproduce:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement