Octree.insert_point

Hi,

I am trying to insert points from a point cloud into an open3d octree. I use this code:

# Octree integration test
o3d_pcl_1 = o3d.geometry.PointCloud.create_from_rgbd_image(rgbd1, camera_intrinsics)
o3d_vox_1 = o3d.geometry.VoxelGrid.create_from_point_cloud(o3d_pcl_1, 1e-3)
octree1 = o3d_vox_1.to_octree(8)

o3d_pcl_2 = o3d.geometry.PointCloud.create_from_rgbd_image(rgbd2, camera_intrinsics)
points2 = np.asarray(o3d_pcl_2.points)
for point in points2:
   octree1.insert_point(octree1, point)

and get this error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-74-0d26b9accd10> in <module>
      3 points2 = np.asarray(o3d_pcl_2.points)
      4 for point in points2:
----> 5     octree1.insert_point(octree1, point)

TypeError: insert_point(): incompatible function arguments. The following argument types are supported:
    1. (self: open3d.open3d_pybind.geometry.Octree, point: numpy.ndarray[float64[3, 1]], f_init: Callable[[], open3d.open3d_pybind.geometry.OctreeLeafNode], f_update: Callable[[open3d.open3d_pybind.geometry.OctreeLeafNode], None]) -> None

Invoked with: geometry::Octree with origin: [-1.32618, -0.938926, 1.0305], size: 2.261, max_depth: 8, geometry::Octree with origin: [-1.32618, -0.938926, 1.0305], size: 2.261, max_depth: 8, array([-1.2268764 ,  0.96355541, -0.88814585])

What is the problem? Does it come from f_init and f_update?

Hi,
I am facing the same issue. However, using:

  • octree = o3d.geometry.Octree()
  • octree.locate_leaf_node(point),

I am able to locate the point and return the leaf node that the point should reside in.

Why does the octree.insert_point() not work for the same leaf node??

thanks

Hi,

I found out a solution to my problem on this Github

My code becomes:

o3d_pcl_1 = o3d.geometry.PointCloud.create_from_rgbd_image(rgbd1, camera_intrinsics)
o3d_vox_1 = o3d.geometry.VoxelGrid.create_from_point_cloud(o3d_pcl_1, 1e-3)
octree1 = o3d_vox_1.to_octree(8)

o3d_pcl_2 = o3d.geometry.PointCloud.create_from_rgbd_image(rgbd2, camera_intrinsics)
points2 = np.asarray(o3d_pcl_2.points)
colors2 = np.asarray(o3d_pcl_2.colors)
for point, color in zip(points2, colors2):
    f_init = o3d.geometry.OctreeColorLeafNode.get_init_function()
    f_update = o3d.geometry.OctreeColorLeafNode.get_update_function(color)
    octree1.insert_point(point, f_init, f_update)

This will add points to the existing octree1 in the limit of the space it covers in world frame. The frontiers of octree1 are not updated to add points that are out of its reach. To have updatable octree frontiers, I will do my deed with Octomap

Hi,

thanks. That worked out for me as well.
Would you have any idea to propose on how to access each leaf node’s points efficiently in order to perfrom computation per node?