简体   繁体   中英

How to save a octree to a file using open3d.io.write_octree?

I tried to save an octree in a file with open3d.io.write_octree.

import open3d as o3d
import numpy as np
from open3d.web_visualizer import draw
from numpy import savetxt

if __name__ == "__main__":
    N = 2000
    armadillo_data = o3d.data.ArmadilloMesh()
    pcd = o3d.io.read_triangle_mesh(
        armadillo_data.path).sample_points_poisson_disk(N)
    # Fit to unit cube.
    pcd.scale(1 / np.max(pcd.get_max_bound() - pcd.get_min_bound()),
              center=pcd.get_center())
    pcd.colors = o3d.utility.Vector3dVector(np.random.uniform(0, 1,
                                                              size=(N, 3)))
    print('Displaying input pointcloud ...')
    #draw([pcd])

    octree = o3d.geometry.Octree(max_depth=4)
    octree.convert_from_point_cloud(pcd, size_expand=0.01)
    print('Displaying octree ..')
    #draw([octree])
    
    o3d.io.write_point_cloud("copy_of_fragment.pcd", pcd)

    o3d.io.write_octree("octofile.oct", octree)

But this does not work, write_point_cloud works fine but write_octree does not.

Anyone used this function? Is there something that I am missing here?

I am trying to create a file like below in the end.

octree.txt

Thanks for the valuable feedbacks in Advance.

I choose to use octomap library instead of open3d which has many built in options for OcTree.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM